情绪检测数据集

时间:2013-03-11 05:10:17

标签: c++ opencv

我正在使用opencv库编写代码,该库跟踪用户的脸部和脸部特征。我已经设法对网络进行实时检测以及来自网络摄像头的眼睛,嘴唇等功能。我现在想从检测到的特征中提取情绪。我想知道是否有任何可用的数据集可以用来比较情绪以及它是如何完成的。

这是面部检测的代码

    CvRect detectFaceInImage(const IplImage *inputImg, const CvHaarClassifierCascade* cascade )
{
    const CvSize minFeatureSize = cvSize(20, 20);
    const int flags = CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH;    // Only search for 1 face.
    const float search_scale_factor = 1.1f;
    IplImage *detectImg;
    IplImage *greyImg = 0;
    CvMemStorage* storage;
    CvRect rc;
    double t;
    CvSeq* rects;
    int i;

    storage = cvCreateMemStorage(0);
    cvClearMemStorage( storage );

    // If the image is color, use a greyscale copy of the image.
    detectImg = (IplImage*)inputImg;    // Assume the input image is to be used.
    if (inputImg->nChannels > 1) 
    {
        greyImg = cvCreateImage(cvSize(inputImg->width, inputImg->height), IPL_DEPTH_8U, 1 );
        cvCvtColor( inputImg, greyImg, CV_BGR2GRAY );
        detectImg = greyImg;    // Use the greyscale version as the input.
    }

    // Detect all the faces.
    t = (double)cvGetTickCount();
    rects = cvHaarDetectObjects( detectImg, (CvHaarClassifierCascade*)cascade, storage,
                search_scale_factor, 3, flags, minFeatureSize );
    t = (double)cvGetTickCount() - t;
    printf("[Face Detection took %d ms and found %d objects]\n", cvRound( t/((double)cvGetTickFrequency()*1000.0) ), rects->total );

    // Get the first detected face (the biggest).
    if (rects->total > 0) {
        rc = *(CvRect*)cvGetSeqElem( rects, 0 );
    }
    else
        rc = cvRect(-1,-1,-1,-1);   // Couldn't find the face.

    //cvReleaseHaarClassifierCascade( &cascade );
    //cvReleaseImage( &detectImg );
    if (greyImg)
        cvReleaseImage( &greyImg );
    cvReleaseMemStorage( &storage );

    return rc;  // Return the biggest face found, or (-1,-1,-1,-1).
}

1 个答案:

答案 0 :(得分:6)

我正在使用Karolinska Directed Emotional Faces(KDEF)照片进行教育研究项目。有关数据集的信息可在http://www.emotionlab.se/resources/kdef获得。

请注意,您可能需要裁剪,调整大小,居中,拉直和标准化图像,以便与OpenCV一起使用。一旦准备好,图像与所有OpenCV2 FaceRecognizer类函数都能很好地工作。

关于如何进行面部表情识别:不存在标准方法。首先阅读FaceRecognizer文档并完成教程。值得一提的是:我发现使用局部二值模式直方图可以得到最准确的结果。