ãã®ãããå€ãã®äººãç§ã®ããã°ã©ã ã®äŸãšãã³ãŒãã®äœæãšãã芳ç¹ããã®ãã®äœæ¥ã®èª¬æãåŸ ã£ãŠããŸããã 誰ããèªåã®ã³ã³ãã¥ãŒã¿ãŒã§ãããç¹°ãè¿ãããšãã§ããããã«ããããé çªã«äŒããŸãã ã³ãŒãå ã®è±å¯ãªã³ã¡ã³ãã«ãã£ãšæ³šæãæã£ãŠãã ããã圌ãã¯åãæã£ãŠããŸãïŒ ãããŠãè¶ å°åã®ã¹ã¯ããŒã«ãæããªãã§ãã ããããªããªãã å€ãã®æ å ±ã è¯ãã€ã³ã¿ãŒãããã®ããå Žæã«ç§»åãããšããã®èšäºã«ã¯å€ãã®ã¹ããŒã ãšåçããããŸãïŒ
ãããžã§ã¯ãéçº
ãã®çµæã åã®ããŒãã§ã¯ãå¿ èŠãªããããŒãæ¥ç¶ãããOpenCVã©ã€ãã©ãªãæ·»ä»ããããããžã§ã¯ããã³ãã¬ãŒããéçºãããŸããã æ®ã£ãŠããäœæ¥ã®çš®é¡ãšãã®æ¹æ³ãèŠãŠã¿ãŸãããã
ãŸãã ç±ãè¿œæ±ã§ã¯ ãããããã®äœæ¥ã¹ããŒã ãã¹ã±ããã§ããããšãå€æããŸãã
æšæº
åçãæäœããããã®ä¿®æ£ãããViola-Jonesã¡ãœããã
åé¡åã®äºåãã¬ãŒãã³ã°
åé¡åšã¯ææ ãèªèããããã®ã¢ãžã¥ãŒã«ã§äœ¿çšããããããäžé£ã®ã¢ã¯ã·ã§ã³ãæè²ãšãã¬ãŒãã³ã°ã®ããã«éçºãããŸããã
ãããã£ãŠã åé¡åšããã¬ãŒãã³ã°ããã«ã¯ ã次ã®ãã®ãå¿ èŠã§ãã
â¢éçºããŒã«ã®æºåãOpenCVã©ã€ãã©ãªã®æ¥ç¶ã
â¢ããŒã¿ã®æºåã 䜿çšã«é©ããŠããŸãïŒ
-ãããžãã£ããããã³ããã¬ãã£ããç»åã®ã»ããããã¹ãããŸãïŒããžãã£ãããã³ãã¬ãã£ãç»åïŒã ãããžãã£ãããªç»åã«ã¯ãé¢å¿ã®ãããªããžã§ã¯ãïŒé¡ãå£ã錻ãªã©ïŒãå«ãŸããŠããŸãã
ããã¬ãç»åã«ã¯èæ¯ã®ã¿ãå«ãŸããŸãã
-ç°¡åã«è£è¶³ã§ãã.vecãã¡ã€ã«ãåããµã€ãºã®ç»åã»ãããå«ãŸãããµã€ãºã¯çž®å°ãããŠããŸãã
-æ¢è£œã®ç»åã®ããŒã¿ããŒã¹ããããã®å€ãããããŸãã ããšãã°ãOpenCVéçºè ã䜿çšããFERET ã
â¢ç®çã®éšåã«ããžç»åãåãåããé£ç¶ããŠæ¥çããŸãã
â¢ãèæ¯ã®é¢å¿å¯Ÿè±¡ããšãã圢ã§ã®èªç¶ãªãã¹ãç»åã®æºåã
â¢é¢å¿é åïŒé¢å¿é åã ROI ïŒã®ç¹å®ã®äžé£ã®èªç¶ãªãã¹ãç»åã匷調衚瀺ããå®éã«ã¯ãé¢å¿ãªããžã§ã¯ããé 眮ãããŠããå Žæã®åº§æšãèšå®ããŸãã
â¢æ°ããããŒã¿ã»ãããžã®ä¿åã
â¢ãµã³ãã«ã®äœæïŒãã¬ãŒãã³ã°ãµã³ãã«ïŒã
â¢ãã¬ãŒãã³ã°ã ãã®æ®µéã§ïŒ
-ããŒã«åé¡åšãã¬ãŒãã³ã°;
-XMLãã¡ã€ã«ã®äœæã
åéãããç»åã»ããã¯ããŒã¿ãã©ã«ããŒã«åéãããXML圢åŒã®Haaråé¡åã®åœ¢åŒã®ã«ã¹ã±ãŒããhaarcascadesãã©ã«ããŒã«è¿œå ãããŸãã
äžäœå±æ§ãæã€ãšã³ãã£ãã£ãšããŠè¡šãããååé¡åã«å¯ŸããŠãåå¥ã®XMLã¹ãã¬ãŒãžãäœæããå¿ èŠããããŸãã DOM ïŒããã¥ã¡ã³ããªããžã§ã¯ãã¢ãã«ïŒããŸãã¯ãã·ã¢èªã§ã¯ãäžè¬çãªåœ¢åŒã®ãã®ãããªåé¡åã®ããã¥ã¡ã³ããªããžã§ã¯ãã¢ãã«ã以äžã«ç€ºããŸãã ã«ãŒãèŠçŽ ã¯ãªããžããªã§ãããªãŒèªäœã®é·ãã¯7ã§ãã
ã«ã¹ã±ãŒãã«ã¯å€ãã®ã¬ãã«ããããŸã-ããã¯åé¡åšã®æåã®ã¬ãã«ã®äŸã§èŠãããšãã§ããŸãïŒ
ãã®äŸã¯ã䜿çšãããXMLã«ä¿åãããæ å ±ã瀺ããŠããŸãã ããã¯ãåé¡åïŒhaarcascadeïŒãšãã®ãµã€ãºïŒãµã€ãºïŒã䜿çšã¬ãã«ïŒã¹ããŒãžïŒãå è¡ã¬ãã«ããŸãã¯ãã®ã¬ãã«ã®èŠªïŒèŠªïŒã次ã®ã¬ãã«ããŸãã¯ãã©ãã¯ãŒïŒæ¬¡ïŒãæ§ç¯ãããããªãŒïŒããªãŒïŒããã³ãã®ã«ãŒãããŒãïŒã«ãŒãããŒãïŒãã©ã¡ãŒã¿ãŒïŒãããå€ãå·Šãå³ïŒã 次ã«ããã®ããªãŒã®ããŒãå ã®ãã£ãŒãã£èªäœã«æ å ±ãæ§ç¯ãããŸããããã¯ãç¹å®ã®åŸæè§ïŒåŸæïŒãæã€ãã©ã¡ãŒã¿ãŒïŒåè§åœ¢ïŒãæã€åè§åœ¢ã§å®çŸ©ãããŸãã ããå ·äœçãªäŸã§ã¯ãäžè¬çãªæå³ã§ã¬ãã«ãšããªãŒã§åå²ããå¿ èŠãããããããã®ãããªããªãŒã®é·ãã¯9ã§ãã
åé¡åãã¡ã€ã«æ§é
ããã°ã©ã ã¢ã«ãŽãªãºã ã®äœæ¥ã®çµæãåºåã¯ä»¥äžã®ãªã¹ãã«ç€ºãæ§é ãæã€xmlãã¡ã€ã«ã«ãªããŸãã ãã¹ãŠã®xmlãã¡ã€ã«ã¯ãæ§é ãšDOMã¢ãã«ãåäžã«ãªããŸãã
<storage> <classifier1> <size></size> <stages> <_><!-- #of stage --> <trees> <_><!-- #of tree --> <_><!-- root node --> <feature> <rects><_></_><_></_></rects> <tilted></tilted> </feature> <threshold></threshold> <left_val></left_val> <right_val></right_val> </_></_></trees> <stage_threshold></stage_threshold> <parent></parent> <next></next> ⊠</_></stages> <_></classifier1> </storage>
æ°ããããŒã¿ã»ããã®æºå
åé¡åšããã¬ãŒãã³ã°ããã«ã¯ããããžãã£ããç»åã®å€§èŠæš¡ãªã»ãããšã倧ãŸãã«èšã£ãŠãç®çã®ãªããžã§ã¯ããšãã®èæ¯ã®ããã¬ãã£ããç»åã®å€§èŠæš¡ãªã»ãããå¿ èŠã§ãã æ¥çãè¡ããããªããžã§ã¯ããé 眮ãããŠããå Žæãã€ãŸãåé¡åãèšæ¶ããããã«ãã£ãŠåŠç¿ãã座æšã瀺ããããããã»ãããåããµã€ãºã§ããããšãéèŠã§ãã æ¥çãããšãæ°ããç»åã®ã»ãããååŸãããŸãã ç§ã®ããŒã¿ããŒã¹ããã®ãã®ãããªãæ¥çããããç»åã®äŸïŒ
ãã®ãããªãµã³ãã«ã¯createsamples.cppãã¡ã€ã«ã䜿çšããŠäœæããããã®ãã¡ã€ã«ã¯cvhaartrainig.hãããŒãããŠäœæ¥ããŸãã æšæºã®OpenCVã©ã€ãã©ãªããããããååŸããå¿ èŠã«å¿ããŠãå®æããããŸããã ãã®ãããªãµã³ãã«ãäœæããéã«ã¯ãå€ãã®æå®ããããã©ã¡ãŒã¿ãŒããããŸã;以äžã®ãªã¹ãã«ç€ºãããŠãããã®ã¯ç§ã䜿çšããŠããŸããããããã¯ãã¹ãŠã®ãã©ã¡ãŒã¿ãŒãšã¯ã»ã©é ãã§ãïŒ
void reateTrainingSamples( const char* filename,// , , const char* imgfilename,// int bgcolor, // int bgthreshold,// , 8- const char* bgfilename, // int count, int invert = 20,// int maxintensitydev = 40,// double maxxangle = 1.1,// X double maxyangle = 1.1, // Y double maxzangle = 0.5, // Z int showsamples = 0,// , int winwidth = 24,// int winheight = 24// );
ãã®çµæã.datãã¡ã€ã«ãããã«äœæãããããã§ãã®ãããªæ å ±ãèŠãããšãã§ããŸãïŒãããªãåŠçã®ããã«ãçµæã®ç»åã«ã¯ããŒã¯ããããã£ãŒãã£ã®åº§æšã«å¿ããååãä»ããããŸãã ãã®äŸã®æ°åã¯ãèŠã€ãã£ããªããžã§ã¯ãã®æ°ã5ã§ããããªããžã§ã¯ãã®ã€ã³ã¹ã¿ã³ã¹ã座æš{30ã49}ãå¹ ãšé«ã469ããã³250ã®é·æ¹åœ¢ã§èŠã€ãã£ãããšãæå³ããŸãã
../../ kalian2.png/0005_0030_0049_0469_0250.jpg 5 30 49 469 250
ãŸããOpenCVã§äœ¿çšãããã€ã¡ãŒãžãè¡šãããã«äœ¿çšããããã¡ã€ã«åãå«ã¿ãè¿œå ã®ã³ãŒãã䜿çšããŠå±éã§ãã.vecãã¡ã€ã«ãä»ããŠäœæããããšãã§ããŸãã ãããè¡ãã«ã¯ãaddVecãä»ããŠvecãã¡ã€ã«ã«æ å ±ãè¿œå ããŸãã
addVec (oldvecname, newvecname, samplwidth, samplheight);// , newvecname , , oldvecname, .
åé¡åšãã¬ãŒãã³ã°ã®ãã©ã¡ãŒã¿ãŒãšæ®µé
ãµã³ãã«ãäœæããåŸã®æ¬¡ã®ã¹ããŒãžã¯åé¡åã®ãã¬ãŒãã³ã°ã¹ããŒãžã§ãèšå®ãããã©ã¡ãŒã¿ãŒã¯æ¬¡ã®ãšããã§ãã
void reateCascadeClassifier( const char* dirname,// , const char* vecfilename,// vec- const char* bgfilename, // , int npos,// int nneg, // int nstages,// int numprecalculated,// , int numsplits,// , : 1 â , 2 - float minhitrate = 0.995F,// float maxfalsealarm = 0.5F,// float weightfraction = 0.95F,// , 90 int mode = 3,// , , . 0, BASIC â , -, , 2, ALL , 45 , 3 int symmetric = 1,// , , 0, int equalweights = 1,// 0, int winwidth = 24,// int winheight = 24,// int boosttype = 3,// , 0 â Discrete AdaBoost, 1 â Real AdaBoost, 2 â LogitBoost, 3 â Gentle AdaBoost int stumperror = 0 );// , Discrete AdaBoost
ãã®ã¹ãããã®çµæã¯ãããã«äœ¿çšã§ããèšç·Žãããåé¡åšã§ãã ç§ãéçºããŠããã¢ãžã¥ãŒã«ã§ã¯ãïŒç¹å®ã®ææ ã«ç¹æã®é¡ã®ç¹åŸŽããšã«ïŒå€ãã®åé¡åãé©çšãããŸãã åé¡åã¯é·ãéèšç·ŽãããŠããŸãã å¥ã®ã³ã³ãã¥ãŒã¿ãŒã§ãã¬ãŒãã³ã°ããŸããã ååé¡åã¯ãã³ã³ãã¥ãŒã¿ãŒã®èšç®èœåã匱ããªããŠãçŽ3æ¥éããããŸãã ç· ãåããããå Žåã¯ãããã«ä»äºã«åããããããšããå§ãããŸãã
⢠face_identify_classifier.xml â , ⢠eyes_identify_classifier.xml â , ⢠eyebrows_identify_classifier.xml â , ⢠mouth_identify_classifier.xml â , ⢠nose_identify_classifier.xml â , ... ⢠happysmile_kalian_classifier.xml â , ⢠happyeyes_kalian_classifier.xml â , , ⢠happyeyebrows_kalian_classifier.xml â , ⢠surprisingeyes_kalian_classifier.xml â , , ⢠openingmouth_kalian_classifier.xml â , ⢠surprisingeyebrows_kalian_classifier.xml â «» ( )
èªåææ èªèè£ çœ®
å ã®ç»åãå©çšå¯èœã«ãªããšããã«ãã¢ãžã¥ãŒã«ã¯ãã®äžã«ããç®çã®ãªããžã§ã¯ããèªåçã«èªèããŸãã ã¢ã¯ã·ã§ã³ã®ã·ãŒã±ã³ã¹èªäœã¯éåžžã«åçŽã«èŠããŸãããããã«ããããããã®æé ãå®è£ ããè€éããé ãããŸãã
ã€ã¡ãŒãžãããŒãããããªãœãŒã¹ãåæåãããããŒã¿ããŒã¹ã«æ¥ç¶ãããããã«åŠçããããã«ã€ã¡ãŒãžãæºåãããinitïŒïŒé¢æ°ãåæããŠã¿ãŸãããã
- æåã«ãç¹å¥ãªé¢æ°cvLoadïŒïŒã䜿çšããŠãæ€åºãšèªèã®ããã«äœæãããåé¡åãèªã¿èŸŒãŸãããããžã§ã¯ãã®haarcascadesãã©ã«ããŒã«é
眮ãããŸãïŒ... \ haarcascades \ïŒã 以äžã¯ãã¡ã¢ãª
storage = cvCreateMemStorage(0);
äœæã§ãstorage = cvCreateMemStorage(0);
ïŒ
// , , , void init(){// , // haarcascades cascade = (CvHaarClassifierCascade*)cvLoad( "haarcascades/mouth_disugst_classifier.xml" );// //cascade1 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/ eyes_identify_classifier.xml" );// cascade1 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/face_identify_classifier.xml" );// cascade7 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_frontalface_alt_tree.xml" );// cascade2 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_eye.xml" );// //cascade3 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_mcs_nose.xml" );// cascade3 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_kalian_nose.xml" );// cascade4 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_profileface.xml" );// // cascade5 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/smiled_01.xml" );//1 cascade8 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/smiled_02.xml" );//2 cascade9 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/smiled_03.xml" );//3 cascade10 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/smiled_04.xml" );//4 cascade6 = (CvHaarClassifierCascade*)cvLoad( "haarcascades/haarcascade_mcs_eyepair_big.xml" );// ... // storage = cvCreateMemStorage(0);
-
cvNamedWindow();
é¢æ°ã䜿çšããŸãcvNamedWindow();
ãŠã£ã³ããŠã衚瀺ãããããã«ç»åãšç»åäžã®æäœã®çµæã衚瀺ãããŸãã - ã«ã¡ã©ã䜿çšããå Žåãã«ã¡ã©ãããã£ããã£ããã³ãŒããå¿
èŠã§ãã
// CvCapture* capture = cvCreateCameraCapture(CV_CAP_ANY); //cvCaptureFromCAM( 0 ); assert( capture ); //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);//1280); //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);//960); // double width = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH); double height = cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT); printf("[i] %.0f x %.0f\n", width, height ); IplImage* frame=0; cvNamedWindow("capture", CV_WINDOW_AUTOSIZE); printf("[i] press Enter for capture image and Esc for quit!\n\n"); int counter=0; char filename[512]; while(true){ // frame = cvQueryFrame( capture ); // cvShowImage("capture", frame); char c = cvWaitKey(33); if (c == 27) { // ESC break; } else if(c == 13) { // Enter // sprintf(filename, "Image%d.jpg", counter); printf("[i] capture... %s\n", filename); cvSaveImage(filename, frame); counter++; }
- ãã®ããã°ã©ã ã«ã¯ãç»åãŸãã¯ç»åã®é
åãã¡ã¢ãªã«é 次ããŒãããããµã€ã¯ã«ãå«ãŸããŸãã
image = cvLoadImage( array_1[j], 1 ); printf("\n[i] Image loaded\n", image); assert( image!= 0 );
ããŒã¿ãããŒã¿ããŒã¹ã«ä¿åãããŠããå Žåããã®æ®µéã§å¿ èŠãªmysql.hããããŒãããŒã¿ããŒã¹ã«æ¥ç¶ãããå¿ èŠã«å¿ããŠããŒã¿ããŒã¹ããã¡ã¢ãªãžã®ããŒã¿ã®äºåæ¥ç¶ãšããŒããè¡ãããŸãã
#include <mysql.h> ⊠// void comlinePrint(char *); ⊠// MYSQL conn; // MYSQL_RES *res; // MYSQL_ROW row; // if(!mysql_init(&conn)) comlinePrint("Error: MySql - \n"); // if(!mysql_real_connect(&conn,"localhost","kalian","","user",0,NULL,0)) comlinePrint("Error: SQL \n"); // , // if(mysql_query(&conn, "SET NAMES 'cp1251'") != 0) { // - // comlinePrint ("Error: \n"); exit(1); } // if(mysql_query(&conn,"INSERT INTO `user` VALUES(NULL, '', '','', 22, '', '','') ") != 0) { // - // comlinePrint ("Error: \n"); exit(1); } void comlinePrint(char * str) { printf(stderr, str); exit(1); } // mysql_close(&conn);}
- 次ã«ãç»åã®ãµã€ãºãå€æŽããŸãã ç»åã®å¹
ãšé«ãããã§ãã¯ãããæ¡ä»¶ã«å¿ããŠãç»åãnåå¢å ãŸãã¯æžå°ããŸãã
if(image->width>700 && image->height>700){ resPic = cvCreateImage( cvSize(image->width/1.5, image->height/1.5), image->depth, image->nChannels ); cvResize(image, resPic, 1); cvShowImage("resizing", resPic); printf ("\n[i] Image has been resized", image); comlinePrint(); else if(image->width<200 && image->height<200){ resPicMal = cvCreateImage( cvSize(image->width*2, image->height*2), image->depth, image->nChannels ); cvResize(image, resPicMal, 1); cvShowImage("resizing", resPicMal);
ãã®åŸãç»åã¯ã¢ãžã¥ãŒã«ã®ã¡ã€ã³ãµã€ã¯ã«ã«åé¡ãããŸãã ç§ãéçºããèªèæ¹æ³ã®äž»ãªä»äºã¯ã次ã®é åºã§æ©èœã«åããããŸãã
- imageGrayïŒïŒ; //ãœãŒã¹ç»åãã°ã¬ãŒã¹ã±ãŒã«ã«å€æ
- SobelPreparationïŒresPicãdst2ïŒ; // Sobelãªãã¬ãŒã¿ãŒã«ããåæåŠç
- OtsuThresholdPreparationïŒresPicãots1ãots2ïŒ; // Otsuäºå€å
- ImageCannyPreparationïŒresPicãdstïŒ; // Cannyæ€åºåšã«ããå¢çç·ã®éžæïŒçµæã¯cvSubã®ã¹ã¯ãªãŒã³ã·ã§ããã«è¡šç€ºãããŸãïŒ
- dilateïŒïŒ; //èŠã€ãã£ãå¢çã®å€ªã*-䜿çšã§ããŸãããã»ãšãã©ã®å Žåããã®é¢æ°ã䜿çšããããã°ã©ã ãã¹ãã®çµæã«ããã°ãçµæã¯æ¹åããããå Žåã«ãã£ãŠã¯ãããªãã§ããã«æªåããŸã
- cvSubïŒgrayãimg1ãimg1ïŒ; //ãªãªãžãã«ãããã€ããªãåŒããŸã
- detect_and_drawïŒresPicïŒ; //ç»åå ã®é¡ãšãã®ç¹åŸŽã®èå¥
- RecognitionResultïŒresPicïŒ; //ææ ã®èšç®
- cvShowImageïŒïŒresPicïŒ; //èªèçµæ
- ïŒcvWaitKeyïŒ1000ïŒïŒ; //ããŒã¹ãããŒã¯ãåŸ ã€
- cvReleaseImageïŒïŒresPicïŒ//ã¡ã¢ãªãªãœãŒã¹ã解æŸãã
é¡ãšãã®æ©èœãæ€åºããããã®æ§æå¯èœãªãã©ã¡ãŒã¿ãŒ
- ç»åæºåæ©èœèªåã§åé¡ãªãæžãããšãã§ãããšç¢ºä¿¡ããŠããŸãã OpenCVã®å®è£ é¢æ°ã¯ã䜿çšãããã¢ã«ãŽãªãºã ã®ååãšåãååãæã£ãŠãããããå段éã§ã®ããã°ã©ã ã®ã¹ã¯ãªãŒã³ã·ã§ããã®ã¿ãæäŸãããŸãã ããããæåŸã«ã³ãŒããæ·»ä»ããŸããã
- ã¢ãžã¥ãŒã«å
ã®ç®çã®ãªããžã§ã¯ãã®æ€çŽ¢ã¯ã detect_and_drawïŒresPicïŒé¢æ°ã䜿çšããŠå®è¡ãããŸãããã®é¢æ°ã®æ¬äœã§ã¯ãé
åãæåã«èšå®ãããåè§åœ¢ã®è²ãå«ãŸããŸãã 次ã«ã cvHaarDetectObjectsïŒïŒé¢æ°ã䜿çšããŠã 人ç©ã®é¡ãé¡ã®ç¹åŸŽã«å¯Ÿå¿ããç»åå
ã®ãã¹ãŠã®ã»ã¯ã·ã§ã³ããªããžã§ã¯ãã·ãŒã±ã³ã¹ã«è¿ãããŸã ã ã³ãŒãã§ã¯ã次ã®ããã«ãªããŸãã
CvSeq* objects1 = cvHaarDetectObjects( img, cascade1, storage, 1.1, 4, 0|CV_HAAR_DO_CANNY_PRUNING, cvSize( 10, 20 ));// /* CvSeq: CvSeq* cvHaarDetectObjects( const CvArr* image,// , CvHaarClassifierCascade* cascade,// CvMemStorage* storage,// double scale_factor = 1.1,// int min_neighbors = 4,// int flags = 0|CV_HAAR_DO_CANNY_PRUNING,// CvSize min_size = cvSize(0,0)// ); */
é¢æ°ã®åäœãããã³ã¢ãžã¥ãŒã«å šäœã®çµæã¯ããã©ã¡ãŒã¿ãŒcvHaarDetectObjectsïŒïŒã«äŸåããŸãã
æå°é£æ¥ãããå€ã¯ãé¡ã®åéšåã®åŒ·åºŠã§ãã ãããå€ããªããšãæ€åºåšã¯åãèªèã®å€ãã1ãæã§çæãããããæåã§æ§æããå¿ èŠããããŸãã éåžžãå€ç«ããæ€åºã¯åœã§ããããã ããããç Žæ£ããããšã¯çã«ããªã£ãŠããŸã ã ãŸããåé¡é åã®è€æ°ã®æ€åºãåäžã®ãšã³ãã£ãã£ã«çµåããããšãçã«ããªã£ãŠããŸã ã
OpenCVã¯ãæ€åºããããªããžã§ã¯ãã®ãªã¹ããè¿ãåã«ããããã®æ¡ä»¶ã®äž¡æ¹ãå®è¡ããŸãã
ããŒãžæé ã¯ãæåã«å€æ°ã®éè€ãå«ãé·æ¹åœ¢ãã°ã«ãŒãåãã次ã«ã°ã«ãŒãã®å¹³åé·æ¹åœ¢ãèŠã€ããŸãã
次ã«ãã°ã«ãŒãå ã®ãã¹ãŠã®é·æ¹åœ¢ããèšç®ãããäžå€®ã®é·æ¹åœ¢ã«çœ®ãæããããŸãã
å€ç«ããé·æ¹åœ¢ãšå€§ããªã°ã«ãŒãã®éã«ã¯ãé¡ãšèª€æ€åºã®äž¡æ¹ã«ãªãåŸãå°ããªã°ã«ãŒãããããŸãã
æå°é£æ¥ãããå€ã¯ãã°ã«ãŒãå ã®æªåŠçã®æ€åºæ°ã«å¿ããŠãé·æ¹åœ¢ã®ã°ã«ãŒããç Žæ£ãŸãã¯ä¿åããããã®ã¯ãªããã³ã°ã¬ãã«ãèšå®ããŸãã ããã©ã«ãã§ã¯ããã®ãã©ã¡ãŒã¿ãŒã¯3ã§ããããã¯ã3ã€ä»¥äžã®é·æ¹åœ¢ã®ã°ã«ãŒããããŒãžããé·æ¹åœ¢ãå°ãªãã°ã«ãŒããç Žæ£ããããšãæå³ããŸãã å€æ°ã®é¡ãšé¡ã®ç¹åŸŽã®èªèãèããäžè¶³ããŠããå Žåã ãããå€ãããå°ããªæ°ã«æžããå¿ èŠããããŸã ã ãŒãã«èšå®ãããŠããå Žåãé¢æ°ã¯Haaråé¡åã®æªå å·¥æ€åºã®å®å šãªãªã¹ããè¿ããŸãã
æå°ã¹ã±ãŒã«ãããã©ã«ãå€ãã倧ããããããã«ããã®ãã©ã¡ãŒã¿ãŒã«æ°ããå€ãèšå®ã§ããŸãã æšæºä»¥å€ã®å€ã䜿çšããå Žåã¯ãæšæºã®æ¯çïŒå¹ ãšé«ãã®æ¯çïŒãç¶æãããããã«ããå¿ èŠããããŸãã ãã®å Žåãã¢ã¹ãã¯ãæ¯ã¯1ïŒ1ã«ãªããŸãã
é¢æ°ã®4çªç®ã®ãã©ã¡ãŒã¿ãŒã¯ãOpenCVãç»åãééãããã³ã«é¡æ€åºã®ããã«ãºãŒã ã€ã³ããé床ã決å®ããŸãã ãããããé«ãå€ã«èšå®ãããšãæ€åºåšã®åäœãéããªããŸãïŒã¹ãã£ã³ãŠã£ã³ããŠã®ãã¹ãå°ãªããªãããïŒããã ããæå°ã¹ã±ãŒã«ãé«ãããå Žåãã¹ã±ãŒã«ãšæ¬ èœããé¢ã®éã®é·ç§»ãéãããå¯èœæ§ããããŸãã ããã©ã«ãã§ã¯ãOpenCVã§ã¯ããã®ãã©ã¡ãŒã¿ãŒã®å€ã¯1.1ã§ããã€ãŸããã¹ã±ãŒã«ã¯ãã¹ããšã«1.1åïŒ10ïŒ ïŒå¢å ããŸãã
cvHaarDetectObjectïŒïŒé¢æ°ã®ãã©ã°å€æ°ã¯ãããã€ãã®å€ãåãããšãã§ããŸãã
- 0;
- CV_HAAR_DO_CANNY_PRUNING;
- CV_HAAR_FIND_BIGGEST_OBJECT;
- CV_HAAR_DO_ROUGH_SEARCH;
- CV_HAAR_DO_CANNY_PRUNING;
- CV_HAAR_SCALE_IMAGE.
ãå®çšçãªã¯ãããããã©ã°ãéžæãããŠããå ŽåïŒ0 | CV_HAAR_DO_CANNY_PRUNINGïŒãæ€åºåšã¯ãé¡ãå åŽã«ããå¯èœæ§ãäœãç»åã®é åãã¹ãããããŸããããã«ãããèšç®æéãççž®ããã誀æ€åºãæé€ãããŸãã ã¹ããããããé åã¯ãé¡æ€åºåšãèµ·åããåã«ç»åå šäœã§ãã®ãããªãäžèŠãªããšããžãæ€åºããæ€åºåšã«ãã£ãŠèå¥ãããŸãã ç¹°ãè¿ãã«ãªããŸããããã®ã¿ã€ãã®ãã©ã°ãèšå®ããããšã¯ãé床ãéžæããããããå€ãã®é¡ãèŠã€ãããã®åŠ¥åç¹ã§ãã ãã©ã°ãèšå®ãããšåŠçé床ã¯åäžããŸãããäžéšã®å人ãã¹ããããããå¯èœæ§ããããŸãã
é¡ã®çž®å°ºã¯æ±ºå®ãããªããããæ€çŽ¢ãå®è¡ããæå°ãµã€ãºã¯ã§ããã ãå°ããèšå®ããå¿ èŠããããŸãã ããã©ã«ãã§ã¯ãïŒ0ã0ïŒã§ããããã¯ãåé¡åxml-fileã«èšè¿°ãããŠããã¹ã±ãŒã«ã䜿çšããããšãæå³ããŸãã
誀ã£ãŠéžæãããæ€çŽ¢ãã©ã¡ãŒã¿ãŒã䜿çšãããäžååãªèšç·Žãåããåé¡åšã®æ®µéã§ã®é¡èªèã®äžè¯ã®äŸïŒ
ããèšç·Žãããåé¡åšã®æ®µéã§ã®è¯å¥œãªé¡èªèã®äŸïŒ
- é¢æ°èªèçµæïŒresPicïŒ; detect_and_drawïŒresPicïŒé¢æ°ã§æ©èœããåé¡åã®ã¿ã€ãã«é¢ããæ
å ±ãæž¡ãããŸãã ã€ãŸããã©ã®ãªããžã§ã¯ããèŠã€ãã£ããã ãããŠãèŠã€ãã£ãåé¡åãææ
ãªã©ã®æ¡ä»¶ãæºããå Žåãææ
ãå®çŸ©ãããŠãããšããæ
å ±ã衚瀺ãããŸãã
ããšãã°ã次ã®åé¡åãæ©èœããå ŽåïŒ
⢠happysmile_kalian_classifier.xml, ⢠happyeyes_kalian_classifier.xml, ⢠happyeyebrows_kalian_classifier.xml
-ããã¯åã³ã®ææ ã§ãã
-ææ ïŒ -ã¯ã!!!
ã¢ãžã¥ãŒã«ããã³ã¢ã«ãŽãªãºã ã®ãã¹ã
ã¢ã«ãŽãªãºã ã®å¹çãšé床ããã¹ãããããã«ããã£ã±ãã«ãªã£ãEmotionDBããŒã¿ããŒã¹ïŒ15ã€ã¡ãŒãž-ãã¹ãçšã§ã¯ãªãïŒãšããŒã«ã«ãã£ã¬ã¯ããªå ã®ã€ã¡ãŒãžã®åçŽãªé åïŒ10ã€ã¡ãŒãžïŒã䜿çšããŠãã¹ããã¹ããå®è¡ããŸããã ããŒã¿ããŒã¹ãšé åå ã®ç»åããŒã¿ã¯ãµã€ãºãç°ãªããè²ããããçœé»ã®åçãããããã®äžã«äººã®æ°ãç°ãªã£ãŠããŸãã
ãã¹ãã§ã¯ãçµã¿èŸŒã¿ã®OpenCV performance.cppãã¡ã€ã«ã䜿çšãããŸããããã¹ãŠã®ããŒã¿ãèšç®ããã ROCæ²ç·ãäœæãããŸãã åé¡åšã®ã¹ããŒãžãŸãã¯ã¹ããŒãžã®ã«ãŠã³ãã®äŸïŒ
int* numclassifiers = new int[cascade->count]; numclassifiers[0] = cascade->stage_classifier[0].count; for( i = 1; i < cascade->count; i++ ) { numclassifiers[i] = numclassifiers[i-1] + cascade->stage_classifier[i].count; }
ãã¹ããããäžé£ã®ç»åã«ã¯åŸæããé¡ããããšããäºå®ã«ãããããããã¢ã«ãŽãªãºã ã¯ãã®ãããªé¡ãã¹ãããããŠèå¥ããŸããããé¡ãåŸæããŠããªãåçŽãªå Žåãããäœéã§æ€åºãæ©èœããŸãã ç §æãäžååã§ãç®çã®ãªããžã§ã¯ãã®èæ¯ãšå€§ããçµåãããã€ãºãç»åã®ãã€ãºãšå¹²æžããç¶æ³ã§ã¯ãã¢ãžã¥ãŒã«ã¯æšæºã®Viola-Jonesã¢ã«ãŽãªãºã ãšãšãã«éåžžã®ç»åããããã£ãããšåäœããŸãã
ãªããžã§ã¯ãã®èŠèªæ§ãäœãïŒèæ¯ãšæ··åããïŒç¶æ³ã§ã¯ãã¢ãžã¥ãŒã«ã¯ãææ¡ãããç»åååŠçã¡ã«ããºã ã®äœ¿çšã«ãããèªèã«ããŸã察å¿ããŸãã
ãã®è¡šã¯ãã¢ã«ãŽãªãºã ã®ãã¹ãçµæãšãViola-Jonesã¢ã«ãŽãªãºã ã®ç²ŸåºŠãOpenCVã©ã€ãã©ãªã®åºæ¬ã»ããããã³é¡èªèçšã®èšç·Žãããã»ãããå«ãå€æŽãããViola-Jonesãš
æ¯èŒããŠããŸããã¢ã«ãŽãªãºã æ¯èŒçµæ
ã¢ã«ãŽãªãºã /ããŒã¿ | Viola-Jones OpenCV | EmoRecïŒæºå+ Viola-Jones + OpenCVïŒ |
---|---|---|
ç»åã®é åïŒ10åïŒ | 89ïŒ ãçŽ7ç§ïŒ7475ããªç§ïŒ | 93ïŒ ãçŽ7ç§ïŒ7412ããªç§ïŒ |
DB EmotionDBïŒ15åïŒ | 92ïŒ ãçŽ12ç§ïŒ12167ããªç§ïŒ | 94ïŒ ãçŽ12ç§ïŒ11870ããªç§ïŒ |
*-æ€åºã®å²åãã¹ããŒãžæ°ïŒã¹ãããïŒãé¡ã®æ€åºã«è²»ããããåèšæé |
çµè«
人ã®é¡ãæ€åºãããšãã®éçºãããã¢ã«ãŽãªãºã ã®é床ã¯ããã»ã©å€§ãããããŸããããåºæ¬çãªã¢ã«ãŽãªãºã ã®é床ãè¶ ããŸããããã¹ãçµæãç°ãªããšçµæãç°ãªããŸããè¡šã¯å¹³åå€ã瀺ããŠããŸããæ®å¿µãªãããå·¥æ¥èŠæš¡ã§ã¯ãªããããªãå€ãã³ã³ãã¥ãŒã¿ãŒãã©ãããããã§ã¯ãå®å šãªãã¹ããåçŸããããšã¯ã§ããŸãããããã¯æãŸãããªãããšã§ãã
ãã®ããã°ã©ã ã«ãããšãåçã®ååŠçã«ã¯å€ãã®æéãããããŸãïŒçŽ250ã300ããªç§ïŒããã³ãŒãããªãã¡ã¯ã¿ãªã³ã°ããå¿ èŠããããŸããæåæ€åºã«ã¯å¹³åã§çŽ400ããªç§ããããŸããææ ã®å®çŸ©ã«ãããæéã¯ã»ãšãã©ããããŸãããé¢æ°ãæ©èœããåé¡åã®ã¿ã€ãã決å®ããéåžžã«éãçµæãããããããã§ãã
æåŸãŸã§èªãã 人ãžã®è³ªå
- Viola Jonesã¢ã«ãŽãªãºã ãšãã®ã¢ããªã±ãŒã·ã§ã³ãå®å šã«ã«ããŒããŠããããšãå€æããŸãããïŒ
- æãåãããæ®éã«èªã¿ãŸããïŒ
- ãã£ãšæžãïŒ
- æžç±ããµã€ãã®éžæããããŸããèšäºãæžãããŠãããšããç§ã¯ããã調ã¹ãŠãæ£ããèšäºãèŠã€ããããäœãèŠã€ããŸããã§ãããããããç§ã¯ãŸã ããŒãžãžã®ãã€ã³ã¿ãšãã©ãŒã©ã ããµã€ããžã®ãªã³ã¯ãæã£ãŠããŸããããããå¥ã®ãããã¯ã«ããŠãHabrã«é 眮ããŸããïŒ
ã¿ããªããããšãïŒãã£ãšèªãïŒæããŸããŠããã§ãšãããããŸãïŒSkyNoName
PSã§ããããã®ä»¶ã«é¢ããããªãã®æ¹å€ãšè³ªåãåŸ ã£ãŠããŸãïŒãŸãããŸãã¯ããªãã®ãããããšãããå°ãªããšãäœããã®åœ¢ã§è³æãããªããå©ãããªã...