OpenCV 3.0.0 FaceDetect示例失败 [英] OpenCV 3.0.0 FaceDetect Sample fails

查看:448
本文介绍了OpenCV 3.0.0 FaceDetect示例失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让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.


  1. 级联分类器文件 lbpcascade_frontalface.xml 在指定路径中不存在。

  2. 级联分类器文件已损坏。

  1. Cascade classifier file lbpcascade_frontalface.xml not present at specified path.
  2. Cascade classifier file is corrupted.

要在运行时获取错误消息而不是异常,请尝试代码样品如下。 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示例失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆