I am trying to do face reconition using the new functionality from FaceRecognizer. I have read all the post about it and couldn't found an example (using javaCV, not C++) of how to do it from scratch.
This is my code for learning process. I am using 6 pictures of the same person (person number 1)
public void learn(String imgFilename ){
int numberOfFacesToLearn = 6;
MatVector images = new MatVector(numberOfFacesToLearn);
CvMat labels = CvMat.create(numberOfFacesToLearn, 1, CV_32SC1);
for( int i = 0; i < numberOfFacesToLearn ; i++){
IplImage faceImgArr = cvLoadImage(imgFilename + i, //all the file names are valid
CV_LOAD_IMAGE_GRAYSCALE);
images.put(faceImgArr);
labels.put(i, 0, 1); //I'm not sure about this line. "1" is because the user number is the same for all the pictures.
}
FaceRecognizerPtr model = createLBPHFaceRecognizer(1, 8, 8, 8, Double.MAX_VALUE);
FaceRecognizer reco = model.get();
reco.train(images, labels);
Every step goes well until the last line (reco.train(images, labels);) when I got this exception:
OpenCV Error: Assertion failed (s >= 0) in unknown function, file ..\..\..\src\opencv\modules\core\src\matrix.cpp, line 115
10-22-12.09:23:37,896-main-ERROR-OpencvClient:Unexpected error:
java.lang.RuntimeException: ..\..\..\src\opencv\modules\core\src\matrix.cpp:115: error: (-215) s >= 0
at com.googlecode.javacv.cpp.opencv_contrib$FaceRecognizer.train(Native Method)
I'll appreciate if somebody can help me to fix this error . I am stuck with this issue since a few days and I dont know how to resolve it at all.