remap single point does not give me the correct value

asked 2016-07-15 04:53:26 -0600

SrSRG gravatar image

Hello!

I am trying to compute the remaped position of a specific point of an image but it does not give me the correct coordinate as I compare it with the remaped image.

is this correct?

Point2f relocated = Point2f(mapx.at<float>(input.rows,input.cols),mapy.at<float>(input.rows,input.cols));

edit retag flag offensive close merge delete

Comments

the farthest point you can legally access is:

mapx.at<float>(input.rows-1,input.cols-1)

while

mapx.at<float>(input.rows,input.cols)

is already out of bounds

berak gravatar imageberak ( 2016-07-15 05:16:44 -0600 )edit

my mistake... the point can be mapx.at<float>(input.rows/2,input.cols/2) and still give me the wrong value

SrSRG gravatar imageSrSRG ( 2016-07-15 05:22:15 -0600 )edit

please show code

berak gravatar imageberak ( 2016-07-15 05:32:18 -0600 )edit

This is the code for creating the maps. This is basically a barrell distortion mapping // clean the room mapx.release(); mapy.release();

// allocate the maps
mapx.create( imframe.size(), CV_32FC1 );
mapy.create( imframe.size(), CV_32FC1 );

// the image size
int w = imframe.cols;
int h = imframe.rows;

for (int y = 0; y < h; y++) {
    int ty= y-Cy;
    for (int x = 0; x < w; x++) {
        int tx= x-Cx;
        int rt= tx*tx+ty*ty;

        mapx.at<float>(y,x) = (float)(tx*(1+kx*rt)+Cx);
    }
}

for (int y = 0;y < h; y++) {
    int ty= y-Cy;
    for (int x = 0; x < w; x++) {
        int tx= x-Cx;
        int rt= tx*tx+ty*ty;

        mapy.at<float>(y,x) = (float)(ty*(1+ky*rt)+Cy);
    }
}
SrSRG gravatar imageSrSRG ( 2016-07-15 05:35:30 -0600 )edit

So the mappings work on the whole imframe if I remap it. but if i draw a circle in the remaped image using the mapx.at<float>(imframe.rows/2,imframe.cols/2) it does not follow the remapped image

SrSRG gravatar imageSrSRG ( 2016-07-15 05:38:00 -0600 )edit

Show the part where you use the maps. I don't entirely understand what you're doing with them.

Tetragramm gravatar imageTetragramm ( 2016-07-15 15:00:26 -0600 )edit

Hi, i need to do the same. Did you get any sucess to remap a single point or an array of points?

Soarez gravatar imageSoarez ( 2018-01-19 12:25:16 -0600 )edit