使用opencv的人脸检测不起作用

face detection using opencv not working

本文关键字:检测 不起作用 opencv 使用      更新时间:2023-10-16

我正在尝试使用OpenCv库创建一个示例人脸检测应用程序。我遵循了以下教程

http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.htmlhttps://www.openshift.com/blogs/day-12-opencv-face-detection-for-java-developers

但我收到了以下警告,它没有检测到人脸。

Hello, OpenCV
Running DetectFaceDemo
Detected 0 faces
Writing faceDetection.png
libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

请帮帮我。我正在使用linuxMint+eclipse系统。

出现问题

FaceDetector.class.getResource("haarcascade_frontalface_alt.xml").getPath()

它返回类似的东西

/C:/src/open/haarcascade_frontalface_alt.xml

开头的斜线应该删除

FaceDetector.class.getResource("haarcascade_frontalface_alt.xml").getPath().substring(1)

尝试这个

CascadeClassifier faceDetector=newCascadeClassifier(JavaCam.class.getResource("haarcascade_frontalface_alt.xml").getPath().substring(1));