cv::Mat imgthreshold; cv::Mat imgsrc = cv::imread("C:/Users/Dell/Pictures/Camera Roll/Yelan.jpg",0); cv::threshold(imgsrc, imgthreshold, 100, 255, THRESH_BINARY); vector<vector<Point>> contours; cv::findContours(imgthreshold, contours,cv::noArray(), RETR_LIST, CHAIN_APPROX_SIMPLE);为什么会在findContours这个函数触发断点
时间: 2024-04-23 15:24:04 浏览: 11
如果在调用 `cv::findContours()` 时程序触发了断点,可能是因为在调用该函数之前没有正确地对 `imgthreshold` 进行初始化,导致函数无法正常工作。请检查以下几个方面:
1. 确保图像文件已经成功读入并加载到 `imgsrc` 中。
2. 检查 `imgthreshold` 的大小和数据类型是否正确,可以使用 `cv::imshow()` 函数在窗口中显示图像来检查。
3. 检查 `threshold()` 函数是否成功将 `imgsrc` 转换为二值图像,并将其保存在 `imgthreshold` 中。可以使用 `cv::imshow()` 函数在窗口中显示二值图像来检查。
4. 检查是否正确传入了 `contours` 变量作为函数的输出参数。
如果以上步骤都没有问题,可以尝试使用调试器查看是哪一行代码触发了断点,以便更好地定位问题所在。