ã2å¹´åãããã£ã¦ããåç»ã108åç´¹ä»ããã¨ããã·ãªã¼ãºãããããæå¾ã®108åç®ã¨ãããã¨ã§èªãä¹ ãã¶ãã«ãã¸ããåç»ãä½ã£ã¦ã¿ã¾ããããªããªãããé»æ³¢å ·åã«ãªã£ããã¨æã£ã¦ãã¾ãããããªã
ã¢ãé¡ããã«ãã¼ã¹
ãèªåçã«ã¢ãé¡ã«ãªãã½ããã¤ãã£ã¦ããã«ãã¼ã¹ããã£ã¦ã¿ãããæ¬å½ã®ã¢ãé¡ããã«ãã¼ã¹ã«ãªãã®ã§ã¯ãªããï¼ï¼ãããªç´ æ´ãªçºæ³ããé¡èªèãã¦å¼·å¶çã«ã¢ãé¡ããã«ãã¼ã¹ã«ãªãã½ãããä½ã£ã¦ã¿ã¾ããã
ã使ã£ãã®ã¯Processingã¨ããããªã¼ã®ããã°ã©ã è¨èªã¨ãã¸ã«ã¡ã®ã¿ã§ãï¼å¤åï¼èª°ã§ãä½ãã¦ãã¾ãã¾ããããã使ãã°æ°ã«ãªããã®åãã»ã»ã»ããæªç¨åå ã§ããï¼ï¼ç¥ã£ã¦ãã人ã«ã¯æ»æ®»æ©åéã®ç¬ãç·ã£ã¦è¨ãã¨ããããããããªã
ææç©
ã社ä¼äººã¯çµè«ãã話ãï¼ã¨ããè¨ãããã®ã§ãã¨ããããä½ã£ãã½ããã§PVçãªãã®ãä½ã£ã¦ã¿ã¾ãããæ¬å½ã¯é©å½ãªäººå½¢ã¨ããé¡èªèããã¦åç»ã¤ãããã¨ããã®ã§ãããã¤ãã¤ãé¡èªèçããããªãçµå±äººéã®é¡ãä¸çªã ã¨ãããã¨ã«ãªãèªãä½å¼µããã¨ã«ãªãã¾ããã
ããªããªãããã¢ãé¡ã£ã·ãã§ããï¼ä»åã¯äºãæ®ã£ãåç»ã§ãã£ã¦ãã¾ãããã¡ããWEBã«ã¡ã©ã§ãªã¢ã«ã¿ã¤ã ã«ã¢ãé¡ã«ãªããã¨ãå¯è½ã§ãããªã¢ã«ã¿ã¤ã ã ã¨ããé»æ³¢åº¦ãä¸ããã®ã§æ¯é試ãã¦ã¿ã¦ä¸ããã
æºå
ãããã¿ããªã¢ãé¡ãããã¦è奮ãã¦ãããï¼å¾ ã¡ãããªãããï¼ãããæ©éä½ãæ¹ã解説ãã¦ããã¾ãããã¾ãã¯æºåãããåã使ã£ã¦ããã®ãMacãªã®ã§Macã®èª¬æã§ããWindowsã¨ãLinuxã§ãã§ããã¯ãã§ããé©å½ã«èª¿ã¹ã¦ä¸ããï¼æãããï¼ã
Processingããã¦ã³ãã¼ã
ããProcessingのサイトãã«è¡ã£ã¦ãã¦ã³ãã¼ãã£ã¦ã¨ãã¯ãªãã¯ãã¦èªåã®OSç¨ã®ãã¡ã¤ã«ããã¦ã³ãã¼ããã¦ã¤ã³ã¹ãã¼ã«ãã¦ãâãªã«ï¼è±èªã ããããããããªãã ã¨ï¼ï¼ã¨ããããDownloadã£ã¦ãã¤ã¯ãªãã¯ãã¦ããStable Releasesã£ã¦ã¨ãã®ä¸ã«ããä¸çªæ°åã®å¤§ãããã¼ã¸ã§ã³ã®ãã¡ã¤ã«ãã¯ãªãã¯ãã¨ãããããã ãï¼ï¼
Open CVãã¤ã³ã¹ãã¼ã«
ãé¡èªèã使ãã«ã¯ãOpen CVã¨ããã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããªãã¨ãããªãã¿ãããªã®ã§ã¤ã³ã¹ãã¼ã«ãã¾ãããOPENCV Processing and Java Libraryãã£ã¦ã¨ãã§ãã¦ã³ãã¼ããã¤ã³ã¹ãã¼ã«ãã¦è¦ã¦ä¸ãããã¤ã³ã¹ãã¼ã«ããå¾ãProcessingã®Libraryã£ã¦ãã©ã«ãã«Open CVã£ã¦ãã©ã«ããã³ãã¼ããå¿ è¦ãããã®ã§æ³¨æãã¦ããè±èªã§ãããããªãããã©ãæ°åãã§GOï¼
ãã¸ã«ã¡ãæºå
ãåç»ãã¨ãããã¤ãªããªãã§ãOKï¼å¤åï¼ï¼Webã«ã¡ã©ãªããªã¢ã«ã¿ã¤ã ã«ã¢ãé¡ã§ããã®ã§ãã¡ãããªã¹ã¹ã¡ï¼åã¯å®¶ã«è»¢ãã£ã¦ãLogitechã®ç®çã¿ãããªWebã«ã¡ã©ä½¿ã£ããã
ãæåã¯Macã§ããã¤ã¹èªèãã¦ãããªãã£ããã©ã調ã¹ãããmacamãã¨ããMac OS Xã§Webã«ã¡ã©ä½¿ããããã«ãã¦ãããã½ããããã£ãã®ã§ã¤ã³ã¹ãã¼ã«ããããã¾ãããã¾ãããã¾ããã¦ãè±èªã ãã©ãã¨ããããä¸çªæ°åã®å¤§ãããã¼ã¸ã§ã³ã®ãã¡ã¤ã«ãã¯ãªãã¯ãã¨ãã°ãããï¼
ã¢ãé¡ãæºå
ã好ããªã¢ãé¡ãæºåãã¦ãï¼å人ã§æ¥½ããåã«ã¯é©å½ã«ãããããæ¾ã£ã¦ããã°ããããããªãããªã好ããªå½¢å¼ã®ç»åãã¡ã¤ã«ãè½ã¨ãã¦ãããã£ï¼ããªã¼ç´ æã®ã¢ãé¡ã欲ããï¼ä»æ¹ãªããªããåãä½ã£ãã¨ã£ã¦ããã®ããããããã¡ããã¨ééPNGã«ãªã£ã¦ãããããã£ãããã ãï¼
ã誰ãæãã¦ãããªãã£ãã®ã§èªåã§æãã¾ãã
ããã°ã©ãã³ã°
ãããããã£ããããã°ã©ãã³ã°ãã¦ã¿ã¾ããããä½ï¼ããã°ã©ãã³ã°ãããããªãï¼ï¼ãã£ããã¨ãªãï¼ï¼ã°ã£ããããï¼ä¿ºã ã£ã¦ããããããããï¼ãããã ããProcessingã£ã¦ã½ããå®è¡ã㦠ã³ããã㦠▶ãã¿ã³ããããããã§ãããã ãï¼ç¥ã£ã¦ é£ã¹ã¦ æããã¦ã¿ãããªããã ï¼ã¿ããªãããã£ã¦å¤§ãããªã£ããã ãï¼
ãå®è¡ã㦠ã³ããã㦠▶ãã¿ã³æ¼ãã¦ã®å³
ããããã ã½ã¼ã¹ã³ã¼ãé©å½ãªãã©ã«ãã«ä¿åãã¦ãåããã©ã«ãã«ã¢ãé¡ã®ç»åãã¡ã¤ã«ããahegao.pngãã¨ããååã§ä¿åãããå¿ããªãã§ããjpegç»åã«ããå ´åã¯ãã½ã¼ã¹ãã¡ã¤ã«ã®æ¹ãããã£ã¦ãã£ã¦ä¸ããã
ãã³ããããã½ã¼ã¹ã³ã¼ãã¯ä¸è¨ãåç
§ãã¦ãã解説ï¼ãããªãã®ãããï¼åã ãåï¼åãããããã ãï¼
â Webã«ã¡ã©ã使ã£ã¦ã¢ãé¡ã«ãªãæ¹æ³
ãWebã«ã¡ã©ãPCã«æ¥ç¶ãã¦ããå®è¡ãã¦ãé©å½ãªé¡ãã«ã¡ã©ã§åãã¨ãªã¢ã«ã¿ã¤ã ã§ã¢ãé¡ã楽ããããï¼çµæ§è§åº¦ã¯éè¦ãªã®ã§æ£é¢ãåãã¦ä¸ãããç®ãé¼»ãå£çãªãã®ãããã°äººéãããªãã¦ãèªèãã¦ããã¾ãã
import hypermedia.video.*; import java.awt.Rectangle; import processing.video.*; boolean rec = false; // true: recording int fps = 30; int w = 640; int h = 480; OpenCV opencv; MovieMaker mm; PImage img; void setup() { size( w, h ); opencv = new OpenCV(this); opencv.capture( width, height ); opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); img = loadImage("ahegao.png"); imageMode(CORNER); if(rec){ mm = new MovieMaker(this, w, h, "ahegao.mov", fps, MovieMaker.VIDEO, MovieMaker.LOSSLESS); frameRate(fps); } } void draw() { opencv.read(); image( opencv.image(), 0, 0 ); Rectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 ); for( int i=0; i<faces.length; i++){ image(img, faces[i].x, faces[i].y, faces[i].width, faces[i].height ); } if(rec){ mm.addFrame(); } } void keyPressed() { if (key == ' ') { if(rec){ mm.finish(); } exit(); } }
ã¡ãã£ã¨ã ã解説ï¼
1.æåã®æ¹ã® int w = 640; int h = 480; ã£ã¦å¥´ã¯è§£å度ã ãã使ã£ã¦ããã«ã¡ã©ã®è§£å度ã«åããã¦æ°åãå¤ãã¦ãã£ã¦ããããããããªããã°ããã®ã¾ã¾å®è¡ãã¦ã¿ãã°ããããä½äºããã£ã¬ã³ã¸ã ãã
2.boolean rec = false; ã£ã¦ãã¤ã¯ãfalseâtrueã«ããã¨ã¢ãé¡åç»ãä¿åã§ããããã¹ãã¼ã¹ãã¼ãæ¼ãã¨çµäºãã¦ãahegao.movãã£ã¦ãã¡ã¤ã«åã§åããã©ã«ãã«ä¿åãããããåç»ã®ãã¬ã¼ã æ°ã¯ int fps = 30; ã®æ°åãå¤ããã°å¤ããããã¾ãåä½ãã¾ãã«éãã£ããé©å½ã«å°ãããã¦ãã£ã¦ã
â 好ããªåç»ãã¢ãé¡åç»ã«ããæ¹æ³
ã次ã¯ãããããæ®ã£ã¦ãããåç»ãé¡èªèãã¦ãèªåçã«ã¢ãé¡ã«ãã¦ãããããã°ã©ã ãåãããã«ã³ãããã¦ä¿åãã¦ãã¢ãç»åããahegao.pngããå¤æãããåç»ããsource.AVIãã£ã¦ãã¡ã¤ã«åã«ãã¦åããã©ã«ãã«ä¿åãã¦å®è¡ããã°ããã£ã¨ããéã«æ®éã®åç»ãã¢ãé¡åç»ã«æ©å¤ããã大ããåç»ã ã¨åãæéããããããrec = true ã«ãã¦å¥ãã¡ã¤ã«ã«æéããã¦æ¸ãåºãã¦ããå¾ã§ã¢ãé¡åç»ãéè³ããã®ãããã§ããAVI以å¤ã®ãã¡ã¤ã«ï¼mpgã¨ãmovï¼ã®å ´åã¯ãã½ã¼ã¹ã³ã¼ãããsource.mpgãã¨ããsource.movãã£ã¦å¤ãã¦ããã°ãããï¼
import hypermedia.video.*; import java.awt.Rectangle; import processing.video.*; boolean rec = true; // true: recording int fps = 30; int w = 1280; int h = 720; OpenCV opencv; MovieMaker mm; PImage img; void setup() { size( w, h ); opencv = new OpenCV( this ); opencv.movie( "source.AVI", width, height ); opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); img = loadImage("ahegao.png"); imageMode(CORNER); if(rec){ mm = new MovieMaker(this, w, h, "ahegao.mov", fps, MovieMaker.VIDEO, MovieMaker.LOSSLESS); frameRate(fps); } } void draw() { opencv.read(); image( opencv.image(), 0, 0 ); Rectangle[] faces = opencv.detect(); for( int i=0; i<faces.length; i++){ image(img, faces[i].x, faces[i].y, faces[i].width, faces[i].height ); } if(rec){ mm.addFrame(); } } void keyPressed() { if (key == ' ') { if(rec){ mm.finish(); } exit(); } }
â å¼·ããããåç»
ãéä¸ã§ä½¿ã£ãã¬ã³ãã AGEã§è©±é¡ã®å¼·ããããå¹æã§ããããã¯
ãProcessing+OpenCVで顔検出を使ったり強いられたりする方法ãã¨ããè¨äºã®ã½ã¼ã¹ã³ã¼ããã³ããããã ãã§ããæä½ã ãï¼
â ç»é¢åå²
ãã¡ãã£ã¨è©¦ãã«ãã£ã¦ã¿ãæå¾ã®æ¹ã®åã®é¡ãå¢ãã¦ããæ°æã¡æªãå¹æã§ãã
int bunkatsu = 60; ã§åå²æ°ãå¤ããã¾ãã3ãªã3Ã3ã®åå²åç»ã«ã1024ãªã1024Ã1024ã®åå²åç»ã«ãªãã¾ãããã 並ã¹ã¦ã³ãããã¦ããã ããªã®ã§ãåå²æ°å¤ããã¦ãå¦çé度ã»ã¨ãã©ããããªãã®ããã½ã§ãã
import hypermedia.video.*; import java.awt.Rectangle; import processing.video.*; boolean rec = true; // true: recording int bunkatsu = 60; int fps = 30; int w = 1280; int h = 720; OpenCV opencv; MovieMaker mm; PImage img; void setup() { size( w, h ); opencv = new OpenCV( this ); opencv.movie( "source.mov", w/bunkatsu, h/bunkatsu ); if(rec){ mm = new MovieMaker(this, w, h, "bunkatsu.mov", fps, MovieMaker.VIDEO, MovieMaker.LOSSLESS); frameRate(fps); } } void draw() { opencv.read(); for(int i=0; i<bunkatsu; i++){ for(int j=0; j<bunkatsu; j++){ image( opencv.image(), i*w/bunkatsu, j*h/bunkatsu); } } if(rec){ mm.addFrame(); } } void keyPressed() { if (key == ' ') { if(rec){ mm.finish(); } } exit(); }
åèã«ããè¨äº
ãåèã£ã¦ããããã»ã¨ãã©ãããã®ãµã¤ããã丸ãã¯ãªã ãï¼æä½ã ããã§ãã¿ããªãããã£ã¦å¤§ãããªã£ããã ãâå 人ã®ç¥æµã«æè¬ã
http://blog.degoo.org/post/52635972113/processing-and-opencv-hidakatoru
ãå大ãªãå
人
Processing+OpenCVで顔検出を使ったり強いられたりする方法 - むだな ものを つくる
ãæåã®æºåã¨ãã¯ãã®ãµã¤ãè¦ãæ¹ãå¤åããããããã§ããç´ æ´ããã
ãProcessingによる画像処理プログラミング(pdf)ã
ãæç§æ¸ã¿ãããªã¾ã¨ããã¨æã£ããåå¤å±å¸ç«å¤§å¦ã®è¬ç¾©ã®è³æã§ãããProcessingã®è¬ç¾©ãªãã¦æ¥½ããããこのページãã«Processing使ã£ãç»åå¦çããåç»å¦çã«é¢ããããããªè³æãç½®ãã¦ããã¾ãããç´ æ´ãããã§ãã
ã¾ã¨ã
ãProcessingã¨OpenCV使ãäºã§ç°¡åã«æãã¤ããå½¢ã«ãããã¨ãã§ãã¾ãããWebã«ã¡ã©ã§é¡èªèããã¾ã§å®è³ª30åç¨åº¦ãããã»ã©ãæ軽ã«ã§ãã¦ãã¾ãã®ã¯ç´ æ´ãããã§ãããè²ã
æ
å ±ãã©ã¤ãã©ãªãå
å®ãã¦ããããã ã¨æãã¾ãããã¨ãã¨ãµã¨ããæãã¤ãã§ãã£ã¦ã¿ãã®ã§ãããç»è³ªã«å°ãæã£ãããé¡èªè以å¤ã®ã¨ãã§ã¯ãã試ãã¦ã¿ããã¡ã«ãããã£ã¦æ®éã«åç»ã®FXï¼ç¹æ®å¹æï¼ã«ä½¿ããããããã£ã¦æ°ã¥ãã¾ããã
ãiMovieã¨ãã®åç»ç·¨éã½ããã£ã¦ä¸å¿è²ã
ç¹æ®å¹æãã£ã¦ããã£ã«ã 調ã«ãããå¤å°åã£ãã ã¼ãã¼ä½ã£ããã§ããã®ã§ããããã³ãã¬ã¼ã以å¤ã®ãã¨ããããã¨ãã¦ãã»ã¨ãã©ä½ãã§ããªããã§ããããAdobe Effectsã¨ã使ãã°è²ã
ã§ããã®ããããã¾ãããæµç³ã«ã¡ãã£ã¨10ä¸ã¯ãã³ã¨åºããªãããããªåãããã®è伸ã³ããã¢ããã¥ã¢ã«ã¯Processingã£ã¦ããã¿ãªã®åç»å¦çã½ãããªã®ããã£ã¦æãã¾ãããæ£ç´é¦¬é¹¿ã«ãã¦ã¦ãã¿ã¾ããã§ãããProcessingã¯ä»ã«ãç»åå¦çãé³æ¥½ç³»ã«ã使ããããªã®ã§ã¾ãè²ã
å®é¨ãã¦ã¿ããããªã¨èãã¦ã¾ãã