cv::findContours(imgthreshold, RETR_TREE, CHAIN_APPROX_NONE);这句话哪里有问题
时间: 2024-04-23 12:26:26 浏览: 62
这句话似乎是使用了OpenCV库中的函数cv::findContours来查找图像中的轮廓,但是参数不太对。正确的语法应该是:
cv::findContours(imgthreshold, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE);
其中,imgthreshold是二值化的图像,contours是存储返回的轮廓的向量,hierarchy是可选的输入参数,RETR_TREE表示检索所有的轮廓并重构嵌套轮廓的完整层次结构,CHAIN_APPROX_NONE表示存储所有的轮廓点,没有任何逼近。
相关问题
contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
这段代码使用OpenCV库中的findContours函数在二值图像中查找轮廓(contours)。函数的第一个参数是二值化后的图像(thresh),第二个参数是轮廓的检索模式(RETR_TREE表示提取所有轮廓并建立轮廓之间的层次关系),第三个参数是轮廓的近似方法(CHAIN_APPROX_NONE表示保存所有的轮廓点)。函数返回两个值,contours是包含所有轮廓的列表,hierarchy是包含轮廓之间层次关系的数组。
contours, hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
This line of code finds and retrieves contours from a binary image. The first argument is the input image (in this case, a binary image obtained from thresholding). The second argument specifies the retrieval mode, which determines the relationship between the contours and the hierarchy (parent-child relationships). The third argument specifies the contour approximation method, which determines the level of detail in the contours (in this case, no approximation is used).
The function returns two values: the contours themselves (as a list of arrays), and the hierarchy (a numpy array that describes the relationship between the contours).
阅读全文