Valath
Valath

Reputation: 920

face detection using opencv not working

I am trying to create a sample face detection application using OpenCv library. I followed the following tutorials

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

But Iam getting the following warning and it is not detecting faces.

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

Please help me.I am using linuxMint+eclipse system.

Upvotes: 1

Views: 3860

Answers (2)

Taha Emara
Taha Emara

Reputation: 140

try this

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

Upvotes: 1

Tharindu Kumara
Tharindu Kumara

Reputation: 4458

Problem is with the

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

It returns something like this

/C:/src/open/haarcascade_frontalface_alt.xml

The slash at the begining should be removed

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

Upvotes: 7

Related Questions