comparison org/vision.org @ 236:3c9724c8d86b

enabled optional recording in vision tests
author Robert McIntyre <rlm@mit.edu>
date Sun, 12 Feb 2012 09:57:05 -0700
parents 5f14fd7b1288
children 02b2e6f3fb43
comparison
equal deleted inserted replaced
235:be78d7bd6920 236:3c9724c8d86b
447 (gray (int (* 255 (sensor-data i))))))) 447 (gray (int (* 255 (sensor-data i)))))))
448 image)))) 448 image))))
449 #+end_src 449 #+end_src
450 450
451 * Tests 451 * Tests
452
453 ** Basic Test 452 ** Basic Test
454 453
455 This is a basic test for the vision system. It only tests the 454 This is a basic test for the vision system. It only tests the
456 vision-pipeline and does not deal with loadig eyes from a blender 455 vision-pipeline and does not deal with loadig eyes from a blender
457 file. The code creates two videos of the same rotating cube from 456 file. The code creates two videos of the same rotating cube from
556 555
557 (defn colored-cannon-ball [color] 556 (defn colored-cannon-ball [color]
558 (comp #(change-color % color) 557 (comp #(change-color % color)
559 (fire-cannon-ball))) 558 (fire-cannon-ball)))
560 559
561 (defn test-worm-vision [] 560 (defn test-worm-vision [record]
562 (let [the-worm (doto (worm)(body!)) 561 (let [the-worm (doto (worm)(body!))
563 vision (vision! the-worm) 562 vision (vision! the-worm)
564 vision-display (view-vision) 563 vision-display (view-vision)
565 fix-display (gen-fix-display) 564 fix-display (gen-fix-display)
566 me (sphere 0.5 :color ColorRGBA/Blue :physical? false) 565 me (sphere 0.5 :color ColorRGBA/Blue :physical? false)
584 (light-up-everything world) 583 (light-up-everything world)
585 (speed-up world) 584 (speed-up world)
586 (.setTimer world timer) 585 (.setTimer world timer)
587 (display-dialated-time world timer) 586 (display-dialated-time world timer)
588 ;; add a view from the worm's perspective 587 ;; add a view from the worm's perspective
588 (if record
589 (Capture/captureVideo
590 world
591 (File.
592 "/home/r/proj/cortex/render/worm-vision/main-view")))
593
589 (add-camera! 594 (add-camera!
590 world 595 world
591 (add-eye! the-worm 596 (add-eye! the-worm
592 (.getChild 597 (.getChild
593 (.getChild the-worm "eyes") "eye")) 598 (.getChild the-worm "eyes") "eye"))
594 (comp 599 (comp
595 (view-image 600 (view-image
596 (File. "/home/r/proj/cortex/render/worm-vision/worm-view")) 601 (if record
602 (File.
603 "/home/r/proj/cortex/render/worm-vision/worm-view")))
597 BufferedImage!)) 604 BufferedImage!))
598 (set-gravity world Vector3f/ZERO) 605
599 (try 606 (set-gravity world Vector3f/ZERO))
600 (Capture/captureVideo
601 world
602 (File. "/home/r/proj/cortex/render/worm-vision/main-view"))))
603 607
604 (fn [world _ ] 608 (fn [world _ ]
605 (.setLocalTranslation me (.getLocation (.getCamera world))) 609 (.setLocalTranslation me (.getLocation (.getCamera world)))
606 (vision-display 610 (vision-display
607 (map #(% world) vision) 611 (map #(% world) vision)
608 (File. "/home/r/proj/cortex/render/worm-vision")) 612 (if record (File. "/home/r/proj/cortex/render/worm-vision")))
609 (fix-display world))))) 613 (fix-display world)))))
610 #+end_src 614 #+end_src
611 615
612 The world consists of the worm and a flat gray floor. I can shoot red, 616 The world consists of the worm and a flat gray floor. I can shoot red,
613 green, blue and white cannonballs at the worm. The worm is initially 617 green, blue and white cannonballs at the worm. The worm is initially
676 680
677 #+begin_src sh :results silent 681 #+begin_src sh :results silent
678 cd /home/r/proj/cortex/render/worm-vision 682 cd /home/r/proj/cortex/render/worm-vision
679 ffmpeg -r 25 -b 9001k -i out/%07d.png -vcodec libtheora worm-vision.ogg 683 ffmpeg -r 25 -b 9001k -i out/%07d.png -vcodec libtheora worm-vision.ogg
680 #+end_src 684 #+end_src
681 685
682 * Headers 686 * Headers
683 687
684 #+name: vision-header 688 #+name: vision-header
685 #+begin_src clojure 689 #+begin_src clojure
686 (ns cortex.vision 690 (ns cortex.vision