Reputation: 404
I am getting error in EigenFaces.predict() method in java cv face recognition. The error is-
OpenCV Error: Image step is wrong (The matrix is not continuous, thus its number of rows can not be changed) in unknown function, file ......\src\opencv\modules\core\src\matrix.cpp, line 802
My code is-
public static void main(String[] args) {
long size=6;
MatVector imgs=new MatVector(size);
int[] id={0,0,0,0,0,0};
FaceRecognizer fr=opencv_contrib.createEigenFaceRecognizer();
for(int i=0;i<=5;i++)
{
String url="C:/Users/vivek/Documents/NetBeansProjects/Recognizer2/src/a"+(i+1)+".jpg";
IplImage img=opencv_highgui.cvLoadImage(url);
imgs=imgs.put(i,img);
}
fr.train(imgs,id);
IplImage testImage=opencv_highgui.cvLoadImage("C:/Users/vivek/Documents/NetBeansProjects/Recognizer2/src/a3.jpg");
CvMat mat= testImage.asCvMat();
int val=fr.predict(mat);
System.out.println(val);
}
Upvotes: 3
Views: 2086
Reputation: 404
Finally I got the solution of my problem. The size of my test and training images were 70*70. I changed the size to 200*200 and now it is working perfectly. The reason behind it is that EigenFaceRecognizer and FisherFaceRecognizer don't work with image width that are not multiple of 8 or 16(In my case). 70 is not multiple of 8 so it is not working but for image width 200(multiple of 8), it is working fine.
Upvotes: 3