changeset 169:94b79c191fc7

renamed some functions in vision.org
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 04:23:32 -0700
parents 1c8e9d389ea4
children 1a00b4918529
files org/hearing.org org/test-creature.org org/vision.org
diffstat 3 files changed, 28 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/hearing.org	Sat Feb 04 04:08:08 2012 -0700
     1.2 +++ b/org/hearing.org	Sat Feb 04 04:23:32 2012 -0700
     1.3 @@ -809,7 +809,7 @@
     1.4             (reset! old-position new-position)))
     1.5         (controlRender [_ _])))))
     1.6  
     1.7 -(defn create-listener!  
     1.8 +(defn add-ear!  
     1.9    "Create a Listener centered on the current position of 'ear 
    1.10     which follows the closest physical node in 'creature and 
    1.11     sends sound data to 'continuation."
    1.12 @@ -833,7 +833,7 @@
    1.13          register-listener!
    1.14          (runonce 
    1.15           (fn [#^Application world]
    1.16 -           (create-listener!
    1.17 +           (add-ear!
    1.18              world creature ear
    1.19              (fn [data]
    1.20                (reset! hearing-data (vec data))))))]
     2.1 --- a/org/test-creature.org	Sat Feb 04 04:08:08 2012 -0700
     2.2 +++ b/org/test-creature.org	Sat Feb 04 04:23:32 2012 -0700
     2.3 @@ -233,11 +233,11 @@
     2.4            (dorun (map #(% world) init-vision-fns))
     2.5            ;;(dorun (map #(% world) init-hearing-fns))
     2.6            
     2.7 -          (add-eye! world
     2.8 -                   (attach-eye creature (test-eye))
     2.9 +          (add-camera! world
    2.10 +                   (add-eye! creature (test-eye))
    2.11                     (comp (view-image) BufferedImage!))
    2.12            
    2.13 -          (add-eye! world (.getCamera world) no-op)
    2.14 +          (add-camera! world (.getCamera world) no-op)
    2.15            ;;(set-gravity world (Vector3f. 0 0 0))
    2.16            ;;(com.aurellem.capture.Capture/captureVideo
    2.17            ;; world (file-str "/home/r/proj/ai-videos/hand"))
    2.18 @@ -308,8 +308,8 @@
    2.19                   (bind-sense rock cam)
    2.20                   
    2.21                   (.setTimer world (RatchetTimer. 60))
    2.22 -                 (add-eye! world cam (comp (view-image) BufferedImage!))
    2.23 -                 (add-eye! world (.getCamera world) no-op))
    2.24 +                 (add-camera! world cam (comp (view-image) BufferedImage!))
    2.25 +                 (add-camera! world (.getCamera world) no-op))
    2.26                 )
    2.27               (fn [_ _] (println-repl rot)))))
    2.28         
     3.1 --- a/org/vision.org	Sat Feb 04 04:08:08 2012 -0700
     3.2 +++ b/org/vision.org	Sat Feb 04 04:23:32 2012 -0700
     3.3 @@ -120,8 +120,8 @@
     3.4    (byteBuffer->bufferedImage!
     3.5     (frameBuffer->byteBuffer! r fb bb) bi))
     3.6  
     3.7 -(defn add-eye!
     3.8 -  "Add an eye to the world, calling continuation on every frame
     3.9 +(defn add-camera!
    3.10 +  "Add a camera to the world, calling continuation on every frame
    3.11    produced." 
    3.12    [#^Application world camera continuation]
    3.13    (let [width (.getWidth camera)
    3.14 @@ -134,12 +134,12 @@
    3.15        (.addProcessor (vision-pipeline continuation))
    3.16        (.attachScene (.getRootNode world)))))
    3.17  
    3.18 -(defn retina-sensor-image
    3.19 +(defn retina-sensor-profile
    3.20    "Return a map of pixel selection functions to BufferedImages
    3.21 -   describing the distribution of light-sensitive components on this
    3.22 -   geometry's surface. Each function creates an integer from the rgb
    3.23 -   values found in the pixel. :red, :green, :blue, :gray are already
    3.24 -   defined as extracting the red green blue and average components
    3.25 +   describing the distribution of light-sensitive components of this
    3.26 +   eye. Each function creates an integer from the rgb values found in
    3.27 +   the pixel. :red, :green, :blue, :gray are already defined as
    3.28 +   extracting the red, green, blue, and average components
    3.29     respectively."
    3.30     [#^Spatial eye]
    3.31     (if-let [eye-map (meta-data eye "eye")]
    3.32 @@ -148,11 +148,11 @@
    3.33        (eval (read-string eye-map)))))
    3.34  
    3.35  (defn eye-dimensions
    3.36 -  "returns the width and height specified in the metadata of the eye"
    3.37 +  "Returns [width, height] specified in the metadata of the eye"
    3.38    [#^Spatial eye]
    3.39    (let [dimensions
    3.40            (map #(vector (.getWidth %) (.getHeight %))
    3.41 -               (vals (retina-sensor-image eye)))]
    3.42 +               (vals (retina-sensor-profile eye)))]
    3.43      [(apply max (map first dimensions))
    3.44       (apply max (map second dimensions))]))
    3.45  
    3.46 @@ -162,8 +162,10 @@
    3.47    (sense-nodes "eyes")
    3.48    "Return the children of the creature's \"eyes\" node.")
    3.49  
    3.50 -(defn attach-eye
    3.51 -  "Attach a Camera to the appropiate area and return the Camera."
    3.52 +(defn add-eye!
    3.53 +  "Create a Camera centered on the current position of 'eye which
    3.54 +   follows the closest physical node in 'creature and sends visual
    3.55 +   data to 'continuation."
    3.56    [#^Node creature #^Spatial eye]
    3.57    (let [target (closest-node creature eye)
    3.58          [cam-width cam-height] (eye-dimensions eye)
    3.59 @@ -182,18 +184,18 @@
    3.60     :blue   0x0000FF
    3.61     :green  0x00FF00})
    3.62  
    3.63 -(defn enable-vision
    3.64 +(defn vision-fn
    3.65    "return [init-function sensor-functions] for a particular eye"
    3.66    [#^Node creature #^Spatial eye & {skip :skip :or {skip 0}}]
    3.67 -  (let [retinal-map (retina-sensor-image eye)
    3.68 -        camera (attach-eye creature eye)
    3.69 +  (let [retinal-map (retina-sensor-profile eye)
    3.70 +        camera (add-eye! creature eye)
    3.71          vision-image
    3.72          (atom
    3.73           (BufferedImage. (.getWidth camera)
    3.74                           (.getHeight camera)
    3.75                           BufferedImage/TYPE_BYTE_BINARY))]
    3.76      [(fn [world]
    3.77 -       (add-eye!
    3.78 +       (add-camera!
    3.79          world camera
    3.80          (let [counter  (atom 0)]
    3.81            (fn [r fb bb bi]
    3.82 @@ -223,7 +225,7 @@
    3.83        (into senses-a senses-b)])
    3.84     [[][]]      
    3.85     (for [eye (eyes creature)]
    3.86 -     (enable-vision creature eye))))
    3.87 +     (vision-fn creature eye))))
    3.88  
    3.89  
    3.90  #+end_src
    3.91 @@ -270,11 +272,11 @@
    3.92         (let [cam (.clone (.getCamera world))
    3.93               width (.getWidth cam)
    3.94               height (.getHeight cam)]
    3.95 -         (add-eye! world cam 
    3.96 +         (add-camera! world cam 
    3.97                    ;;no-op
    3.98                    (comp (view-image) BufferedImage!)
    3.99                    )
   3.100 -         (add-eye! world
   3.101 +         (add-camera! world
   3.102                    (doto (.clone cam)
   3.103                      (.setLocation (Vector3f. -10 0 0))
   3.104                      (.lookAt Vector3f/ZERO Vector3f/UNIT_Y))
   3.105 @@ -282,7 +284,7 @@
   3.106                    (comp (view-image) BufferedImage!))
   3.107           ;; This is here to restore the main view
   3.108           ;; after the other views have completed processing
   3.109 -         (add-eye! world (.getCamera world) no-op)))
   3.110 +         (add-camera! world (.getCamera world) no-op)))
   3.111       (fn [world tpf]
   3.112         (.rotate candy (* tpf 0.2) 0 0)))))
   3.113  #+end_src