How to determine object orientation in binary image? (Python, OpenCV) -
i supposed determine direction windmill facing aerial images (with respect true north - 0 359 degrees).
here example input image (with added arrow direction i'm trying determine):
and here's segmented windmill fitted rectangle:
after segmenting windmill background used following code fitted rectangle:
contours, hierarchy = cv2.findcontours(segmentedimage.copy(), cv2.retr_tree, cv2.chain_approx_simple) cnt = contours[0] rect = cv2.minarearect(cnt) box = cv2.cv.boxpoints(rect) box = np.int0(box) cv2.drawcontours(segmentedimage, [box], 0, (255,255,0), 1)
my question is, how can determine correct direction of windmill , calculate angle relative y-axis? thanks!
dunno if works in general, given sample images i'd find middle point of short edges of bounding box , 2 rectangles 2 halves of big bbox.
i compute sum of mask pixels in 2 separate half-bboxes, assuming white 1 , black 0. since white area bigger on half of rectangle "front" of turbine is, pick direction according of 2 half-bboxes has higher sum
Comments
Post a Comment