Funny you’ve linked to OpenCV – I tried porting their C++ implementation to Java the other day.
Sometimes it works:
Occasionally it doesn’t:
Other times there’s no output at all:

There might be just one bug in there somewhere… Anyway, I didn’t realise it had a Java interface so I’ll try that and compare…