gpt4 book ai didi

c++ - iOS - Xcode - OpenCV - findContours 错误

转载 作者:行者123 更新时间:2023-11-28 04:59:47 26 4
gpt4 key购买 nike

findContours 导致以下错误:

2017-09-22 16:50:05.396700+0200 OpenCVLiveCamera[7827:3041522] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-09-22 16:50:05.397011+0200 OpenCVLiveCamera[7827:3041522] [MC] Reading from public effective user settings.
OpenCV Error: Assertion failed (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, line 2601 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Volumes/build-storage/build/master_iOS-mac/opencv/modules/core/src/matrix.cpp:2601: error: (-215) mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) in function create

代码:

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 解决

 std::vector<std::vector<cv::Point> > contours;

关于c++ - iOS - Xcode - OpenCV - findContours 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46368996/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com