diff org/sense.org @ 200:7eb966144dad

finished video for sense.org, now with subtitles!
author Robert McIntyre <rlm@mit.edu>
date Mon, 06 Feb 2012 08:26:20 -0700
parents 305439cec54d
children 1c915cc1118b
line wrap: on
line diff
     1.1 --- a/org/sense.org	Mon Feb 06 01:40:22 2012 -0700
     1.2 +++ b/org/sense.org	Mon Feb 06 08:26:20 2012 -0700
     1.3 @@ -219,38 +219,16 @@
     1.4  * Viewing Sense Data
     1.5  
     1.6  It's vital to /see/ the sense data to make sure that everything is
     1.7 -behaving as it should. =(view-sense)= is here so that each sense can
     1.8 -define its own way of turning sense-data into pictures, while the
     1.9 -actual rendering of said pictures stays in one central place.
    1.10 -=(points->image)= helps senses generate a base image onto which they
    1.11 -can overlay actual sense data.
    1.12 +behaving as it should. =(view-sense)= and its helper, =(view-image)=
    1.13 +are here so that each sense can define its own way of turning
    1.14 +sense-data into pictures, while the actual rendering of said pictures
    1.15 +stays in one central place.  =(points->image)= helps senses generate a
    1.16 +base image onto which they can overlay actual sense data.
    1.17  
    1.18  #+name: view-senses
    1.19  #+begin_src clojure
    1.20  (in-ns 'cortex.sense)
    1.21  
    1.22 -(defn points->image
    1.23 -  "Take a collection of points and visuliaze it as a BufferedImage."
    1.24 -  [points]
    1.25 -  (if (empty? points)
    1.26 -    (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY)
    1.27 -    (let [xs (vec (map first points))
    1.28 -          ys (vec (map second points))
    1.29 -          x0 (apply min xs)
    1.30 -          y0 (apply min ys)
    1.31 -          width (- (apply max xs) x0)
    1.32 -          height (- (apply max ys) y0)
    1.33 -          image (BufferedImage. (inc width) (inc height)
    1.34 -                                BufferedImage/TYPE_INT_RGB)]
    1.35 -      (dorun
    1.36 -       (for [x (range (.getWidth image))
    1.37 -             y (range (.getHeight image))]
    1.38 -         (.setRGB image x y 0xFF0000)))
    1.39 -      (dorun 
    1.40 -       (for [index (range (count points))]
    1.41 -         (.setRGB image (- (xs index) x0) (- (ys index) y0) -1)))
    1.42 -      image)))
    1.43 -
    1.44  (defn view-image
    1.45    "Initailizes a JPanel on which you may draw a BufferedImage.
    1.46     Returns a function that accepts a BufferedImage and draws it to the
    1.47 @@ -303,6 +281,28 @@
    1.48            (display (sense-display-kernel datum)))
    1.49          @windows data)))))
    1.50  
    1.51 +(defn points->image
    1.52 +  "Take a collection of points and visuliaze it as a BufferedImage."
    1.53 +  [points]
    1.54 +  (if (empty? points)
    1.55 +    (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY)
    1.56 +    (let [xs (vec (map first points))
    1.57 +          ys (vec (map second points))
    1.58 +          x0 (apply min xs)
    1.59 +          y0 (apply min ys)
    1.60 +          width (- (apply max xs) x0)
    1.61 +          height (- (apply max ys) y0)
    1.62 +          image (BufferedImage. (inc width) (inc height)
    1.63 +                                BufferedImage/TYPE_INT_RGB)]
    1.64 +      (dorun
    1.65 +       (for [x (range (.getWidth image))
    1.66 +             y (range (.getHeight image))]
    1.67 +         (.setRGB image x y 0xFF0000)))
    1.68 +      (dorun 
    1.69 +       (for [index (range (count points))]
    1.70 +         (.setRGB image (- (xs index) x0) (- (ys index) y0) -1)))
    1.71 +      image)))
    1.72 +
    1.73  (defn gray
    1.74    "Create a gray RGB pixel with R, G, and B set to num. num must be
    1.75     between 0 and 255."
    1.76 @@ -378,6 +378,8 @@
    1.77    (.localToWorld object local-coordinate nil))
    1.78  #+end_src
    1.79  
    1.80 +** Sense Binding
    1.81 +
    1.82  =(bind-sense)= binds either a Camera or a Listener object to any
    1.83  object so that they will follow that object no matter how it
    1.84  moves. It is used to create both eyes and ears.
    1.85 @@ -410,8 +412,8 @@
    1.86         (controlRender [_ _])))))
    1.87  #+end_src
    1.88  
    1.89 -Here is some example code which shows a camera bound to a blue
    1.90 -box as it is buffeted by white cannonballs.
    1.91 +Here is some example code which shows how a camera bound to a blue box
    1.92 +with =(bind-sense)= moves as the box is buffeted by white cannonballs.
    1.93  
    1.94  #+name: test
    1.95  #+begin_src clojure 
    1.96 @@ -454,8 +456,6 @@
    1.97       no-op)))
    1.98  #+end_src
    1.99  
   1.100 -** Demo Video
   1.101 -
   1.102  #+begin_html
   1.103  <video controls="controls" width="755">
   1.104    <source src="../video/bind-sense.ogg" type="video/ogg"
   1.105 @@ -464,14 +464,17 @@
   1.106  
   1.107  #+end_html
   1.108  
   1.109 -note to self: the video was created with the following commands:
   1.110 +With this, eyes are easy --- you just bind the camera closer to the
   1.111 +desired object, and set it to look outward instead of inward as it
   1.112 +does in the video.
   1.113  
   1.114 +(nb : the video was created with the following commands)
   1.115  
   1.116 +*** Combine Frames with ImageMagick
   1.117  #+begin_src clojure :results silent
   1.118  (in-ns 'user)
   1.119  (import java.io.File)
   1.120  (use 'clojure.contrib.shell-out)
   1.121 -
   1.122  (let
   1.123      [idx (atom -1)
   1.124       left (rest 
   1.125 @@ -479,27 +482,32 @@
   1.126             (file-seq (File. "/home/r/proj/cortex/render/bind-sense0/"))))
   1.127       right (rest
   1.128              (sort
   1.129 -             (file-seq (File. "/home/r/proj/cortex/render/bind-sense1/"))))]
   1.130 +             (file-seq
   1.131 +              (File. "/home/r/proj/cortex/render/bind-sense1/"))))
   1.132 +     sub (rest
   1.133 +          (sort
   1.134 +           (file-seq
   1.135 +            (File. "/home/r/proj/cortex/render/bind-senseB/"))))
   1.136 +     sub* (concat sub (repeat 1000 (last sub)))]
   1.137    (dorun
   1.138     (map  
   1.139 -    (fn [im-1 im-2]
   1.140 -      (println idx)
   1.141 +    (fn [im-1 im-2 sub]
   1.142        (sh "convert" (.getCanonicalPath im-1)
   1.143            (.getCanonicalPath im-2) "+append"
   1.144 +          (.getCanonicalPath sub) "-append"
   1.145            (.getCanonicalPath
   1.146             (File. "/home/r/proj/cortex/render/bind-sense/"
   1.147                    (format "%07d.png" (swap! idx inc))))))
   1.148 -    left right)))
   1.149 +    left right sub*)))
   1.150  #+end_src
   1.151  
   1.152 +*** Encode Frames with ffmpeg
   1.153 +
   1.154  #+begin_src sh :results silent
   1.155  cd /home/r/proj/cortex/render/
   1.156 -cp ../images/aurellem-1280x480.png bind-sense/0000000.png             
   1.157  ffmpeg -r 60 -b 9000k -i bind-sense/%07d.png bind-sense.ogg
   1.158  #+end_src
   1.159  
   1.160 -
   1.161 -
   1.162  * Bookkeeping
   1.163  Here is the header for this namespace, included for completness.
   1.164  #+name: header
   1.165 @@ -520,7 +528,6 @@
   1.166    (:import javax.imageio.ImageIO)
   1.167    (:import java.io.File)
   1.168    (:import (javax.swing JPanel JFrame SwingUtilities)))
   1.169 -
   1.170  #+end_src
   1.171  
   1.172  * Source Listing