I have this data from a video.
Vertices of a rectangle
Points of an animal tracking inside the rectangle.
Due to image deformation, my "rectangle" is not regular.
I want to transform the data in order to plot them in matplotlib as a rectangle.
Is there an easy method?
This is the maze and trancking. I decompose it into five quadrilaterals
解决方案
You can use skimage.transform.ProjectiveTransform from scikit-image to transform coordinates inside your quadrilateral into the local square space [0, 1] × [0, 1].
For more info on how to apply linear algebra to solve this problem, see ProjectiveTransform.estimate or "Projective Mappings for Image Warping" by Paul Heckbert, 1999.
Suppose you have the corners of your quadrilateral in clockwise order:
bottom_left = [58.6539, 31.512]
top_left &