cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]
时间: 2024-05-19 15:14:38 浏览: 77
cvFindContours
This line of code uses the OpenCV library's "findContours" function to find the contours (boundaries) of the white regions in a binary mask image.
The function takes three arguments:
1. The binary mask image (in this case, a copy of the original mask image)
2. The retrieval mode (cv2.RETR_EXTERNAL) which retrieves only the extreme outer contours (ignoring contours within contours)
3. The contour approximation method (cv2.CHAIN_APPROX_SIMPLE) which compresses horizontal, vertical, and diagonal segments and leaves only their end points.
The function returns two values: the contours themselves and the hierarchy of the contours (which is not needed in this case, so only the contours are returned using the [-2] index).
阅读全文