Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transform Rectangle to trapezoid for perspective

I have picture from front-view. and I want to turn this into bird's eye view. Now I want to calculate for each point in the rectangle (x,y) what will be transformed x,y in the trapezoid. enter image description here

there must be a formula for this transformation with a given x and y and also the angle of the trapezoid (a).

I am programming in C and using opencv.

Thanks a lot in advance.

like image 850
Khashayar Avatar asked Feb 28 '13 16:02

Khashayar


1 Answers

Did you consider the homography transform. You use this to create or correct perspective in an image, I think that it is exactly what you want.

With OpenCV, you can use the method cv::findHomography(). The arguments are the 4 initial points (vertices of your rectangle) and the 4 final points (the vertices of the trapeze). You get a transformation matrix that you can then use with cv::warpPerspective() or cv::perspectiveTransform().

like image 60
cedrou Avatar answered Nov 04 '22 10:11

cedrou