OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 21 Jun 2013 04:30:14 -0500Inverse Perspective Mapping -> When to undistort?http://answers.opencv.org/question/15526/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.
Please ask more details if my description is confusing!Thu, 20 Jun 2013 19:33:57 -0500http://answers.opencv.org/question/15526/inverse-perspective-mapping-when-to-undistort/Answer by neoirto for <p>BACKGROUND:</p>
<p>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.</p>
<p>QUESTION:</p>
<p>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. </p>
<p>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.</p>
<p>Please ask more details if my description is confusing!</p>
http://answers.opencv.org/question/15526/inverse-perspective-mapping-when-to-undistort/?answer=15546#post-id-15546Hi,
You should :
- first undistort your raw image
- then apply your warpperspective()
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...Fri, 21 Jun 2013 04:30:14 -0500http://answers.opencv.org/question/15526/inverse-perspective-mapping-when-to-undistort/?answer=15546#post-id-15546