How to determine the orientation of an object in a binary image? (Python, OpenCV)

I must determine the direction in which the windmill collides with aerial photographs (relative to the True North - from 0 to 359 degrees).

My question is, how can I determine the correct direction of the windmill and calculate its angle relative to the y axis? Thanks!

+5
source share
1 answer

I don’t know if this works at all, but given your sample images, I would find the midpoint of the short edges of the bounding box and get two rectangles for the two halves of the big BBox.

Then I calculated the sum of the pixels of the mask in two separate half-waves, assuming that white is 1 and black is 0. Since the white area is more than half the rectangle where the β€œfront” of the turbine, choose the direction according to which of the two half-BBoxes has a higher amount

+4
source

Source: https://habr.com/ru/post/1271721/


All Articles