comparison org/gabor.org @ 363:9fa92af29c3a

saving ...
author Robert McIntyre <rlm@mit.edu>
date Thu, 07 Mar 2013 05:36:17 +0000
parents 4b229dc028b6
children b599a189433b
comparison
equal deleted inserted replaced
362:4b229dc028b6 363:9fa92af29c3a
14 (ns cortex.gabor 14 (ns cortex.gabor
15 (:import org.opencv.core.CvType) 15 (:import org.opencv.core.CvType)
16 (:import java.awt.image.BufferedImage) 16 (:import java.awt.image.BufferedImage)
17 (:import ij.ImagePlus) 17 (:import ij.ImagePlus)
18 (:import org.opencv.core.Mat) 18 (:import org.opencv.core.Mat)
19 (:use cortex.sense) 19 (:use (cortex world sense util vision))
20 (:use cortex.util)) 20 (:import com.jme3.post.SceneProcessor)
21 (:import (com.jme3.util BufferUtils Screenshots))
22 (:import java.nio.ByteBuffer)
23 (:import java.awt.image.BufferedImage)
24 (:import (com.jme3.renderer ViewPort Camera))
25 (:import (com.jme3.math ColorRGBA Vector3f Matrix3f Vector2f))
26 (:import com.jme3.renderer.Renderer)
27 (:import com.jme3.app.Application)
28 (:import com.jme3.texture.FrameBuffer)
29 (:import (com.jme3.scene Node Spatial)))
30
31
32 (cortex.import/mega-import-jme3)
21 33
22 (defn load-opencv 34 (defn load-opencv
23 "Load the opencv native library. Must be called before any OpenCV 35 "Load the opencv native library. Must be called before any OpenCV
24 stuff is used." 36 stuff is used."
25 [] 37 []
91 (view (ImagePlus. output)))) 103 (view (ImagePlus. output))))
92 104
93 (defn print-kernel [kernel] 105 (defn print-kernel [kernel]
94 (println (.dump kernel))) 106 (println (.dump kernel)))
95 107
96 (defn convolve-practice [] 108
97 (let [input "/home/r/proj/cortex/images/dominos.jpg" 109 (def brick-length 0.48)
110 (def brick-width 0.24)
111 (def brick-height 0.12)
112 (def gravity (Vector3f. 0 -9.81 0))
113
114
115 (defn brick* [position]
116 (println "get brick.")
117 (doto (box brick-length brick-height brick-width
118 :position position :name "brick"
119 :material "Common/MatDefs/Misc/Unshaded.j3md"
120 :texture "Textures/Terrain/BrickWall/BrickWall.jpg"
121 :mass 34)
122 (->
123 (.getMesh)
124 (.scaleTextureCoordinates (Vector2f. 1 0.5)))
125 (.setShadowMode RenderQueue$ShadowMode/CastAndReceive)
126 )
127 )
128
129
130 (defn floor*
131 "make a sturdy, unmovable physical floor"
132 []
133 (box 10 0.1 5 :name "floor" :mass 0 :color ColorRGBA/Gray :position (Vector3f. 0 0 0)))
134
135 (defn floor* []
136 (doto (box 10 0.1 5 :name "floor" ;10 0.1 5 ; 240 0.1 240
137 :material "Common/MatDefs/Misc/Unshaded.j3md"
138 :texture "Textures/BronzeCopper030.jpg"
139 :position (Vector3f. 0 0 0 )
140 :mass 0)
141 (->
142 (.getMesh)
143 (.scaleTextureCoordinates (Vector2f. 3 6)));64 64
144 (->
145 (.getMaterial)
146 (.getTextureParam "ColorMap")
147 (.getTextureValue)
148 (.setWrap Texture$WrapMode/Repeat))
149 (.setShadowMode RenderQueue$ShadowMode/Receive)
150 ))
151
152
153 (defn brick-wall* []
154 (let [node (Node. "brick-wall")]
155 (dorun
156 (map
157 (comp #(.attachChild node %) brick*)
158 (for [y (range 10)
159 x (range 4)
160 z (range 1)]
161 (Vector3f.
162 (+ (* 2 x brick-length)
163 (if (even? (+ y z))
164 (/ brick-length 4) (/ brick-length -4)))
165 (+ (* brick-height (inc (* 2 y))))
166 (* 2 z brick-width) ))))
167 (.setShadowMode node RenderQueue$ShadowMode/CastAndReceive)
168 node))
169
170 (import com.aurellem.capture.Capture)
171
172 (import java.io.File)
173
174
175 (defn brick-wall-game-run [record?]
176 (doto
177 (world
178 (doto (Node.) (.attachChild (floor*))
179 (.attachChild (brick-wall*))
180 )
181 {"key-f" (fn [game value]
182 (if (not value) (add-element game (brick-wall*))))
183 "key-space" (fire-cannon-ball )}
184 (fn [world]
185 (position-camera world
186 (Vector3f. 1.382548, 4.0383573, 5.994235)
187 (Quaternion. 0.0013082094, 0.98581666, -0.1676442, 0.0076932586))
188
189 ;;(speed-up world)
190
191 (if record?
192 (Capture/captureVideo
193 world
194 (File.
195 "/home/r/proj/cortex/render/gabor-1/main")))
196 (add-camera! world (.getCamera world) no-op))
197 (fn [& _]))
198 (.start)))
199
200 (defn convolve-practice [kernel]
201 (let [input "/home/r/proj/cortex/render/gabor-1/main/0000032.png"
98 202
99 203
100 output "/home/r/ppp.png" 204 output "/home/r/ppp.png"
101 205
102 i (org.opencv.highgui.Highgui/imread input) 206 i (org.opencv.highgui.Highgui/imread input)
112 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat) 216 (org.opencv.highgui.Highgui/imwrite "/home/r/ppp.png" new-mat)
113 217
114 (view (ImagePlus. input)) 218 (view (ImagePlus. input))
115 (view (ImagePlus. output)))) 219 (view (ImagePlus. output))))
116 220
221
222
223 (defn generate-gabor-images []
224 (gabor-kernel 2.8 1 0 3.5 0)
225
226
227
228
117 #+end_src 229 #+end_src
118 230
119 231
120 232
121 * COMMENT Generate Source 233 * COMMENT Generate Source