Ask Your Question

How to build lookup table for inverse perspective mapping?

asked 2013-04-11 13:18:18 -0500

updated 2014-06-12 12:22:36 -0500

Hi, I want to build a lookup table to use with inverse perspective mapping. Instead of applying warpPerspective with the transform matrix on each frame, I want to use a lookup table (LUT).

Right now I use the following code to generate the transformation matrix

m = new Mat(3, 3, CvType.CV_32FC1);
m = Imgproc.getPerspectiveTransform(src, dst);

In the onCameraFrame() I apply the warpPerspective() function. How can I build a LUT knowing some input pixels on the original frame and their correspondences in the output frame, and knowing the transfromation matrix??

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-04-12 02:59:53 -0500

Follow the following guide about lookup tables in OpenCV and see if it can fix your problem. If I understand your question correctly, this is all you need.

edit flag offensive delete link more


Here's what I have:

Right now I'm using warpPerspective() to generate the birds eye view (inverse perspective map) but it's really slow.. I've been reading in some papers that you can build a lookup table and use that to map the points. ( for example here: >> @ page 23 >> 5.1 Generate lookup array

razvan gravatar imagerazvan ( 2013-04-12 13:39:21 -0500 )edit

I would say, give it a go. I haven't done anything related in the area so can't help ya for the moment :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-12 14:32:48 -0500 )edit

razvan i'm trying to implement inverse perspective mapping in image of road for calculate the distance but i can't generate bird-eye view :( how do you calculate destination points?

Carlos gravatar imageCarlos ( 2013-04-13 15:13:12 -0500 )edit

I did it by hand, manually, on a sheet of paper.. Basically on the src array you have 4 points in a trapezoid shape. On the dst array you put the corresponding calculated 4 points that represent a sqare/rectangle. I tried multiple values for the dst array, until I got a good result. Using the data from the calibration tutorial (extrinsic parameters w/ rotation and translation vectors) didn't work as expected. The source code for the transformation matrix is written in my initial question (the "m" matrix). After that you apply:

 Imgproc.warpPerspective(mRgba, tempMat, m, ddsize, Imgproc.INTER_LINEAR | Imgproc.CV_WARP_FILL_OUTLIERS);

 mRgba = tempMat.clone();
razvan gravatar imagerazvan ( 2013-04-13 19:57:40 -0500 )edit

Question Tools


Asked: 2013-04-11 13:18:18 -0500

Seen: 3,396 times

Last updated: Jun 12 '14