[英]iOS - Xcode - OpenCV - findContours error
findContours
导致以下错误:
2017-09-22 16:50:05.396700+0200 OpenCVLiveCamera[7827:3041522] [MC] systemgroup.com.apple.configurationprofiles 路径的系统组容器是/private/var/containers/Shared/SystemGroup/systemgroup.com.apple .configurationprofiles
2017-09-22 16:50:05.397011+0200 OpenCVLiveCamera[7827:3041522] [MC] 从公共有效用户设置中读取。
OpenCV 错误:断言失败 (mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0)) in create, file /Volumes/build-storage/ build/master_iOS-mac/opencv/modules/core/src/matrix.cpp,第 2601 行 libc++abi.dylib:以 cv::Exception 类型的未捕获异常终止:/Volumes/build-storage/build/master_iOS-mac /opencv/modules/core/src/matrix.cpp:2601: 错误: (-215) mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) 在函数中创建
代码:
void getContours(cv::Mat &srcImage){
cv::Mat dstImage = srcImage;
// Convert it to gray
cvtColor( srcImage, srcImage, CV_BGR2GRAY );
// Threshold
threshold(srcImage, srcImage, 192.0, 255.0, cv::THRESH_BINARY_INV);
// Find Contours to find chains of consecutive edge pixels
std::vector<std::vector<Point> > contours;
findContours(srcImage, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
// Draw contours on image
//....
}
请帮忙。 谢谢
通过将Point
更改为cv::Point
in 解决
std::vector<std::vector<cv::Point> > contours;
findContours
更改输入图像,因此无法显示。 试试
threshImg = srcImg.clone()
findContours(threshImg, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.