OpenCV RotatedRect with specified angle

前端 未结 3 1714
自闭症患者
自闭症患者 2021-02-04 17:06

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

3条回答
  •  长发绾君心
    2021-02-04 17:40

    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.

提交回复
热议问题