Ask Your Question

Revision history [back]

I am developing face recognize on android,why the predict method always return 0

I was developing face recognize on android, but I missed a problem, when I use the predict method to predict persons, the return values is 0 everytime. The api sad that -1 states this face is unknown. Now,I want to know why is it. could you help me. thanks!

click to hide/show revision 2
retagged

updated 2014-04-21 02:48:00 -0600

berak gravatar image

I am developing face recognize on android,why the predict method always return 0

I was developing face recognize on android, but I missed a problem, when I use the predict method to predict persons, the return values is 0 everytime. The api sad that -1 states this face is unknown. Now,I want to know why is it. could you help me. thanks!

I am developing face recognize on android,why the predict method always return 0

I was developing face recognize on android, but I missed a problem, when I use the predict method to predict persons, the return values is 0 everytime. The api sad that -1 states this face is unknown. Now,I want to know why is it. could you help me. thanks!thanks! My code

vector<Mat> images;
vector<jint> labels;
jint num_components = 10;
jdouble threshold = 10.0;
Mat& predictImg = *(Mat*)predictImgAddr;
//person1
images.push_back(imread("/sdcard/s1/1.bmp"));
labels.push_back(0);
images.push_back(imread("/sdcard/s1/2.bmp"));
labels.push_back(0);
images.push_back(imread("/sdcard/s1/3.bmp"));
labels.push_back(0);
images.push_back(imread("/sdcard/s1/4.bmp"));
labels.push_back(0);

//person2
images.push_back(imread("/sdcard/s2/1.bmp"));
labels.push_back(1);
images.push_back(imread("/sdcard/s2/2.bmp"));
labels.push_back(1);
images.push_back(imread("/sdcard/s2/3.bmp"));
labels.push_back(1);
images.push_back(imread("/sdcard/s2/4.bmp"));
labels.push_back(1);
Ptr<FaceRecognizer> model = createFisherFaceRecognizer(num_components, threshold);
model->train(images,labels);
jint predicted = model->predict(predictImg);
return predicted; `