PyImageSearch / imutils

A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.
MIT License
4.51k stars 1.03k forks source link

Erroneous behavior of `four_point_transform` #195

Open cedric-sun opened 4 years ago

cedric-sun commented 4 years ago

Hi all,

I found some weird behavior of imutils.perspective.four_point_transform. The following example was meant to get a perpendicular perspective of a car license plate:

The image is available here. Coordinates in br-bl-tl-tr order are [(481, 580), (254, 615), (255, 551), (482, 516)] (well, the x coordinates are just 1 pixel away)

The notecard demo works fine for me. I guess something is wrong with the order_points function.

cedric-sun commented 4 years ago

I think cv2.warpPerspective requires that these 4 points in the tl-tr-bl-br order, but the result of order_points is interpreted as

https://github.com/jrosebr1/imutils/blob/df65a77087548b5952431cc8006d66bcca7b1abc/imutils/perspective.py#L40

Something might be wrong.