我正在尝试让OpenCV运行我正在使用以下 示例代码
I am trying to get OpenCV running i am using the following sample code
我显示以下错误行:
OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale, file ..\..\..\..\opencv\modules\objdetect\src\cascadedetect.cpp, line 1580 Exception in thread "main" CvException [org.opencv.core.CvException: cv::Exception: ..\..\..\..\opencv\modules\objdetect\src\cascadedetect.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?
推荐答案这种情况通常有两个原因。
This happens usually for two reasons.
要在运行时获取错误消息而不是异常,请尝试代码样品如下。 CascadeClassifier 构造函数无法加载级联分类器XML,则它是静默的。开发人员有责任调用 empty()方法并检查分类器是否正确加载
To get an error message instead of exception during runtime, try code sample as below. The CascadeClassifier constructor is silent, if it cannot load the cascade classifier XML. The onus is on the developer to call the empty() method and check if classifier is loaded correctly
CascadeClassifier cascade = new CascadeClassifier( CASCADE_CLASSIFIER_PATH ); if ( cascade.empty() ) { //handler error here }您获得的异常来自OpenCV本机代码断言这里。
Exception you got is from OpenCV native code assertion here.
更多推荐
OpenCV 3.0.0 FaceDetect示例失败
发布评论