Android- face Recognition using openCV?

為{幸葍}努か 提交于 2019-12-03 09:05:18
a.bertucci

Well, my colleagues and I did some investigation on face recognition last year, and these are some of ours considerations about using integrated recognition tools vs JavaCV (the Java bindings for OpenCV):

Please check below tutorials

  1. Face Detection on Andriod Part-I ( Wayback link )
  2. Face Detection on Andriod Part-II ( Wayback link )

Hope it helps :)

you can use NDK for using C/C++ OpenCV API

docs
beginner tutorial


void DetectMyFace ()
{
    // image structure in opencv
    IplImage *inImg = 0;
    // face detector classifer 
    CvHaarClassifierCascade *clCascade = 0;
    CvMemStorage *mStorage = 0;
    CvSeq *faceRectSeq;

    inImg = cvLoadImage("2.jpg");

    mStorage = cvCreateMemStorage(0);
    clCascade = (CvHaarClassifierCascade *)cvLoad("haarcascade_frontalface_default.xml", 0, 0, 0);

    if ( !inImg || !mStorage || !clCascade ) 
    {
        printf("Initilization error : %s" , (!inImg)? "cant load image" : (!clCascade)? 
            "cant load haar cascade" : 
            "unable to locate memory storage");

        return;
    }

    faceRectSeq = cvHaarDetectObjects(inImg,clCascade,mStorage,
        1.2,
        3,
        CV_HAAR_DO_CANNY_PRUNING,
        cvSize(25,25));


    const char *winName = "Display Face";
    cvNamedWindow(winName,CV_WINDOW_AUTOSIZE);  

    for ( int i = 0; i < (faceRectSeq ? faceRectSeq -> total:0); i++ )
    {

        CvRect *r = (CvRect*)cvGetSeqElem(faceRectSeq,i);
        CvPoint p1 = { r->x, r->y };
        CvPoint p2 = { r->x + r->width, r->y + r->height };

        cvRectangle(inImg,p1,p2,CV_RGB(0,255,0),1,4,0);     
    }

    cvShowImage(winName, inImg);
    cvWaitKey(0);   

    cvDestroyWindow(winName);

    // release the variables 
    cvReleaseImage(&inImg);
    if(clCascade) cvReleaseHaarClassifierCascade(&clCascade);
    if(mStorage)  cvReleaseMemStorage(&mStorage);
}

I have already made an Android app for Face Recognition using OpenCV. You can check it out: https://github.com/yaylas/AndroidFaceRecognizer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!