我正在努力实现人脸识别,并来到这里: -
import com.googlecode.javacv.cpp.opencv_contrib;
import com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizer;
import com.googlecode.javacv.cpp.opencv_core.CvMat;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_core.MatVector;
import com.googlecode.javacv.cpp.opencv_highgui;
public class Eigen {
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();
{
String url="C:/Users/user/Desktop/a3.png";
IplImage img=opencv_highgui.cvLoadImage(url);
}
fr.train(imgs,id);
IplImage testImage=opencv_highgui.cvLoadImage("C:/Users/vivek/Documents/NetBeansProjects/face/src/testimg/hello.png");
CvMat mat= testImage.asCvMat();
int val=fr.predict(mat);
System.out.println(val);
}
}
但是这段代码每次运行时都会给我运行错误: - 输出
OpenCV错误:图像步骤错误(矩阵不连续,因此 cv :: Mat :: reshape,file中的行数不能改变 ........ \ opencv \ modules \ core \ src \ matrix.cpp,第802行异常 线程“main”java.lang.RuntimeException: ........ \ opencv \ modules \ core \ src \ matrix.cpp:802:错误:( - 13) 矩阵不连续,因此其行数不能改变 在函数cv :: Mat :: reshape
中
我有灰度缩放两个图像,它们的尺寸相同,为200 * 200.但它仍然显示此错误可以让任何人帮忙。