im2,contours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)#确定前景对象的轮廓
时间: 2024-05-31 15:13:20 浏览: 8
`cv2.findContours()` 函数是用于检测图像中的轮廓的函数。在本例中,`thresh` 是一个二值化图像,用于确定前景对象的轮廓。`cv2.RETR_TREE` 参数表示以树形结构检测轮廓,`cv2.CHAIN_APPROX_SIMPLE` 参数表示使用简单的压缩方法来保存轮廓信息,只保留轮廓的端点信息。
函数返回三个值:`im2` 表示二值化后的图像,`contours` 表示轮廓的列表,`hierarchy` 是可选的轮廓层次结构,如果使用 `cv2.RETR_TREE` 模式,则会返回轮廓之间的父子关系。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)