def identify_OD(image):
newfin = cv2.dilate(image, cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5)), iterations=2)
mask = np.ones(newfin.shape[:2], dtype="uint8") * 255
y1, ycontours, yhierarchy = cv2.findContours(newfin.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
prev_contour = ycontours[0]
for cnt in ycontours:
if cv2.contourArea(cnt) >= cv2.contourArea(prev_contour):
prev_contour = cnt
cv2.drawContours(mask, [cnt], -1, 0, -1)
M = cv2.moments(prev_contour)
cx = int(M['m10']/M['m00'])
cy = int(M['m01']/M['m00'])
return (cx,cy)
评论列表
文章目录