opencv error断言失败



OpenCV错误:

 Assertion failed (scaleFactor > 1 && image.depth() == CV_8U) in detectMultiScale, file /build/buildd/opencv-2.4.9+dfsg/modules/objdetect/src/cascadedetect.cpp, line 1081
    terminate called after throwing an instance of 'cv::Exception'
      what():  /build/buildd/opencv-2.4.9+dfsg/modules/objdetect/src/cascadedetect.cpp:1081: error: (-215) scaleFactor > 1 && image.depth() == CV_8U in function detectMultiScale.

为什么会出现这个错误?

查看级联分类器detectMultiScale文档。

void CascadeClassifier::detectMultiScale(const Mat& image, vector<Rect>& objects, double scaleFactor=1.1, int minNeighbors=3, int flags=0, Size minSize=Size(), Size maxSize=Size())

for image it state:

类型为CV_8U的矩阵,其中包含对象所在位置的图像检测到

for scaleFactor it state:

指定在每个图像比例下的图像大小减少多少的参数。

如果你了解级联分类器是如何工作的,你会注意到scaleFactor低于0不会做任何有用的事情。

这个断言试图告诉你你需要什么,所以倒着读——它失败了,

 (scaleFactor > 1 && image.depth() == CV_8U)

…返回'0' -当我们使用布尔AND时,这意味着一个或两个逻辑语句失败…(因此有三种可能性)

最新更新