java中的opencv人脸检测

java中的opencv人脸检测,java,opencv,Java,Opencv,我试着这么做: 但每次我都被发现有0张脸。 我有Windows7x64,所有库opencv_java245.dll都已连接。我尝试了版本2.4.4和2.4.5,尝试了不同的图像格式SPNG、jpg、bmp和不同的图像,但结果总是相同的。 为什么这可能不起作用?这个问题是通过将xml文件从我的项目传输到计算机上的另一个位置来解决的这个问题是通过将xml文件从我的项目传输到计算机上的另一个位置来解决的我遇到了同样的问题,我更改了代码 //CascadeClassifier faceDetector

我试着这么做: 但每次我都被发现有0张脸。 我有Windows7x64,所有库opencv_java245.dll都已连接。我尝试了版本2.4.4和2.4.5,尝试了不同的图像格式SPNG、jpg、bmp和不同的图像,但结果总是相同的。
为什么这可能不起作用?

这个问题是通过将xml文件从我的项目传输到计算机上的另一个位置来解决的

这个问题是通过将xml文件从我的项目传输到计算机上的另一个位置来解决的

我遇到了同样的问题,我更改了代码

//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("/lena.png").getPath());

然后它就起作用了

源代码中的文件位置有问题

String lbpcascadesFilePath = getClass().getResource("/lbpcascade_frontalface.xml").getPath();
// The fiel path you got is like /E:/Programmer/EclipseWorkspace/JavaProject/TestOpenCV/bin/lbpcascade_frontalface.xml
System.out.println(lbpcascadesFilePath); 
// trim first '/', or the file cannot be read in Windows.
lbpcascadesFilePath = lbpcascadesFilePath.substring(1);
// Then it is OK to load the file.
CascadeClassifier faceDetector = new CascadeClassifier(lbpcascadesFilePath);
然后对图像文件执行相同的操作

String imgFilePath = getClass().getResource("/lena.png").getPath();
System.out.println(imgFilePath); // like /E:/Programmer/EclipseWorkspace/JavaProject/TestOpenCV/bin/lena.png
imgFilePath = imgFilePath.substring(1);  // trim first "/", or the file cannot be read in Windows.
Mat image = Highgui.imread(imgFilePath);

我遇到了同样的问题,我改变了密码

//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("/lena.png").getPath());

然后它就起作用了

源代码中的文件位置有问题

String lbpcascadesFilePath = getClass().getResource("/lbpcascade_frontalface.xml").getPath();
// The fiel path you got is like /E:/Programmer/EclipseWorkspace/JavaProject/TestOpenCV/bin/lbpcascade_frontalface.xml
System.out.println(lbpcascadesFilePath); 
// trim first '/', or the file cannot be read in Windows.
lbpcascadesFilePath = lbpcascadesFilePath.substring(1);
// Then it is OK to load the file.
CascadeClassifier faceDetector = new CascadeClassifier(lbpcascadesFilePath);
然后对图像文件执行相同的操作

String imgFilePath = getClass().getResource("/lena.png").getPath();
System.out.println(imgFilePath); // like /E:/Programmer/EclipseWorkspace/JavaProject/TestOpenCV/bin/lena.png
imgFilePath = imgFilePath.substring(1);  // trim first "/", or the file cannot be read in Windows.
Mat image = Highgui.imread(imgFilePath);

将.xml和.png文件移动到不同的位置并不能解决我的问题。它仍然显示检测到的错误消息0个面。您还有其他选择吗?将.xml和.png文件移动到其他位置并不能解决我的问题。它仍然显示检测到的错误消息0个面。你还有别的选择吗?