1

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.

1
  • your image was not read properly (so it could not detect anything). Commented Apr 27, 2014 at 9:51

2 Answers 2

7

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)
Sign up to request clarification or add additional context in comments.

3 Comments

you are correct. the issue was with resources loading from classpath. I addressed them in absolute path. It worked fine, thanks.
@Valath, I got the same error after the slash issue in the path fixed with substring(1).
What is the result of this? FaceDetector.class.getResource("haarcascade_frontalface_alt.xml").getPath()
1

try this

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.