OpenCV错误:在iOS上断言失败

我试图find一个图像中最大的斑点,并根据链接的plist文件进行分类。 我正在使用最新版本的OpenCV for iOS,并且已经查看了几个相关的问题,但目前为止还没有涉及到iOS。

我得到这个错误:

OpenCV错误:断言失败(types== src2.type()&& src1.cols == src2.cols &&(type == CV_32F || type == CV_8U))in batchDistance,file / Users / admin / Desktop / OpenCV / modules / core / src / stat.cpp,第4000行

libc ++ abi.dylib:以typescv :: Exception的未捕获exception终止:/Users/admin/Desktop/OpenCV/modules/core/src/stat.cpp:4000:error:(-215)type == src2。在函数batchDistance中键入()&& src1.cols == src2.cols &&(type == CV_32F || type == CV_8U)

当我运行这个:

- (IBAction)CaptureButton:(id)sender { // Find the biggest blob. int biggestBlobIndex = 0; for (int i = 0, biggestBlobArea = 0; i < detectedBlobs.size(); i++) { Blob &detectedBlob = detectedBlobs[i]; int blobArea = detectedBlob.getWidth() * detectedBlob.getHeight(); if (blobArea > biggestBlobArea) { biggestBlobIndex = i; biggestBlobArea = blobArea; } } Blob &biggestBlob = detectedBlobs[biggestBlobIndex]; // Classify the blob. blobClassifier->classify(biggestBlob); // the error occurs here } 

我在最后一行中调用的classify在另一个文件中声明:

 void classify(Blob &detectedBlob) const; 

这是来自stat.cpp的相关代码:

 Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); int type = src1.type(); CV_Assert( type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U)); // this is line 4000 

这里有什么问题?

我不知道cv :: Mat对象如何在目标c中查找,但是您需要确保与分类器一起使用的图像的所有维度,通道数目和深度都是统一的。 当你用训练图像喂食分类器时,可能以前有一个步骤。 也许其中之一是不兼容你试图分类的垫子。

如果您自己编译并在CMake中设置debugging版本,您可以尝试使用opencv进行debugging。