我是 Affectiva 情感识别 SDK 的新手。我一直在关注来自 this link 的视频中的示例但是当我提供一些图片示例时 this image无法检测到人脸。 我的代码看起来:-
Listener
class Listener : public affdex::ImageListener{
void onImageResults(std::map<affdex::FaceId,affdex::Face> faces,affdex::Frame image){
std::string pronoun="they";
std::string emotion="neutral";
for (auto pair : faces){
affdex::FaceId faceId=pair.first;
affdex::Face face=pair.second;
if(face.appearance.gender==affdex::Gender::Male){
pronoun="Male";
}else if(face.appearance.gender==affdex::Gender::Female){
pronoun="Female";
}
if(face.emotions.joy>25){
emotion="Happy :)";
}else if(face.emotions.sadness>25){
emotion="Sad :(";
}
cout<<faceId<<" : "<<pronoun <<" looks "<< emotion <<endl;
}
}
void onImageCapture(affdex::Frame image){
cout<<"IMage captured"<<endl;
}
};
主要代码
Mat img;
img=imread(argv[1],CV_LOAD_IMAGE_COLOR);
affdex::Frame frame(img.size().width, img.size().height, img.data, affdex::Frame::COLOR_FORMAT::BGR);
affdex::PhotoDetector detector(3);
detector.setClassifierPath("/xxx/xxx/affdex-sdk/data");
affdex::ImageListener * listener(new Listener());
detector.setImageListener(listener);
detector.setDetectAllEmotions(true);
detector.setDetectAllExpressions(true);
detector.start();
detector.process(frame);
detector.stop();
我哪里出错了?或者是sdk无法从某些图像中检测到人脸?有谁能够帮助我?
编辑 我用了下面的图片
最佳答案
有时 SDK 无法检测图像中的人脸。没有一种检测器可以一直检测到所有的人脸。你检查过不同的图像吗?
编辑:
这两张图片分别为 250x250 和 260x194,质量非常低。我建议您使用更高分辨率的图像来测试该应用程序。正如 Affectiva 在其网页中所述,推荐的最低分辨率为 320x240,人脸应至少为 30x30。 https://developer.affectiva.com/obtaining-optimal-results/
关于c++ - 无法使用 Offline Affectiva SDK 检测人脸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45755570/