diff org/integration.org @ 299:47fe4f7b74b3

rendering video for the first time!
author Robert McIntyre <rlm@mit.edu>
date Thu, 16 Feb 2012 21:14:28 -0700
parents 85f3ff3e3f26
children c78917fb0615
line wrap: on
line diff
     1.1 --- a/org/integration.org	Thu Feb 16 20:05:54 2012 -0700
     1.2 +++ b/org/integration.org	Thu Feb 16 21:14:28 2012 -0700
     1.3 @@ -391,74 +391,8 @@
     1.4  29 :pinky-1-e
     1.5  )
     1.6  
     1.7 -
     1.8 -
     1.9 -;; rotate touch 180
    1.10 -
    1.11 -;; rotate mucles 90 counter-clockwise
    1.12 -;; scale muscles to 15x60
    1.13 -
    1.14 -finger width : 113
    1.15 -finger height : 357
    1.16 -
    1.17 -thumb width : 113
    1.18 -
    1.19 -pinky  --- 0,195
    1.20 -ring   --- 111,100
    1.21 -middle --- 228,0
    1.22 -pointer -- 436,96
    1.23 -thumb ---  486,420
    1.24 -
    1.25 -
    1.26 -
    1.27 -within a finger (coordinates of top left corner (x,y)):
    1.28 -
    1.29 -tip-flexor     : 0,7
    1.30 -tip-extensor   : 98,7
    1.31 -tip            : 18,0
    1.32 -
    1.33 -joint-2-3      : 32,79
    1.34 -
    1.35 -mid-flexor     : 19,131
    1.36 -mid-extensor   : 80,131
    1.37 -mid            : 30,133
    1.38 -
    1.39 -joint-1-2      : 32,193
    1.40 -
    1.41 -base-flexor    : 19,245
    1.42 -base-extensor  : 80,245
    1.43 -base           : 39,247
    1.44 -
    1.45 -joint-palm-1   : 32,307
    1.46 -
    1.47 -
    1.48 -Thumb is the same as finger, except it has two more pieces
    1.49 -
    1.50 -extra-flexor-1 : 2,131
    1.51 -extra-flexor-2 : 100,131
    1.52 -
    1.53 -;; rotate entire thumb 45 degrees clockwise
    1.54 -
    1.55 -within vision
    1.56 -gray -- 165,577
    1.57 -green -- 278,577
    1.58 -blue  -- 165,682
    1.59 -red   -- 278,682
    1.60 -
    1.61 -entire hand          : 809, 22
    1.62 -main view            :  78,202
    1.63 -hearing              : 784,819
    1.64 -
    1.65 -hand-size: 688x769
    1.66 -
    1.67 -
    1.68 -total image size:
    1.69 -1600x894
    1.70 -
    1.71  (def base (File. "/home/r/proj/cortex/render/hand"))
    1.72  
    1.73 -
    1.74 -
    1.75  (defn prepare-muscle [muscle]
    1.76    ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
    1.77  
    1.78 @@ -484,6 +418,97 @@
    1.79     joint-1-2                     "-geometry" "+32+193" "-composite"
    1.80     ")"])
    1.81  
    1.82 +(defn file-names [#^File dir]
    1.83 +   (map #(.getCanonicalPath %) (next (sort (file-seq dir)))))
    1.84 +
    1.85 +(defn file-groups [& paths]
    1.86 +  (apply (partial map list )
    1.87 +         (map (comp file-names #(File. base %))
    1.88 +              paths)))
    1.89 +  
    1.90 +
    1.91 +(defn pinky []
    1.92 +  (file-groups
    1.93 +   "muscle/18"
    1.94 +   "muscle/19"
    1.95 +   "touch/5"
    1.96 +   "proprio/7"
    1.97 +   
    1.98 +   "muscle/17"
    1.99 +   "muscle/16"
   1.100 +   "touch/4"
   1.101 +   "proprio/8"
   1.102 +   
   1.103 +   "muscle/28"
   1.104 +   "muscle/29"
   1.105 +   "touch/3"
   1.106 +   "proprio/10"))
   1.107 +
   1.108 +(defn ring []
   1.109 +  (file-groups
   1.110 +   "muscle/21"
   1.111 +   "muscle/20"
   1.112 +   "touch/11"
   1.113 +   "proprio/5"
   1.114 +
   1.115 +   "muscle/22"
   1.116 +   "muscle/23"
   1.117 +   "touch/10"
   1.118 +   "proprio/6"
   1.119 +
   1.120 +   "muscle/25"
   1.121 +   "muscle/24"
   1.122 +   "touch/9"
   1.123 +   "proprio/12"))
   1.124 +
   1.125 +(defn middle []
   1.126 +  (file-groups
   1.127 +   "muscle/14"
   1.128 +   "muscle/15"
   1.129 +   "touch/2"
   1.130 +   "proprio/1"
   1.131 +
   1.132 +   "muscle/12"
   1.133 +   "muscle/13"
   1.134 +   "touch/1"
   1.135 +   "proprio/0"
   1.136 +
   1.137 +   "muscle/8"
   1.138 +   "muscle/9"
   1.139 +   "touch/0"
   1.140 +   "proprio/9"))
   1.141 +
   1.142 +(defn pointer []
   1.143 +  (file-groups
   1.144 +   "muscle/10"
   1.145 +   "muscle/11"
   1.146 +   "touch/8"
   1.147 +   "proprio/4"
   1.148 +
   1.149 +   "muscle/1"
   1.150 +   "muscle/0"
   1.151 +   "touch/7"
   1.152 +   "proprio/3"
   1.153 +
   1.154 +   "muscle/5"
   1.155 +   "muscle/4"
   1.156 +   "touch/6"
   1.157 +   "proprio/11"))
   1.158 +
   1.159 +(defn thumb []
   1.160 +  (file-groups
   1.161 +   "muscle/7"
   1.162 +   "muscle/6"
   1.163 +   "touch/13"
   1.164 +   "proprio/2"
   1.165 +
   1.166 +   "muscle/27"
   1.167 +   "muscle/26"
   1.168 +   "muscle/3"
   1.169 +   "muscle/2"
   1.170 +   "touch/12"
   1.171 +   "proprio/13"))
   1.172 +
   1.173  (defn generate-finger
   1.174    [tip-flexor tip-extensor tip
   1.175     joint-2-3
   1.176 @@ -520,13 +545,6 @@
   1.177     (prepare-muscle mid-extensor-2)  "-geometry" "+100+131" "-composite"
   1.178     ")"])
   1.179  
   1.180 -pinky  --- 0,195
   1.181 -ring   --- 111,100
   1.182 -middle --- 228,0
   1.183 -pointer -- 436,96
   1.184 -thumb ---  486,420
   1.185 -
   1.186 -
   1.187  (defn generate-hand
   1.188    [pinky-pieces
   1.189     ring-pieces
   1.190 @@ -558,8 +576,6 @@
   1.191     red    "-geometry" "+113+105" "-composite"
   1.192     ")"])
   1.193    
   1.194 -
   1.195 -
   1.196  (def test-muscle (File. base "muscle/0/0000000.png"))
   1.197  (def test-proprio (File. base "proprio/0/0000000.png"))
   1.198  (def test-tip (File. base "touch/2/0000000.png"))
   1.199 @@ -568,41 +584,45 @@
   1.200  (def test-hearing (File. base "hearing/0/0000000.png"))
   1.201  (def test-main (File. base "main/0000000.png"))
   1.202  
   1.203 -
   1.204  (def test-target (File. base "output.png"))
   1.205  
   1.206  (def background (File. base "background.png"))
   1.207  
   1.208  (use 'clojure.contrib.shell-out)
   1.209 -(defn final-image [muscle proprio tip mid vision hearing main]
   1.210 -  (let [[muscle proprio tip mid vision hearing main] (map #(.getCanonicalPath %)
   1.211 -                                      [muscle proprio tip mid vision
   1.212 -                                       hearing main])
   1.213 -        finger-pieces [muscle muscle tip
   1.214 -                       proprio
   1.215 -                       muscle muscle mid
   1.216 -                       proprio
   1.217 -                       muscle muscle mid
   1.218 -                       proprio]
   1.219 -        thumb-pieces  [muscle muscle tip
   1.220 -                       proprio
   1.221 -                       muscle muscle muscle muscle mid
   1.222 -                       proprio]]
   1.223 -    
   1.224 -    
   1.225 -    (apply
   1.226 +
   1.227 +(defn vision []
   1.228 +  (file-groups
   1.229 +   "vision/0"
   1.230 +   "vision/1"
   1.231 +   "vision/2"
   1.232 +   "vision/3"))
   1.233 +
   1.234 +(defn hearing []
   1.235 +  (file-names (File. base "hearing/0")))
   1.236 +
   1.237 +(defn main []
   1.238 +  (file-names (File. base "main")))
   1.239 +
   1.240 +(defn targets []
   1.241 +  (map
   1.242 +   (comp #(.getCanonicalPath %)
   1.243 +         #(File. (str base "/out/" (format "%07d.png" %))))
   1.244 +   (range 0 (count (main)))))
   1.245 +
   1.246 +
   1.247 +(defn final-image [main [all red green blue] hearing
   1.248 +                   pinky ring middle pointer thumb target]
   1.249 +  (println target)
   1.250 +  (apply
   1.251       sh
   1.252       (flatten
   1.253        ["convert"
   1.254         (.getCanonicalPath background)
   1.255 -       (generate-hand finger-pieces
   1.256 -                      finger-pieces
   1.257 -                      finger-pieces
   1.258 -                      finger-pieces
   1.259 -                      thumb-pieces)
   1.260 +       
   1.261 +       (generate-hand pinky ring middle pointer thumb)
   1.262         "-geometry" "+809+22" "-composite"
   1.263         
   1.264 -       (generate-vision vision vision vision vision)
   1.265 +       (generate-vision all red green blue)
   1.266         "-geometry" "+974+599" "-composite"
   1.267  
   1.268         hearing
   1.269 @@ -611,17 +631,32 @@
   1.270         main
   1.271         "-geometry" "+78+202" "-composite"
   1.272                
   1.273 -       (.getCanonicalPath test-target)]))))
   1.274 +       target])))
   1.275    
   1.276 +(defn convert-files []
   1.277 +  (dorun
   1.278 +   (pmap final-image
   1.279 +         (main)
   1.280 +         (vision)
   1.281 +         (hearing)
   1.282 +         (pinky)
   1.283 +         (ring)
   1.284 +         (middle)
   1.285 +         (pointer)
   1.286 +         (thumb)
   1.287 +         (targets))))
   1.288 +#+end_src
   1.289  
   1.290  
   1.291 -   
   1.292 +#+begin_src sh
   1.293 +cd /home/r/proj/cortex/render/hand
   1.294  
   1.295 -                       
   1.296 +ffmpeg -r 60 -i out/%07d.png -i main.wav -b:a 128k \
   1.297 +         -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg 
   1.298  #+end_src
   1.299  
   1.300  #+results: integration
   1.301 -: #'cortex.integration/test-everything!
   1.302 +: #'cortex.integration/convert-files
   1.303  
   1.304  * COMMENT purgatory
   1.305  #+begin_src clojure