Hi, I have tried first steps with OpenCV and have a problem I need help with.
Based on examples I wanted to test face detection. I prepared a simple code that loads a image and should run the detection with the source-code follows:
Source code test2.java
public void run(){
System.out.println("Start");
System.out.println(Core.VERSION);
System.out.println(getClass().getResource("CV_test.jpg").getPath());
Mat image = Imgcodecs.imread(getClass().getResource("CV_test.jpg").getPath());
System.out.println(image.height()+"x"+image.width());
System.out.println(getClass().getResource("haarcascade_frontalface_default.xml").getPath());
CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("haarcascade_frontalface_default.xml").getPath());
System.out.println(faceDetector.empty());
}
and console output:
Console output
Start
3.1.0-dev
/home/ocena/workspace/test2/bin/test2/CV_test.jpg
520x782
/home/ocena/workspace/test2/bin/test2/haarcascade_frontalface_default.xml
true
CV_test.jpg & haarcascade_frontalface_default.xml are in the same directory and the image is loaded OK where the XML not.
Any idea what is wrong?
Thanks for hint, J.Ocenasek