I have the situation that I have a small binary image that has one shape, around which I want to find the best fitting rotated rectangle (not b
Here's another approach (just a guess)
Wikipedia page on Principal Component Analysis says:
PCA can be thought of as fitting an n-dimensional ellipsoid to the data ...
And as your data is 2D, you can use the cv::fitEllipse function to fit an ellipse to your data and use the coordinates of the generated RotatedRect to calculate the angle. This gives better results as compared to cv::minAreaRect.