1 | initial version |
I figured out one way to do everything but the scale.
First, use minAreaRect to get a rotated rectangle that encloses all the points.
Then, use getRotationMatrix2d to figure out the rotation matrix that will transform the rectangle to a zero angle.
Then, use transform with the original points list and the rotation matrix to transform the points.
You still have to work out the scaling but that seems doable.