comparison org/integration.org @ 299:47fe4f7b74b3

rendering video for the first time!
author Robert McIntyre <rlm@mit.edu>
date Thu, 16 Feb 2012 21:14:28 -0700
parents 85f3ff3e3f26
children c78917fb0615
comparison
equal deleted inserted replaced
298:85f3ff3e3f26 299:47fe4f7b74b3
389 27 :thumb-1-f 389 27 :thumb-1-f
390 28 :pinky-1-f 390 28 :pinky-1-f
391 29 :pinky-1-e 391 29 :pinky-1-e
392 ) 392 )
393 393
394
395
396 ;; rotate touch 180
397
398 ;; rotate mucles 90 counter-clockwise
399 ;; scale muscles to 15x60
400
401 finger width : 113
402 finger height : 357
403
404 thumb width : 113
405
406 pinky --- 0,195
407 ring --- 111,100
408 middle --- 228,0
409 pointer -- 436,96
410 thumb --- 486,420
411
412
413
414 within a finger (coordinates of top left corner (x,y)):
415
416 tip-flexor : 0,7
417 tip-extensor : 98,7
418 tip : 18,0
419
420 joint-2-3 : 32,79
421
422 mid-flexor : 19,131
423 mid-extensor : 80,131
424 mid : 30,133
425
426 joint-1-2 : 32,193
427
428 base-flexor : 19,245
429 base-extensor : 80,245
430 base : 39,247
431
432 joint-palm-1 : 32,307
433
434
435 Thumb is the same as finger, except it has two more pieces
436
437 extra-flexor-1 : 2,131
438 extra-flexor-2 : 100,131
439
440 ;; rotate entire thumb 45 degrees clockwise
441
442 within vision
443 gray -- 165,577
444 green -- 278,577
445 blue -- 165,682
446 red -- 278,682
447
448 entire hand : 809, 22
449 main view : 78,202
450 hearing : 784,819
451
452 hand-size: 688x769
453
454
455 total image size:
456 1600x894
457
458 (def base (File. "/home/r/proj/cortex/render/hand")) 394 (def base (File. "/home/r/proj/cortex/render/hand"))
459
460
461 395
462 (defn prepare-muscle [muscle] 396 (defn prepare-muscle [muscle]
463 ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"]) 397 ["(" muscle "-rotate" "90" "-scale" "15x60!" ")"])
464 398
465 (defn prepare-touch [touch] 399 (defn prepare-touch [touch]
481 (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite" 415 (prepare-muscle mid-extensor) "-geometry" "+80+131" "-composite"
482 (prepare-touch mid) "-geometry" "+39+133" "-composite" 416 (prepare-touch mid) "-geometry" "+39+133" "-composite"
483 417
484 joint-1-2 "-geometry" "+32+193" "-composite" 418 joint-1-2 "-geometry" "+32+193" "-composite"
485 ")"]) 419 ")"])
420
421 (defn file-names [#^File dir]
422 (map #(.getCanonicalPath %) (next (sort (file-seq dir)))))
423
424 (defn file-groups [& paths]
425 (apply (partial map list )
426 (map (comp file-names #(File. base %))
427 paths)))
428
429
430 (defn pinky []
431 (file-groups
432 "muscle/18"
433 "muscle/19"
434 "touch/5"
435 "proprio/7"
436
437 "muscle/17"
438 "muscle/16"
439 "touch/4"
440 "proprio/8"
441
442 "muscle/28"
443 "muscle/29"
444 "touch/3"
445 "proprio/10"))
446
447 (defn ring []
448 (file-groups
449 "muscle/21"
450 "muscle/20"
451 "touch/11"
452 "proprio/5"
453
454 "muscle/22"
455 "muscle/23"
456 "touch/10"
457 "proprio/6"
458
459 "muscle/25"
460 "muscle/24"
461 "touch/9"
462 "proprio/12"))
463
464 (defn middle []
465 (file-groups
466 "muscle/14"
467 "muscle/15"
468 "touch/2"
469 "proprio/1"
470
471 "muscle/12"
472 "muscle/13"
473 "touch/1"
474 "proprio/0"
475
476 "muscle/8"
477 "muscle/9"
478 "touch/0"
479 "proprio/9"))
480
481 (defn pointer []
482 (file-groups
483 "muscle/10"
484 "muscle/11"
485 "touch/8"
486 "proprio/4"
487
488 "muscle/1"
489 "muscle/0"
490 "touch/7"
491 "proprio/3"
492
493 "muscle/5"
494 "muscle/4"
495 "touch/6"
496 "proprio/11"))
497
498 (defn thumb []
499 (file-groups
500 "muscle/7"
501 "muscle/6"
502 "touch/13"
503 "proprio/2"
504
505 "muscle/27"
506 "muscle/26"
507 "muscle/3"
508 "muscle/2"
509 "touch/12"
510 "proprio/13"))
486 511
487 (defn generate-finger 512 (defn generate-finger
488 [tip-flexor tip-extensor tip 513 [tip-flexor tip-extensor tip
489 joint-2-3 514 joint-2-3
490 mid-flexor mid-extensor mid 515 mid-flexor mid-extensor mid
517 mid-flexor mid-extensor mid 542 mid-flexor mid-extensor mid
518 joint-palm-1) "-geometry" "+0+0" "-composite" 543 joint-palm-1) "-geometry" "+0+0" "-composite"
519 (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite" 544 (prepare-muscle mid-flexor-2) "-geometry" "+2+131" "-composite"
520 (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite" 545 (prepare-muscle mid-extensor-2) "-geometry" "+100+131" "-composite"
521 ")"]) 546 ")"])
522
523 pinky --- 0,195
524 ring --- 111,100
525 middle --- 228,0
526 pointer -- 436,96
527 thumb --- 486,420
528
529 547
530 (defn generate-hand 548 (defn generate-hand
531 [pinky-pieces 549 [pinky-pieces
532 ring-pieces 550 ring-pieces
533 middle-pieces 551 middle-pieces
556 green "-geometry" "+113+0" "-composite" 574 green "-geometry" "+113+0" "-composite"
557 blue "-geometry" "+0+105" "-composite" 575 blue "-geometry" "+0+105" "-composite"
558 red "-geometry" "+113+105" "-composite" 576 red "-geometry" "+113+105" "-composite"
559 ")"]) 577 ")"])
560 578
561
562
563 (def test-muscle (File. base "muscle/0/0000000.png")) 579 (def test-muscle (File. base "muscle/0/0000000.png"))
564 (def test-proprio (File. base "proprio/0/0000000.png")) 580 (def test-proprio (File. base "proprio/0/0000000.png"))
565 (def test-tip (File. base "touch/2/0000000.png")) 581 (def test-tip (File. base "touch/2/0000000.png"))
566 (def test-mid (File. base "touch/0/0000000.png")) 582 (def test-mid (File. base "touch/0/0000000.png"))
567 (def test-vision (File. base "vision/0/0000000.png")) 583 (def test-vision (File. base "vision/0/0000000.png"))
568 (def test-hearing (File. base "hearing/0/0000000.png")) 584 (def test-hearing (File. base "hearing/0/0000000.png"))
569 (def test-main (File. base "main/0000000.png")) 585 (def test-main (File. base "main/0000000.png"))
570 586
571
572 (def test-target (File. base "output.png")) 587 (def test-target (File. base "output.png"))
573 588
574 (def background (File. base "background.png")) 589 (def background (File. base "background.png"))
575 590
576 (use 'clojure.contrib.shell-out) 591 (use 'clojure.contrib.shell-out)
577 (defn final-image [muscle proprio tip mid vision hearing main] 592
578 (let [[muscle proprio tip mid vision hearing main] (map #(.getCanonicalPath %) 593 (defn vision []
579 [muscle proprio tip mid vision 594 (file-groups
580 hearing main]) 595 "vision/0"
581 finger-pieces [muscle muscle tip 596 "vision/1"
582 proprio 597 "vision/2"
583 muscle muscle mid 598 "vision/3"))
584 proprio 599
585 muscle muscle mid 600 (defn hearing []
586 proprio] 601 (file-names (File. base "hearing/0")))
587 thumb-pieces [muscle muscle tip 602
588 proprio 603 (defn main []
589 muscle muscle muscle muscle mid 604 (file-names (File. base "main")))
590 proprio]] 605
591 606 (defn targets []
592 607 (map
593 (apply 608 (comp #(.getCanonicalPath %)
609 #(File. (str base "/out/" (format "%07d.png" %))))
610 (range 0 (count (main)))))
611
612
613 (defn final-image [main [all red green blue] hearing
614 pinky ring middle pointer thumb target]
615 (println target)
616 (apply
594 sh 617 sh
595 (flatten 618 (flatten
596 ["convert" 619 ["convert"
597 (.getCanonicalPath background) 620 (.getCanonicalPath background)
598 (generate-hand finger-pieces 621
599 finger-pieces 622 (generate-hand pinky ring middle pointer thumb)
600 finger-pieces
601 finger-pieces
602 thumb-pieces)
603 "-geometry" "+809+22" "-composite" 623 "-geometry" "+809+22" "-composite"
604 624
605 (generate-vision vision vision vision vision) 625 (generate-vision all red green blue)
606 "-geometry" "+974+599" "-composite" 626 "-geometry" "+974+599" "-composite"
607 627
608 hearing 628 hearing
609 "-geometry" "+784+819" "-composite" 629 "-geometry" "+784+819" "-composite"
610 630
611 main 631 main
612 "-geometry" "+78+202" "-composite" 632 "-geometry" "+78+202" "-composite"
613 633
614 (.getCanonicalPath test-target)])))) 634 target])))
615 635
616 636 (defn convert-files []
617 637 (dorun
618 638 (pmap final-image
619 639 (main)
620 640 (vision)
641 (hearing)
642 (pinky)
643 (ring)
644 (middle)
645 (pointer)
646 (thumb)
647 (targets))))
621 #+end_src 648 #+end_src
622 649
650
651 #+begin_src sh
652 cd /home/r/proj/cortex/render/hand
653
654 ffmpeg -r 60 -i out/%07d.png -i main.wav -b:a 128k \
655 -b:v 9000k -c:a libvorbis -c:v libtheora hand.ogg
656 #+end_src
657
623 #+results: integration 658 #+results: integration
624 : #'cortex.integration/test-everything! 659 : #'cortex.integration/convert-files
625 660
626 * COMMENT purgatory 661 * COMMENT purgatory
627 #+begin_src clojure 662 #+begin_src clojure
628 (defn bullet-trans* [] 663 (defn bullet-trans* []
629 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red 664 (let [obj-a (box 1.5 0.5 0.5 :color ColorRGBA/Red