def mapit(self, mode):
# Find the centroid of the bounding box of the image (we know this by construction - testing the functions)
w,h,c = self.img.shape
outerEdge = np.array([(0,0), (0, h), (w,h), (w, 0)], dtype = np.int)
M = cv2.moments(outerEdge)
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
cv2.circle(self.img, (cX, cY), 7, (255, 255, 255), -1)
cv2.putText(self.img, "center", (cX - 20, cY - 20),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
cv2.rectangle(self.img, (cX-30, cY-30), (cY+30, cY+30),(0,255,0), 2)
评论列表
文章目录