答案 0 :(得分:2)
更新:
在OpenCV 3.4中,cv2.findContours
返回image, contours, hierarchy
cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
在OpenCV 4.0中,cv2.findContours
返回contours, hierarchy
cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
因此,要在脱粒二进制图像中查找轮廓并计算区域,请使用:
cnts= cv.findContours(threshed, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)[-2]
for cnt in cnts:
area = cv2.contourArea(cnt)
print(area)