2017-08-18 33 views
0

我是Affectiva情感识别SDK的新手。我一直在从this link的视频后面的例子,但是当我提供一些图片示例this image时,脸部无法被检测到。 我的代码如下: -使用Offline 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("/home/mitiku/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 hereenter image description here

回答

2

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

编辑:

这两个图像为250x250和260x194,真正的低质量。我建议你使用更高分辨率的图像测试应用程序。由于Affectiva在他们的网页中声明,建议的最低分辨率为320x240,脸部应该至少为30x30。 https://developer.affectiva.com/obtaining-optimal-results/

+0

是的,大多数时候sdk并没有检测到人脸。 – Mitiku

+0

这并不常见。你能分享一些脸部未被检测到的图像吗? –