# Inverse Perspective Mapping -> When to undistort?

BACKGROUND:

I have a a camera mounted on a car facing forward and I want to find the roadmarks. Hence I'm trying to transform the image into a birds eye view image, as viewed from a virtual camera placed 15m in front of the camera and 20m above the ground. I implemented a prototype that uses OpenCV's warpPerspective function. The perspective transformation matrix is got by defining a region of interest on the road and by calculating where the 4 corners of the ROI are projected in both the front and the bird's eye view cameras. I then use these two sets of 4 points and use getPerspectiveTransform function to compute the matrix. This successfully transforms the image into top view.

QUESTION:

When should I undistort the front facing camera image? Should I first undistort and then do this transform or should I first transform and then undistort.

If you are suggesting the first case, then what camera matrix should I use to project the points onto the bird's eye view camera. Currently I use the same raw camera matrix for both the projections.

edit retag close merge delete

Sort by ยป oldest newest most voted

Hi,

You should :

• first undistort your raw image

And use the undistorted camera matrix of course ( Intrinsic_undisto ).

To get the transform Mat, you don't have to do such complex computes.

Mat Trans_to_C= (   Mat_<double>(3,3) <<
1, 0, -Cx,
0, 1, -Cy,
0, 0, fx);

Mat Intrinsic_undisto = (   Mat_<double>(3,3) <<
fx, 0, Cx,
0, fy, Cy,
0, 0, 1);

Mat 3x3_Translation_bird_eye = (    Mat_<double>(3,3) <<
1, 0, Trans_X,
0, 1, Trans_Y,
0, 0, Trans_Z);

Mat transform =  3x3_Translation_bird_eye * Intrinsic_undisto * 3x3_Rot * Trans_to_C;


I'm not sure for 3x3_Translation_bird_eye, but you should try this...

more

Official site

GitHub

Wiki

Documentation