1 先对二值图像找边框。cv2.findContours
2 计算形心 cv2.moments
3 plot
_,cnts, _ = cv2.findContours(
thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
#compute the center of the contour
M=cv2.moments(cnts)
cX= int(M["m10"] / M["m00"])
cY= int(M["m01"]/ M["m00"])
cv2.circle(composite,(cX,cY),7,(255,255,255),-1)
cv2.imshow("COCO detections", composite)
cv2.waitKey(0)
cv2.destroyWindow('COCO detections')
ref
https://blog.csdn.net/xiaoyufei117122/article/details/53574993
https://blog.csdn.net/chaihuimin/article/details/76888353