Mercurial > cortex
diff org/touch.org @ 250:e9bce4f722b1
added basic touch video... going to bed...
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 13 Feb 2012 08:20:25 -0700 |
parents | 95a9f6f1cb82 |
children | f1a74d23e7e4 |
line wrap: on
line diff
1.1 --- a/org/touch.org Mon Feb 13 06:06:02 2012 -0700 1.2 +++ b/org/touch.org Mon Feb 13 08:20:25 2012 -0700 1.3 @@ -483,19 +483,15 @@ 1.4 (let [image (points->image coords)] 1.5 (dorun 1.6 (for [i (range (count coords))] 1.7 - (do 1.8 - (if (= i 500) (println-repl (sensor-data i))) 1.9 - 1.10 - (comment 1.11 - (.setRGB image ((coords i) 0) ((coords i) 1) 1.12 - (apply touch->gray (sensor-data i))))))) 1.13 + (.setRGB image ((coords i) 0) ((coords i) 1) 1.14 + (apply touch->gray (sensor-data i))))) 1.15 image)))) 1.16 #+end_src 1.17 1.18 #+results: visualization 1.19 : #'cortex.touch/view-touch 1.20 1.21 -* COMMENT Basic Test of Touch 1.22 +* Basic Test of Touch 1.23 1.24 The worm's sense of touch is a bit complicated, so for this basic test 1.25 I'll use a new creature --- a simple cube which has touch sensors 1.26 @@ -534,29 +530,92 @@ 1.27 #+begin_src clojure 1.28 (in-ns 'cortex.test.touch) 1.29 1.30 +(import com.aurellem.capture.Capture) 1.31 +(import java.io.File) 1.32 + 1.33 (defn test-basic-touch 1.34 ([] (test-basic-touch false)) 1.35 ([record?] 1.36 (let [the-cube (doto (touch-cube) (body!)) 1.37 touch (touch! the-cube) 1.38 touch-display (view-touch)] 1.39 - (world (nodify [the-cube 1.40 - (box 10 1 10 :position (Vector3f. 0 -10 0) 1.41 - :color ColorRGBA/Gray :mass 0)]) 1.42 + (world 1.43 + (nodify [the-cube 1.44 + (box 10 1 10 :position (Vector3f. 0 -10 0) 1.45 + :color ColorRGBA/Gray :mass 0)]) 1.46 + 1.47 + standard-debug-controls 1.48 + 1.49 + (fn [world] 1.50 + (if record? 1.51 + (Capture/captureVideo 1.52 + world 1.53 + (File. "/home/r/proj/cortex/render/touch-cube/main-view/"))) 1.54 + (speed-up world) 1.55 + (light-up-everything world)) 1.56 + 1.57 + (fn [world tpf] 1.58 + (touch-display 1.59 + (map #(% (.getRootNode world)) touch) 1.60 + (if record? 1.61 + (File. "/home/r/proj/cortex/render/touch-cube/touch/")))))))) 1.62 +#+end_src 1.63 1.64 - standard-debug-controls 1.65 - 1.66 - (fn [world] 1.67 - (speed-up world) 1.68 - (light-up-everything world)) 1.69 +** Basic Touch Demonstration 1.70 1.71 - (fn [world tpf] 1.72 - (touch-display 1.73 - (map #(% (.getRootNode world)) touch))))))) 1.74 - 1.75 +#+begin_html 1.76 +<div class="figure"> 1.77 +<center> 1.78 +<video controls="controls" width="755"> 1.79 + <source src="../video/basic-touch.ogg" type="video/ogg" 1.80 + preload="none" poster="../images/aurellem-1280x480.png" /> 1.81 +</video> 1.82 +</center> 1.83 +<p>The simple creature responds to touch.</p> 1.84 +</div> 1.85 +#+end_html 1.86 1.87 +** Generating the Basic Touch Video 1.88 +#+begin_src clojure 1.89 +(ns cortex.video.magick4 1.90 + (:import java.io.File) 1.91 + (:use clojure.contrib.shell-out)) 1.92 + 1.93 +(defn images [path] 1.94 + (sort (rest (file-seq (File. path))))) 1.95 + 1.96 +(def base "/home/r/proj/cortex/render/touch-cube/") 1.97 + 1.98 +(defn pics [file] 1.99 + (images (str base file))) 1.100 + 1.101 +(defn combine-images [] 1.102 + (let [main-view (pics "main-view") 1.103 + touch (pics "touch/0") 1.104 + background (repeat 9001 (File. (str base "background.png"))) 1.105 + targets (map 1.106 + #(File. (str base "out/" (format "%07d.png" %))) 1.107 + (range 0 (count main-view)))] 1.108 + (dorun 1.109 + (pmap 1.110 + (comp 1.111 + (fn [[background main-view touch target]] 1.112 + (println target) 1.113 + (sh "convert" 1.114 + touch 1.115 + "-resize" "x300" 1.116 + "-rotate" "180" 1.117 + background 1.118 + "-swap" "0,1" 1.119 + "-geometry" "+776+129" 1.120 + "-composite" 1.121 + main-view "-geometry" "+66+21" "-composite" 1.122 + target)) 1.123 + (fn [& args] (map #(.getCanonicalPath %) args))) 1.124 + background main-view touch targets)))) 1.125 #+end_src 1.126 1.127 + 1.128 * Adding Touch to the Worm 1.129 1.130 #+name: test-touch