Mercurial > cortex
diff org/integration.org @ 300:c78917fb0615
created first version of the video which demonstrates all the senses
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 17 Feb 2012 11:06:27 -0700 |
parents | 47fe4f7b74b3 |
children | 4203c2140b95 |
line wrap: on
line diff
1.1 --- a/org/integration.org Thu Feb 16 21:14:28 2012 -0700 1.2 +++ b/org/integration.org Fri Feb 17 11:06:27 2012 -0700 1.3 @@ -12,9 +12,22 @@ 1.4 made so far. The blender file for the creature serves as an example of 1.5 a fully equipped creature in terms of senses. You can find it [[../assets/Models/test-creature/hand.blend][here]]. 1.6 1.7 + 1.8 +#+begin_html 1.9 +<div class="figure"> 1.10 +<video controls="controls" width="755"> 1.11 + <source src="../video/hand.ogg" type="video/ogg" 1.12 + preload="none" poster="../images/aurellem-1280x480.png" /> 1.13 +</video> 1.14 +<p>Simulated Senses in a Virtual Environment</p> 1.15 +</div> 1.16 +#+end_html 1.17 + 1.18 + 1.19 + 1.20 #+name: integration 1.21 #+begin_src clojure 1.22 -(ns cortex.integration 1.23 +(ns cortex.test.integration 1.24 "let's play!" 1.25 {:author "Robert McIntyre"} 1.26 (:use (cortex world util body sense 1.27 @@ -30,20 +43,14 @@ 1.28 (def hand "Models/test-creature/hand.blend") 1.29 1.30 (def output-base (File. "/home/r/proj/cortex/render/hand")) 1.31 +#+end_src 1.32 1.33 +For this demonstration I have to manually drive the muscles of the 1.34 +hand. I do this by creating a little mini-language to describe 1.35 +simulated muscle contraction. 1.36 1.37 -;; Let the hand fall palm-up 1.38 - 1.39 -;; it curls its phalanges, starting with the pinky. 1.40 - 1.41 -;; it lets these fall back down? 1.42 - 1.43 -;; block falls down onto the hand, accompanied by a sound. The block 1.44 -;; can be seen by the hand's eye. 1.45 - 1.46 -;; hand FORCEFULLY catapults the block so that it hits the camera. 1.47 - 1.48 - 1.49 +#+name: integration-2 1.50 +#+begin_src clojure 1.51 (defn motor-control-program 1.52 "Create a function which will execute the motor script" 1.53 [muscle-positions 1.54 @@ -94,8 +101,24 @@ 1.55 :pinky-1-e]) 1.56 1.57 (def full 9001) 1.58 + 1.59 + 1.60 +;; Coreography: 1.61 + 1.62 +;; Let the hand fall palm-up 1.63 + 1.64 +;; it curls its phalanges, starting with the pinky. 1.65 + 1.66 +;; it lets its phalanges fall back down. 1.67 + 1.68 +;; block falls down onto the hand, accompanied by a sound. The block 1.69 +;; can be seen by the hand's eye. 1.70 + 1.71 +;; hand FORCEFULLY catapults the block so that it hits the camera. 1.72 + 1.73 + 1.74 ;; the systax here is [keyframe body-part force] 1.75 -(def wiggle-each-finger-tip 1.76 +(def move-fingers 1.77 [[300 :pinky-3-f 50] 1.78 [320 :pinky-2-f 80] 1.79 [340 :pinky-1-f 100] 1.80 @@ -197,41 +220,6 @@ 1.81 (println-repl (.getWorldTranslation brick))) 1.82 (controlRender [_ _])))) 1.83 (add-element world brick)))))) 1.84 - 1.85 - 1.86 -(def control-list 1.87 - [ 1.88 - 0 ;;pointer-21 #<Vector3f (0.99999994, 0.0, 0.0)> 1.89 - 0 ;;pointer-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.90 - 0 ;;thumb-11 #<Vector3f (-0.8802276, -0.39781287, -0.25873658)> 1.91 - 0 ;;thumb-11 #<Vector3f (0.8485723, 0.46149826, 0.2587364)> 1.92 - 0 ;;pointer-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.93 - 0 ;;pointer-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.94 - 0 ;;thumb-2.0011 #<Vector3f (-0.71705645, -0.44753736, -0.5343599)> 1.95 - 0 ;;thumb-2.0011 #<Vector3f (-0.10567085, 0.83862597, 0.53435963)> 1.96 - 0 ;;middle-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.97 - 0 ;;middle-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.98 - 0 ;;pointer-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.99 - 0 ;;pointer-31 #<Vector3f (0.99999994, 0.0, 0.0)> 1.100 - 0 ;;middle-21 #<Vector3f (0.99999994, 0.0, 0.0)> 1.101 - 0 ;;middle-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.102 - 0 ;;middle-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.103 - 0 ;;middle-31 #<Vector3f (0.99999994, 0.0, 0.0)> 1.104 - 0 ;;pinky-21 #<Vector3f (0.99999994, 0.0, 0.0)> 1.105 - 0 ;;pinky-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.106 - 0 ;;pinky-31 #<Vector3f (-1, 0.0, 0.0)> 1.107 - 0 ;;pinky-31 #<Vector3f (1.0, 0.0, 0.0)> 1.108 - 0 ;;ring-31 #<Vector3f (0.99999994, 0.0, 0.0)> 1.109 - 0 ;;ring-31 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.110 - 0 ;;ring-21 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.111 - 0 ;;ring-21 #<Vector3f (0.99999994, 0.0, 0.0)> 1.112 - 0 ;;ring-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.113 - 0 ;;ring-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.114 - 0 ;;thumb-11 #<Vector3f (-0.43154645, 0.7302033, 0.5296894)> 1.115 - 0 ;;thumb-11 #<Vector3f (-0.8032993, -0.2722854, -0.5296895)> 1.116 - 0 ;;pinky-11 #<Vector3f (-0.99999994, 0.0, 0.0)> 1.117 - 0 ;;pinky-11 #<Vector3f (0.99999994, 0.0, 0.0)> 1.118 - ]) 1.119 1.120 (import com.aurellem.capture.Capture) 1.121 1.122 @@ -261,7 +249,7 @@ 1.123 prop-display (view-proprioception) 1.124 1.125 control-script (motor-control-program 1.126 - muscle-positions wiggle-each-finger-tip) 1.127 + muscle-positions move-fingers) 1.128 muscles (movement! creature) 1.129 muscle-display (view-movement) 1.130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1.131 @@ -315,7 +303,18 @@ 1.132 1.133 (.setLocalTranslation me (.getLocation (.getCamera world))) 1.134 (fix-display world)))))) 1.135 +#+end_src 1.136 1.137 +* Generating the Video 1.138 + 1.139 +Just a bunch of calls to imagemagick to arrange the data that 1.140 +=test-everything!= produces. 1.141 + 1.142 +#+name: magick-8 1.143 +#+begin_src clojure 1.144 +(ns cortex.video.magick8 1.145 + (:import java.io.File) 1.146 + (:use clojure.contrib.shell-out)) 1.147 1.148 (comment 1.149 ;; list of touch targets 1.150 @@ -426,7 +425,6 @@ 1.151 (map (comp file-names #(File. base %)) 1.152 paths))) 1.153 1.154 - 1.155 (defn pinky [] 1.156 (file-groups 1.157 "muscle/18" 1.158 @@ -468,13 +466,13 @@ 1.159 "touch/2" 1.160 "proprio/1" 1.161 1.162 + "muscle/13" 1.163 "muscle/12" 1.164 - "muscle/13" 1.165 "touch/1" 1.166 "proprio/0" 1.167 1.168 + "muscle/9" 1.169 "muscle/8" 1.170 - "muscle/9" 1.171 "touch/0" 1.172 "proprio/9")) 1.173 1.174 @@ -603,11 +601,11 @@ 1.175 (defn main [] 1.176 (file-names (File. base "main"))) 1.177 1.178 -(defn targets [] 1.179 +(defn targets [dest max] 1.180 (map 1.181 (comp #(.getCanonicalPath %) 1.182 - #(File. (str base "/out/" (format "%07d.png" %)))) 1.183 - (range 0 (count (main))))) 1.184 + #(File. (str base dest (format "%07d.png" %)))) 1.185 + (range max))) 1.186 1.187 1.188 (defn final-image [main [all red green blue] hearing 1.189 @@ -633,7 +631,7 @@ 1.190 1.191 target]))) 1.192 1.193 -(defn convert-files [] 1.194 +(defn combine-files [] 1.195 (dorun 1.196 (pmap final-image 1.197 (main) 1.198 @@ -644,20 +642,61 @@ 1.199 (middle) 1.200 (pointer) 1.201 (thumb) 1.202 - (targets)))) 1.203 + (targets "/out/" (count (main)))))) 1.204 + 1.205 +(defn subtitles [] 1.206 + (file-names (File. base "subs"))) 1.207 + 1.208 +(defn outs [] 1.209 + (file-names (File. base "out"))) 1.210 + 1.211 + 1.212 +(defn mix-subtitles [] 1.213 + (let [subs (subtitles) 1.214 + targets (targets "/out-subs/" (count subs)) 1.215 + overlay (.getCanonicalPath (File. base "output.png"))] 1.216 + (dorun 1.217 + (pmap 1.218 + (fn [sub target] 1.219 + (sh 1.220 + "convert" 1.221 + overlay 1.222 + sub "-geometry" "+0+0" "-composite" 1.223 + target)) 1.224 + subs targets)))) 1.225 + 1.226 +(defn out-subtitles [] 1.227 + (file-names (File. base "out-subs"))) 1.228 + 1.229 + 1.230 +(defn insert-subtitles [] 1.231 + (let [subtitles (out-subtitles) 1.232 + outs (outs) 1.233 + targets (targets 1.234 + "/final/" 1.235 + (+ (count outs) (count subtitles)))] 1.236 + (dorun 1.237 + (pmap 1.238 + #(sh "cp" %1 %2) 1.239 + (concat subtitles outs) targets)))) 1.240 + 1.241 +(defn generate-final [] 1.242 + (combine-files) 1.243 + (mix-subtitles) 1.244 + (insert-subtitles)) 1.245 #+end_src 1.246 1.247 - 1.248 -#+begin_src sh 1.249 +#+begin_src sh :results silent 1.250 cd /home/r/proj/cortex/render/hand 1.251 1.252 -ffmpeg -r 60 -i out/%07d.png -i main.wav -b:a 128k \ 1.253 +sox --ignore-length main.wav main-delayed.wav delay 24 1.254 + 1.255 +mogrify -resize 755x final/* 1.256 + 1.257 +ffmpeg -r 60 -i final/%07d.png -i main-delayed.wav -b:a 128k \ 1.258 -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg 1.259 #+end_src 1.260 1.261 -#+results: integration 1.262 -: #'cortex.integration/convert-files 1.263 - 1.264 * COMMENT purgatory 1.265 #+begin_src clojure 1.266 (defn bullet-trans* [] 1.267 @@ -820,8 +859,13 @@ 1.268 1.269 1.270 * COMMENT generate source 1.271 -#+begin_src clojure :tangle ../src/cortex/integration.clj 1.272 +#+begin_src clojure :tangle ../src/cortex/test/integration.clj 1.273 <<integration>> 1.274 +<<integration-2>> 1.275 +#+end_src 1.276 + 1.277 +#+begin_src clojure :tangle ../src/cortex/video/magick8.clj 1.278 +<<magick-8>> 1.279 #+end_src 1.280 1.281