Advent Calendaråå è¨äº
ãAdvent Calendarã«é¢ãã¦ã¯ä¸è¨è¨äºåç
§ãã ããã
ãä»å¹´ã¯æ¯å¹´åå ãã¦ããProcessingã®ä»ãæè¿è²ã éãã§ããRaspberry Piã®Advent Calendarã«ããã£ãããªã®ã§åå ãã¦ã¿ã¾ããã
ãåå ããã®ã¯è¯ãã®ã§ãããæ¸ãæéããã¾ããªãã®ã§ä¸ã¤ã®è¨äºã§ä¸¡æ¹ã®Advent Calendarã«åå ãã¦ã¿ããã¨ãã大èãªè©¦ã¿ããã¦ã¿ã¾ããã²ãã£ã¨ãããç¦ãæã ã£ãããã
Raspberry Piã¨Processing
ãRaspberry PiãProcessingã大好ãããããRaspberry Piã§Processingããã°è¯ãã®ãããªãã¨æãããã§ããProcessingã ã¨æ軽ã«æ åãããããã®ã§ãããã¸ã§ã¯ã¿ã§ã¡ãã£ã¨ããã¤ã³ã¹ã¿ã¬ã¼ã·ã§ã³ããããã©PCã ã¨å¤§ããã¨ããå ´åãå¦æ ¡ã§ã®æè²ç¨ãªã©è²ã 使ãéãèãããã¾ãããå°ãåã¾ã§Raspberry Piã§Processingåããã®ã¯ä¸ã å³ããã£ãããã§ããããã¼ãã¦ã§ã¢ãRaspberry Pi2ã¨ãªãå¤§å¹ ã«ãã·ã³ãã¯ãã¢ããããã®ã¨ãã½ããã¦ã§ã¢ãProcessingãver3.01ã§Raspberry Piã«æ£å¼å¯¾å¿ãããã¨ã§ããããåãããã«ãªã£ã¦ããããã§ãã
ãMake:ã®ä»¥ä¸è¨äºã«Processingã®Raspberry Pi対å¿ã®ç´¹ä»ã¨ã¤ã³ã¹ãã¼ã«æ¹æ³æ¸ãã¦ãã£ãã®ã§ãããããç¨åº¦ããã£ã¦ãã人åãã®ãã£ãããã説æãªã®ã§ãåå¿è
åãã®è£è¶³ãã»å
·ä½çãªã³ãã³ãã追å ãã¦èª¬æããä¸ã§ãRaspberry Pi + Processingã§ç°¡åãªç»åå¦çã«ææ¦ãã¦ã¿ããã¨æãã¾ãã
ãç¶ãã¯ãèå³ããæ¹ã®ã¿ã覧ä¸ããã
Raspberry Piã¨Processingã®ã»ããã¢ããæ¹æ³
Raspberry Piã»ããã¢ãã
ãæä½éRaspberry Piãå¿
è¦ã§ããä»ã ã¨Raspberry Pi2ããªã¹ã¹ã¡ãRaspberry Pi3ãRaspberry Pi4ããªã¹ã¹ã¡ã§ãã
ãå½å æ£è¦ä»£çåºçãRaspberry Pi 4 Model B/4GB OKdoçãæé©ãã¼ã¯ä»ã
- ã¡ãã£ã¢: Personal Computers
ãä»ã«å¿ è¦ãªãã®ããå ·ä½çãªã»ããã¢ããæ¹æ³ã¯ä»¥ä¸ã®è¨äºãåç §ä¸ããï¼TensorFlowã®ã»ããã¢ããã¯ä¸è¦ã§ãï¼ã
Processingã¤ã³ã¹ãã¼ã«
ãã»ããã¢ããå®äºãã¦ãããã«æ¥ç¶ããRaspberry Piãèµ·åãã¾ãã
ã次ã«ã¿ã¼ããã«ãèµ·åï¼ä¸ã®æ¹ã«ãããã¬ãã¿ãããªã¢ã¤ã³ã³ãã¯ãªãã¯ãï¼ãã¦ä»¥ä¸ã³ãã³ãã§processingããã¦ã³ãã¼ããã¦è§£åãã¾ãããã
$ wget https://github.com/processing/processing/releases/download/processing-0269-3.5.3/processing-3.5.3-linux-armv6hf.tgz $ tar xvzf processing-3.5.3-linux-armv6hf.tgz
ãããã§ã¤ã³ã¹ãã¼ã«ã¯å®äºã§ãã
Processingèµ·å
ããã®ã¾ã¾ä»¥ä¸ã³ãã³ããå®è¡ã
$ cd processing-3.5.3/ $ ./processing
ã以ä¸ã®ãããªç»é¢ãåºããèµ·åæåã§ãã
Processingã§é¡èªèãã¦ã¢ãé¡(OpenCV)
ããã£ãããªã®ã§ãProcessingã§æä½ã£ãé¡èªèãã¦ã¢ãé¡ã«ãªãæ°ã®çã£ãããã°ã©ã ã試ãã¦ã¿ããã¨æãã¾ããä¸è¨è¨äºåç
§ã
OpenCVã¤ã³ã¹ãã¼ã«
ãã¾ãã¯ç»åå¦çã«ãã使ãããOpenCVã¨ããã©ã¤ãã©ãªãprocessingç¨ã®ãã®ã以ä¸ã³ãã³ãã§ãã¦ã³ãã¼ãï¼ã¤ã³ã¹ãã¼ã«ã
$ cd $ cd sketchbook/libraries $ wget https://github.com/atduskgreg/opencv-processing/releases/download/latest/opencv_processing.zip $ unzip opencv_processing.zip
ãããã§å®äºãæ¬å½ã¯å®äºãããªããã¨ãå¾ã§ãããã®ã§ããâ¦
ããã°ã©ã ã½ã¼ã¹ã³ã¼ã
ããã¨ãã¨ã®ããã°ã©ã ãProcessing1ç¨ã§ãProcessing3ã®å¯¾å¿ã§è²ã
ä¿®æ£ããå¿
è¦ããã£ãã®ã§ãä¿®æ£ãã¾ãããç¹ã«èª¬æããå¿
è¦ã¯ãªããããã®çãããã°ã©ã ã§ããåããã©ã«ãã«äººã®é¡ã®å
¥ã£ãç»åsource.jpg
ã¨ã¢ãé¡ç»åahegao.png
ãå
¥ãã¦ãã®ããã°ã©ã ãå®è¡ããã¨ãsource.jpg
ãã¢ãé¡ç»åã«æ©å¤ãããã¾ãã
import java.awt.Rectangle; import gab.opencv.*; OpenCV opencv; PImage source_img; PImage ahegao_img; void setup() { size(640, 480); opencv = new OpenCV(this, 640, 480); opencv.loadImage("source.jpg"); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); ahegao_img = loadImage("ahegao.png"); imageMode(CORNER); } void draw() { image( opencv.getInput() , 0, 0 ); Rectangle[] faces = opencv.detect(); for(int i=0; i<faces.length; i++){ image(ahegao_img, faces[i].x, faces[i].y, faces[i].width, faces[i].height ); } }
使ç¨ç»å
ããããã«å£å¿çç»åãªãããªã¨æã£ã¦æ¢ããã®ã§ãããèä½æ¨©çã«å³ããã£ãã®ã§ã変デジ研究所-カメラとガジェットのレビューブログããããããªã¼ç´ æããåããã¾ããããããã (id:lonestartx) ããããã¤ããããã¨ããããã¾ãï¼
ãããªãå£å¿ã£ã½ã(source.jpg)
ãã¢ãé¡(ahegao.png)
ããã°ã©ã å®è¡
ãåããã©ã«ãã«ç»åå
¥ãã¦ææ°æã
ã¨ããã°ã©ã å®è¡ããããç¡æ
ã«ãåããªãã
ã以ä¸ã®ã¨ã©ã¼ã¡ãã»ã¼ã¸ãã©ããProcessingã®OpenCVã©ã¤ãã©ãªã¯ã¾ã ARMç³»ã®Raspberry Piã«ã¯å¯¾å¿ãã¦ããªãããã§ããã·ã§ãã¯â¦
OpenCV for Processing is only compatible with the 64-bit download of Processing.
ãä»æ¹ãªãã®ã§Macä¸ã§åãããã¨ãããç¡äºåä½æåã
ãã¢ãé¡ã«ãªã£ãï¼
ã追è¨ï¼Raspberry Piã§Open CVåãããã«ãªãã¾ããï¼ä»¥ä¸åç
§ã
ã¾ã¨ã
ããããªãããããªããªãã§ãã¿ã¾ããâ¦Processingç¨ã®OpenCVãRaspberry Piã«å¯¾å¿ãããï¼ãã£ã¨ï¼åãã¦ãããã¯ããªã®ã§ãããã°ã©ã ã¯ä¸å¿å
¬éãã¦ããã¾ããOpenCVã使ããªããããªç°¡åãªç»åå¦çãªãåãã¾ãã®ã§ãProcessingã®exampleããã°ã©ã ããåèãµã¤ãã®ããã°ã©ã ãªã©è²ã
試ãã¦ã¿ã¦ä¸ããã
ãRaspberry Piã§OpenCVã使ãå ´åã¯pythonãè¯ãã¿ããã§ããpython+OpenCVããã£ã¦ã¿ããã¨ãã人ã¯ä¸è¨è¨äºåç
§ä¸ããã
ãpython+OpenCVã§ã®é¡èªèã¯ããããæ¢ãã°è²ã åºã¦ãã¾ããããã®ãã¡èªåããããããªã¨æã£ã¦ãã¾ãã®ã§ããã®ã¨ãã¯ã¾ãå ¬éãã¾ããå¤åã
追è¨ï¼å
¬éãã¾ããã以ä¸è¨äºåç
§ãã ããã
ãå½å æ£è¦ä»£çåºçãRaspberry Pi 4 Model B/4GB OKdoçãæé©ãã¼ã¯ä»ã
- ã¡ãã£ã¢: Personal Computers
é¢é£è¨äº
å¤æ´å±¥æ´
- 2020/09/10 ã©ãºãã¤4ã¨Processing3.5.3ã§ã®æ å ±è¿½è¨