Ask Your Question
1

OpenCV does not detect faces on Eclipse/Win7

asked 2016-11-15 18:17:17 -0600

jytou gravatar image

updated 2016-11-16 09:28:05 -0600

berak gravatar image

Hi all, I'm pulling my hair around this one. I have followed tutorials, unzipped opencv, added my library in eclipse, copy/pasted the simple face detection program, and now it runs fine but... it doesn't detect any face, even with faces that are easy to detect and with images that people have successfully used with the same sample code. The catch is that the program runs fine (no error) but does not detect any face, whatever the image I give it (I've tried on larger banks of frontal face images, no luck: 0 face detected). I've even tried the cat face detection with some very obvious images, and still nothing is detected. Eye detection returns 0 eye detected as well.

To make sure it is really using the x64 DLL, I've also tried changing the DLL directory to x86 and I do get an error saying that it cannot open a 32 bit DLL on a 64 bit system, which confirms it is indeed loading the DLL. I've tried this with the latest 2.4.13 version of opencv as well as the previous version 2.4.12, with no luck. Anyone ever faced this kind of issue? Any clue what could be causing this?

I am on Windows 7 SP 1, x64 obviously. Eclipse is a little old: Mars.1 release (Build id: 20150924-1200). UPDATE: I have installed the latest Eclipse (Neon.1a Release (4.6.1)) and get the exact same results. JDK is 1.8.0_60.

Thanks!

JY.

edit retag flag offensive close merge delete

Comments

1

your ide is irrelevent here.

but please check cascade.empty() - most probably it did not find the xml file

berak gravatar imageberak ( 2016-11-16 08:09:09 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-11-16 09:23:09 -0600

jytou gravatar image

Indeed, problem solved. For some reason, the path returned by getResource().getPath() had a leading "/" although I'm on Windows here so it was something like "/C:/foo/bar". No wonder the classifier couldn't find the file. Shouldn't it throw an error rather than silently failing?

edit flag offensive delete link more

Comments

2

lol, btw, you never even mentioned using java here ...

well, if it would throw an exception, you'd have to catch it - here, you simply have to check the return value (or empty())

berak gravatar imageberak ( 2016-11-16 09:27:18 -0600 )edit

Yes, it's always the debate between crashing when something bad happens vs going on and leaving the check to the caller. I am personally more and more in favor of the former, but that's my own inclination and I'll have to keep in mind that opencv's policy seems to be the latter. Not a big deal, just good to know. :) Thanks for your great help.

jytou gravatar imagejytou ( 2016-11-16 11:24:16 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-11-15 18:15:12 -0600

Seen: 221 times

Last updated: Nov 16 '16