Unable to Initialise affdex

cpp

#1

We are unable to use imagemagick to process images in cpp any possible help will be highly appreciated.
For timebeing we used our own pixels array to initialise and when we run it we find an error which states.

terminate called after throwing an instance of 'affdex::AffdexException’
what(): Failed to initialize: Unable to initialize affdex
Aborted (core dumped)

We have attached the cpp file for the above error.

#include
#include “PhotoDetector.h”

using namespace std;

class Listener : public affdex::ImageListener {
void onImageResults(std::map< affdex::FaceId, affdex::Face> faces, affdex::Frame image) {
std::cout << "Found Faces "<< faces.size() << std::endl;

    for(auto pair : faces) {
    	std::string pronoun = "they";
     	std::string emotion = "neutral";
     	affdex::Face face = pair.second;

    	if(face.appearance.gender == affdex::Gender::Male){
        	pronoun = "He";
    	} else if(face.appearance.gender == affdex::Gender::Female){
        	pronoun = "She";
       	}
    
    	if(face.emotions.joy > 25 ) {
        	emotion = "Happy";
    	} else if(face.emotions.sadness > 25 ) {
        	emotion = "Sad";
    	}
    	std::cout << face.id <<" ; "<< pronoun << " Looks " <<  emotion << std::endl;

	}

};
	void onImageCapture(affdex::Frame image){};

};

int main(int argc, char ** argsv) {
int pixels[] = {
0,0,65535,65535,65535,
1,0,11051,11051,11051,
2,0,11051,11051,11051,
3,0,11051,11051,11051,
4,0,11051,11051,11051,
5,0,11051,11051,11051,
6,0,11051,11051,11051,
7,0,11051,11051,11051,
8,0,11051,11051,11051,
9,0,11051,11051,11051,
10,0,11051,11051,11051,
11,0,11051,11051,11051,
12,0,11051,11051,11051,
13,0,11051,11051,11051,
14,0,11051,11051,11051,
15,0,65535,65535,65535,
0,1,10794,10794,10794,
1,1,10794,10794,10794,
2,1,23130,23130,23130,
3,1,23130,23130,23130,
4,1,23130,23130,23130,
5,1,23130,23130,23130,
6,1,23130,23130,23130,
7,1,23130,23130,23130,
8,1,23130,23130,23130,
9,1,23130,23130,23130,
10,1,23130,23130,23130,
11,1,23130,23130,23130,
12,1,23130,23130,23130,
13,1,23130,23130,23130,
14,1,10794,10794,10794,
15,1,10794,10794,10794,
0,2,10280,10280,10280,
1,2,22873,22873,22873,
2,2,17733,17733,17733,
3,2,17733,17733,17733,
4,2,19018,18761,17733,
5,2,17733,17733,17733,
6,2,17733,17733,17733,
7,2,17733,17733,17733,
8,2,17733,17733,17733,
9,2,17733,17733,17733,
10,2,17733,17733,17733,
11,2,18761,18504,17733,
12,2,17733,17733,17733,
13,2,17733,17733,17733,
14,2,22873,22873,22873,
15,2,10280,10280,10280,
0,3,9509,9509,9509,
1,3,17219,17219,17219,
2,3,17219,17219,17219,
3,3,24672,23130,16962,
4,3,56283,49087,16448,
5,3,25700,24158,16962,
6,3,17219,17219,17219,
7,3,17219,17219,17219,
8,3,17219,17219,17219,
9,3,17219,17219,17219,
10,3,24672,23130,16962,
11,3,54998,47802,16448,
12,3,23130,21845,16962,
13,3,17219,17219,17219,
14,3,17219,17219,17219,
15,3,9509,9509,9509,
0,4,8995,8995,8995,
1,4,16705,16705,16705,
2,4,19789,19275,16705,
3,4,56797,49344,16191,
4,4,62194,53713,16191,
5,4,53713,46774,16191,
6,4,17219,17219,16705,
7,4,16705,16705,16705,
8,4,16705,16705,16705,
9,4,17219,17219,16705,
10,4,51914,45489,16191,
11,4,62194,53713,16191,
12,4,54741,47545,16191,
13,4,18247,17990,16705,
14,4,16705,16705,16705,
15,4,8995,8995,8995,
0,5,8224,8224,8224,
1,5,15934,15934,15934,
2,5,39835,35466,16191,
3,5,62194,53713,16191,
4,5,62194,53713,16191,
5,5,62194,53713,16191,
6,5,37265,33153,15934,
7,5,15934,15934,15934,
8,5,15934,15934,15934,
9,5,35466,31868,15934,
10,5,62194,53713,16191,
11,5,62194,53713,16191,
12,5,62194,53713,16191,
13,5,37265,33153,15934,
14,5,15934,15934,15934,
15,5,8224,8224,8224,
0,6,7196,7196,7196,
1,6,15420,15420,15420,
2,6,56797,49087,16191,
3,6,62194,53713,16191,
4,6,62194,53713,16191,
5,6,62194,53713,16191,
6,6,43433,37779,12593,
7,6,9509,8738,6425,
8,6,8738,8481,6682,
9,6,46003,40092,13107,
10,6,62194,53713,16191,
11,6,62194,53713,16191,
12,6,62194,53713,16191,
13,6,53970,47031,15934,
14,6,15420,15420,15420,
15,6,7196,7196,7196,
0,7,6425,6425,6425,
1,7,16448,15934,14649,
2,7,62194,53713,16191,
3,7,62194,53713,16191,
4,7,62194,53713,16191,
5,7,62194,53713,16191,
6,7,11822,10794,5397,
7,7,57311,49601,15163,
8,7,56026,48316,14906,
9,7,11822,10537,5654,
10,7,62194,53713,16191,
11,7,62194,53713,16191,
12,7,62194,53713,16191,
13,7,61166,52685,16191,
14,7,14649,14649,14649,
15,7,6425,6425,6425,
0,8,5654,5654,5654,
1,8,13878,13878,13878,
2,8,13878,13878,13878,
3,8,13878,13878,13878,
4,8,13878,13878,13878,
5,8,13878,13878,13878,
6,8,7453,6939,5140,
7,8,57311,49601,15163,
8,8,56797,49087,14906,
9,8,8224,7710,5654,
10,8,13878,13878,13878,
11,8,13878,13878,13878,
12,8,13878,13878,13878,
13,8,13878,13878,13878,
14,8,13878,13878,13878,
15,8,5654,5654,5654,
0,9,4626,4626,4626,
1,9,13107,13107,13107,
2,9,13107,13107,13107,
3,9,13107,13107,13107,
4,9,13107,13107,13107,
5,9,13107,13107,13107,
6,9,11565,11308,10280,
7,9,9766,8995,5140,
8,9,9509,8738,5140,
9,9,12079,11565,10537,
10,9,13107,13107,13107,
11,9,13107,13107,13107,
12,9,13107,13107,13107,
13,9,13107,13107,13107,
14,9,13107,13107,13107,
15,9,4626,4626,4626,
0,10,3855,3855,3855,
1,10,12336,12336,12336,
2,10,12336,12336,12336,
3,10,12336,12336,12336,
4,10,12336,12336,12336,
5,10,12336,12336,12336,
6,10,37522,33153,14392,
7,10,62194,53713,16191,
8,10,62194,53713,16191,
9,10,38807,34181,14392,
10,10,12336,12336,12336,
11,10,12336,12336,12336,
12,10,12336,12336,12336,
13,10,12336,12336,12336,
14,10,12336,12336,12336,
15,10,3855,3855,3855,
0,11,3084,3084,3084,
1,11,11822,11822,11822,
2,11,11822,11822,11822,
3,11,11822,11822,11822,
4,11,11822,11822,11822,
5,11,15934,15163,12079,
6,11,59881,51657,15934,
7,11,62194,53713,16191,
8,11,62194,53713,16191,
9,11,60909,52685,16191,
10,11,19018,17733,12336,
11,11,11822,11822,11822,
12,11,11822,11822,11822,
13,11,11822,11822,11822,
14,11,11822,11822,11822,
15,11,3084,3084,3084,
0,12,2313,2313,2313,
1,12,11051,11051,11051,
2,12,11051,11051,11051,
3,12,11051,11051,11051,
4,12,11051,11051,11051,
5,12,39835,35209,13878,
6,12,62194,53713,16191,
7,12,62194,53713,16191,
8,12,62194,53713,16191,
9,12,62194,53713,16191,
10,12,44718,39064,14392,
11,12,11051,11051,11051,
12,12,11051,11051,11051,
13,12,11051,11051,11051,
14,12,11051,11051,11051,
15,12,2313,2313,2313,
0,13,1542,1542,1542,
1,13,10537,10537,10537,
2,13,10537,10537,10537,
3,13,10537,10537,10537,
4,13,11051,10794,10537,
5,13,36751,32382,13364,
6,13,56026,48573,15420,
7,13,62194,53713,16191,
8,13,62194,53713,16191,
9,13,55512,48059,15420,
10,13,34952,30840,13107,
11,13,11051,11051,10537,
12,13,10537,10537,10537,
13,13,10537,10537,10537,
14,13,10537,10537,10537,
15,13,1542,1542,1542,
0,14,1028,1028,1028,
1,14,1028,1028,1028,
2,14,10023,10023,10023,
3,14,10023,10023,10023,
4,14,10023,10023,10023,
5,14,10023,10023,10023,
6,14,10023,10023,10023,
7,14,10023,10023,10023,
8,14,10023,10023,10023,
9,14,10023,10023,10023,
10,14,10023,10023,10023,
11,14,10023,10023,10023,
12,14,10023,10023,10023,
13,14,10023,10023,10023,
14,14,1028,1028,1028,
15,14,1028,1028,1028,
0,15,65535,65535,65535,
1,15,514,514,514,
2,15,514,514,514,
3,15,514,514,514,
4,15,514,514,514,
5,15,514,514,514,
6,15,514,514,514,
7,15,514,514,514,
8,15,514,514,514,
9,15,514,514,514,
10,15,514,514,514,
11,15,514,514,514,
12,15,514,514,514,
13,15,514,514,514,
14,15,514,514,514,
15,15,65535,65535,65535,
-1};
affdex::Frame frame(15, 15, pixels, affdex::Frame::COLOR_FORMAT::BGR);
affdex::PhotoDetector detector(2, affdex::FaceDetectorMode::LARGE_FACES );
std::string classifierPath="/home/mahesh/affdex-sdk/data";
affdex::ImageListener * listen = new Listener();
detector.setImageListener(listen);
detector.setClassifierPath(classifierPath);
detector.setDetectAllExpressions(true);
detector.setDetectAllEmotions(true);
detector.setDetectAllEmojis(true);
detector.setDetectAllAppearances(true);
detector.start();
detector.process(frame);
detector.stop();
}


#2

Are you using the Magick++? I think you are trying to run the example described in this video on our developer-portal. A couple of things I find wrong here, the array of pixels should be a char array. The affdex::Frame object expects frameWidth(img.rows()) and frameHeight(img.columns()) as the first and second respectively.


#3

Thanks for the quick reply,

We modified and used Magick++ in it. But when we try to execute it we get an error which says

Wrong JPEG library version: Library is 62, caller expects 80

We tried everything but we are not able to ger over this error.
May we know which version of ImageMagick is being used in the video and what command do we use to compile our code.
Any help would be highly appreciated.

Regards
Rishikeshwar