c++ - 无法使用 Offline Affectiva SDK 检测人脸

标签 c++ affdex-sdk

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

编辑 我用了下面的图片

enter image description here enter image description here

最佳答案

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

编辑:

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

关于c++ - 无法使用 Offline Affectiva SDK 检测人脸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45755570/

相关文章:

c++ - 如何编写同时接受 && 和 const& 的模板函数?

c++ - 等待多个互斥锁的条件变量

c++ - Affectiva情感SDK - 调用.setLicensePath()和setClassifierPath()时抛出异常

javascript - 如何使用 Emotion SDK for Javascript 批量处理视频文件

javascript - Affdex JS SDK - 无法从相机检测器获取回调

c++ - CoCreateInstance 使用 CLSCTX_LOCAL_SERVER 是否足以确保所有应用程序共享 COM 对象实例?

c++ - 在 C++ 中销毁动态分配的内存(数组对象)

c++ - 一个对象怎么知道它是分配在栈上还是堆上呢?

c++ - Affdex 'opencv-webcam-demo' 在 Ubuntu 16.04 中崩溃

ios - 使用相机时从不调用 Affdex AFDXDetector 委托(delegate)函数?