0

我是 Affectiva 情感识别 SDK 的新手。我一直在关注此链接中视频的示例但是当我提供一些图片示例时,无法检测到该图像的面部。我的代码看起来: -

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 无法从某些图像中检测到人脸?有谁能够帮助我?

编辑我使用了以下图片

在此处输入图像描述在此处输入图像描述

4

1 回答 1

2

有时 SDK 无法检测图像中的人脸。没有一个检测器可以一直检测所有的人脸。你检查过不同的图像吗?

编辑:

这两张图片是 250x250 和 260x194,质量非常低。我建议您使用更高分辨率的图像测试应用程序。正如 Affectiva 在其网页中指出的那样,建议的最低分辨率为 320x240,人脸至少应为 30x30。 https://developer.affectiva.com/obtaining-optimal-results/

于 2017-08-21T01:57:40.580 回答