I am working on a project where I'm using OpenCV on Python 3 to detect shapes and some properties using a camera in real-time. Ones of the shapes is a rectangle so I used Rotating Rectangle (or minimum area Rectangle) to extract useful information about it:
#Rotating Rectangle
rect = cv2.minAreaRect(approx)
box = cv2.boxPoints(rect)
box = np.int0(box)
This function detects the corners of the rectangle automatically and orders them depending to their coordinates. i.e the order of the corners changes when the rectangle is rotated, like the gif below:
Is there a way to have the order not change with rotation? The width and height of the rectangle depend on the order, so the height can become the width with a sleight angle change and vise versa.













