OpenCVã®ä½¿ãæ¹(8) é¡æ¤åºãè¡ã£ã¦ã¿ã
çããããã«ã¡ã¯
ãå
æ°ã§ãããç§ã¯å
æ°ã§ãã
ãã¦ãä»æ¥ã¯OpenCVã§é¡æ¤åºãè¡ã£ã¦ã¿ã¾ãã
é¡æ¤åºã¨ã¯ãç»é¢ã®ä¸ããé¡ãæ¤åºããã¿ã¹ã¯ã®ãã¨ã§ãã
æ©éã§ãããã½ã¼ã¹ã³ã¼ããæ¸ãã¦ã¿ã¾ããã
#include <opencv2/opencv.hpp> #include <iostream> using namespace std; using namespace cv; Mat detectFaceInImage(Mat &image,string &cascade_file){ CascadeClassifier cascade; cascade.load(cascade_file); vector<Rect> faces; cascade.detectMultiScale(image, faces, 1.1,3,0,Size(20,20)); for (int i = 0; i < faces.size(); i++){ rectangle(image, Point(faces[i].x,faces[i].y),Point(faces[i].x + faces[i].width,faces[i].y + faces[i].height),Scalar(0,200,0),3,CV_AA); } return image; } int main(int argc, char const *argv[]){ Mat image = imread(argv[1]); string filename = argv[2]; Mat detectFaceImage = detectFaceInImage(image, filename); imshow("detect face",detectFaceImage); waitKey(0); return 0; }
ã½ã¼ã¹ã³ã¼ãã®è§£èª¬ã§ããã第ä¸å¼æ°ã«åçã第äºå¼æ°ã«å¦ç¿ãããèå¥å¨ãå
¥ãã¾ãã
ãã®èå¥å¨ã§ãããOpenCVã®ãã£ã¬ã¯ããªã«å«ã¾ãã¦ãã¾ãã
以ä¸ã®ãµã¤ãã«ããã¨ãhaarç¹å¾´éã¨å©ç¨ããæ½åºã¨lbpç¹å¾´ãå©ç¨ããç¹å¾´ãããããã§ããã
精度ãé«ãã®ã¯haarã§ãé度ãé«éãªã®ã¯lbpç¹å¾´ã ããã§ãã
opencv - Haar Cascades vs. LBP Cascades in Face Detection - Stack Overflow
å®éã«é¡æ¤åºãè¡ã£ã¦ã¿ã¾ããå ãã¯Lennaãã
ãªãããã¾ããã£ã¦ãã
次ã¯è¤æ°ã®é¡ãæ¤åºã§ãããè¡ã£ã¦ã¿ã¾ãã
é¦ãã²ãã£ãé¡ã¨ããè¥å¹²é ãã¦ããé¡ããã¦ãã¢ãã¡ç»åã¯æ¤åºã§ããªãããã§ãã
ã¢ãã¡ç»åã§éã³ããã¨æã£ãçãããå®ã¯ã¢ãã¡ç»åç¨ã®èå¥å¨ãããã¾ãã
nagadomi/lbpcascade_animeface · GitHubã«ããã¦ããã¾ãããããåå¾ãã¾ããããããã¦ãå度ãé¡æ¤åºãè¡ã£ã¦ã¿ã¾ãã
çµµéã¡ãã以å¤ã¯æ¤åºã§ãã¦ãã¾ããæ°ã®ãããæªãã¨ããã«èå¥ã§ãã¦ããªãæ°ãããã
ãããªæãã§é¡æ¤åºãã§ãã¾ããé¡èªèã¿ã¹ã¯ã¨ããæãã§ãããææ¦ãããã¨æãã¾ãã