我正在尝试找到图像中最大的blob,并根据链接的plist文件对其进行分类 . 我正在使用最新版本的OpenCV for iOS,我已经看了几个相关的问题,但到目前为止都没有涉及到iOS .
我收到这个错误:
OpenCV错误:断言失败(类型== src2.type()&& src1.cols == src2.cols &&(type == CV_32F || type == CV_8U))batchDistance,file / Users / admin / Desktop / OpenCV /modules/core/src/stat.cpp,line 4000 libc abi.dylib:以cv类型的未捕获异常终止::异常:/Users/admin/Desktop/OpenCV/modules/core/src/stat.cpp:4000:错误:(-215)type == src2.type()&& src1.cols == src2.cols &&(type == CV_32F || type == CV_8U)函数batchDistance
当我运行这个:
- (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
这是什么问题?
1 回答
我不知道cv :: Mat对象在目标c中是如何看的,但是你需要确保分类器使用的所有维度,通道数和图像深度都是一致的 . 当您为分类器提供训练图像时,可能之前有一个步骤 . 也许其中一个与您尝试分类的垫子不兼容 .
如果您自己编译并在CMake中设置调试版本,可以尝试使用opencv进行调试 .