gpt4 book ai didi

c++ - 情绪检测数据集

转载 作者:太空宇宙 更新时间:2023-11-03 21:58:40 25 4
gpt4 key购买 nike

我正在使用 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).
}

最佳答案

我正在使用卡罗林斯卡定向情绪面孔 (KDEF) 照片进行教育研究项目。有关数据集的信息,请访问 http://www.emotionlab.se/resources/kdef。 .

请注意,您可能需要裁剪、调整大小、居中、拉直和规范化图像才能将它们用于 OpenCV。一旦准备好,图像就可以很好地与所有 OpenCV2 FaceRecognizer 类函数一起使用。

至于如何进行面部表情识别:不存在标准方法。首先阅读 FaceRecognizer 文档并完成教程。物有所值:我发现使用局部二进制模式直方图可以产生最准确的结果。

关于c++ - 情绪检测数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15331573/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com