Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OpenCV findContours只能间歇工作_Python_Opencv_Opencv Python - Fatal编程技术网

Python OpenCV findContours只能间歇工作

Python OpenCV findContours只能间歇工作,python,opencv,opencv-python,Python,Opencv,Opencv Python,我目前正在运行一个非常基本的脚本,使用drawContours()来勾勒轮廓。不幸的是,这只正确运行了大约1/5次,每次我都必须手动关闭并重新加载脚本,等待findContours工作 下面是我正在做的脚本和图片(当drawContours脚本工作时) 使用边缘/二值图像查找轮廓效果最佳,例如cv2.threshold或cv2.adaptiveThreshold 请参见查找轮廓最适合边缘/二值图像,例如cv2.threshold或cv2.adaptiveThreshold 请参见尝试对图像设置阈

我目前正在运行一个非常基本的脚本,使用drawContours()来勾勒轮廓。不幸的是,这只正确运行了大约1/5次,每次我都必须手动关闭并重新加载脚本,等待findContours工作

下面是我正在做的脚本和图片(当drawContours脚本工作时)


使用边缘/二值图像查找轮廓效果最佳,例如cv2.threshold或cv2.adaptiveThreshold


请参见

查找轮廓最适合边缘/二值图像,例如cv2.threshold或cv2.adaptiveThreshold


请参见尝试对图像设置阈值:

ret, thresh = cv2.threshold(image, 127, 255, 0)
然后试着找到伯爵:

cnts,__ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

尝试对图像设置阈值:

ret, thresh = cv2.threshold(image, 127, 255, 0)
然后试着找到伯爵:

cnts,__ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)