Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to get OpenCV running i am using the following sample code

I get the following Error line displayed:

OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file ........opencvmodulesobjdetectsrccascadedetect.cpp, line 1580
Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ........opencvmodulesobjdetectsrccascadedetect.cpp:1580: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale
]
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale_1(Native Method)
    at org.opencv.objdetect.CascadeClassifier.detectMultiScale(CascadeClassifier.java:176)
    at org.maxbit.opencv.samples.DetectFaceDemo.run(SampleB.java:29)
    at org.maxbit.opencv.samples.SampleB.main(SampleB.java:51)

Can any body tell me what that error means or how to debug this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
111 views
Welcome To Ask or Share your Answers For Others

1 Answer

I also faced the problem. The problem is in the .getPath() return an absolute path of the format.

Eg: "/C:/Users/projects/FaceDetection/bin/com/face/detection/haarcascade_frontalface_alt.xml".

So change the code like this.

CascadeClassifier faceDecetor = new CascadeClassifier(FaceDetection.class.getResource("haarcascade_frontalface_alt.xml").getPath().substring(1));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...