Mercurial > cortex
changeset 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 |
files | .hgignore assets/Models/subtitles/subtitles.blend org/sense.org |
diffstat | 3 files changed, 49 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/.hgignore Mon Feb 06 01:40:22 2012 -0700 1.2 +++ b/.hgignore Mon Feb 06 08:26:20 2012 -0700 1.3 @@ -6,6 +6,7 @@ 1.4 capture-video.html 1.5 render* 1.6 sources* 1.7 +*.hdr 1.8 1.9 syntax: regexp 1.10 ^.*blend\d$ 1.11 \ No newline at end of file
2.1 Binary file assets/Models/subtitles/subtitles.blend has changed
3.1 --- a/org/sense.org Mon Feb 06 01:40:22 2012 -0700 3.2 +++ b/org/sense.org Mon Feb 06 08:26:20 2012 -0700 3.3 @@ -219,38 +219,16 @@ 3.4 * Viewing Sense Data 3.5 3.6 It's vital to /see/ the sense data to make sure that everything is 3.7 -behaving as it should. =(view-sense)= is here so that each sense can 3.8 -define its own way of turning sense-data into pictures, while the 3.9 -actual rendering of said pictures stays in one central place. 3.10 -=(points->image)= helps senses generate a base image onto which they 3.11 -can overlay actual sense data. 3.12 +behaving as it should. =(view-sense)= and its helper, =(view-image)= 3.13 +are here so that each sense can define its own way of turning 3.14 +sense-data into pictures, while the actual rendering of said pictures 3.15 +stays in one central place. =(points->image)= helps senses generate a 3.16 +base image onto which they can overlay actual sense data. 3.17 3.18 #+name: view-senses 3.19 #+begin_src clojure 3.20 (in-ns 'cortex.sense) 3.21 3.22 -(defn points->image 3.23 - "Take a collection of points and visuliaze it as a BufferedImage." 3.24 - [points] 3.25 - (if (empty? points) 3.26 - (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY) 3.27 - (let [xs (vec (map first points)) 3.28 - ys (vec (map second points)) 3.29 - x0 (apply min xs) 3.30 - y0 (apply min ys) 3.31 - width (- (apply max xs) x0) 3.32 - height (- (apply max ys) y0) 3.33 - image (BufferedImage. (inc width) (inc height) 3.34 - BufferedImage/TYPE_INT_RGB)] 3.35 - (dorun 3.36 - (for [x (range (.getWidth image)) 3.37 - y (range (.getHeight image))] 3.38 - (.setRGB image x y 0xFF0000))) 3.39 - (dorun 3.40 - (for [index (range (count points))] 3.41 - (.setRGB image (- (xs index) x0) (- (ys index) y0) -1))) 3.42 - image))) 3.43 - 3.44 (defn view-image 3.45 "Initailizes a JPanel on which you may draw a BufferedImage. 3.46 Returns a function that accepts a BufferedImage and draws it to the 3.47 @@ -303,6 +281,28 @@ 3.48 (display (sense-display-kernel datum))) 3.49 @windows data))))) 3.50 3.51 +(defn points->image 3.52 + "Take a collection of points and visuliaze it as a BufferedImage." 3.53 + [points] 3.54 + (if (empty? points) 3.55 + (BufferedImage. 1 1 BufferedImage/TYPE_BYTE_BINARY) 3.56 + (let [xs (vec (map first points)) 3.57 + ys (vec (map second points)) 3.58 + x0 (apply min xs) 3.59 + y0 (apply min ys) 3.60 + width (- (apply max xs) x0) 3.61 + height (- (apply max ys) y0) 3.62 + image (BufferedImage. (inc width) (inc height) 3.63 + BufferedImage/TYPE_INT_RGB)] 3.64 + (dorun 3.65 + (for [x (range (.getWidth image)) 3.66 + y (range (.getHeight image))] 3.67 + (.setRGB image x y 0xFF0000))) 3.68 + (dorun 3.69 + (for [index (range (count points))] 3.70 + (.setRGB image (- (xs index) x0) (- (ys index) y0) -1))) 3.71 + image))) 3.72 + 3.73 (defn gray 3.74 "Create a gray RGB pixel with R, G, and B set to num. num must be 3.75 between 0 and 255." 3.76 @@ -378,6 +378,8 @@ 3.77 (.localToWorld object local-coordinate nil)) 3.78 #+end_src 3.79 3.80 +** Sense Binding 3.81 + 3.82 =(bind-sense)= binds either a Camera or a Listener object to any 3.83 object so that they will follow that object no matter how it 3.84 moves. It is used to create both eyes and ears. 3.85 @@ -410,8 +412,8 @@ 3.86 (controlRender [_ _]))))) 3.87 #+end_src 3.88 3.89 -Here is some example code which shows a camera bound to a blue 3.90 -box as it is buffeted by white cannonballs. 3.91 +Here is some example code which shows how a camera bound to a blue box 3.92 +with =(bind-sense)= moves as the box is buffeted by white cannonballs. 3.93 3.94 #+name: test 3.95 #+begin_src clojure 3.96 @@ -454,8 +456,6 @@ 3.97 no-op))) 3.98 #+end_src 3.99 3.100 -** Demo Video 3.101 - 3.102 #+begin_html 3.103 <video controls="controls" width="755"> 3.104 <source src="../video/bind-sense.ogg" type="video/ogg" 3.105 @@ -464,14 +464,17 @@ 3.106 3.107 #+end_html 3.108 3.109 -note to self: the video was created with the following commands: 3.110 +With this, eyes are easy --- you just bind the camera closer to the 3.111 +desired object, and set it to look outward instead of inward as it 3.112 +does in the video. 3.113 3.114 +(nb : the video was created with the following commands) 3.115 3.116 +*** Combine Frames with ImageMagick 3.117 #+begin_src clojure :results silent 3.118 (in-ns 'user) 3.119 (import java.io.File) 3.120 (use 'clojure.contrib.shell-out) 3.121 - 3.122 (let 3.123 [idx (atom -1) 3.124 left (rest 3.125 @@ -479,27 +482,32 @@ 3.126 (file-seq (File. "/home/r/proj/cortex/render/bind-sense0/")))) 3.127 right (rest 3.128 (sort 3.129 - (file-seq (File. "/home/r/proj/cortex/render/bind-sense1/"))))] 3.130 + (file-seq 3.131 + (File. "/home/r/proj/cortex/render/bind-sense1/")))) 3.132 + sub (rest 3.133 + (sort 3.134 + (file-seq 3.135 + (File. "/home/r/proj/cortex/render/bind-senseB/")))) 3.136 + sub* (concat sub (repeat 1000 (last sub)))] 3.137 (dorun 3.138 (map 3.139 - (fn [im-1 im-2] 3.140 - (println idx) 3.141 + (fn [im-1 im-2 sub] 3.142 (sh "convert" (.getCanonicalPath im-1) 3.143 (.getCanonicalPath im-2) "+append" 3.144 + (.getCanonicalPath sub) "-append" 3.145 (.getCanonicalPath 3.146 (File. "/home/r/proj/cortex/render/bind-sense/" 3.147 (format "%07d.png" (swap! idx inc)))))) 3.148 - left right))) 3.149 + left right sub*))) 3.150 #+end_src 3.151 3.152 +*** Encode Frames with ffmpeg 3.153 + 3.154 #+begin_src sh :results silent 3.155 cd /home/r/proj/cortex/render/ 3.156 -cp ../images/aurellem-1280x480.png bind-sense/0000000.png 3.157 ffmpeg -r 60 -b 9000k -i bind-sense/%07d.png bind-sense.ogg 3.158 #+end_src 3.159 3.160 - 3.161 - 3.162 * Bookkeeping 3.163 Here is the header for this namespace, included for completness. 3.164 #+name: header 3.165 @@ -520,7 +528,6 @@ 3.166 (:import javax.imageio.ImageIO) 3.167 (:import java.io.File) 3.168 (:import (javax.swing JPanel JFrame SwingUtilities))) 3.169 - 3.170 #+end_src 3.171 3.172 * Source Listing