# What is the reverse of warpPerspective ?

Hi all !

At the bottom of this link, a transformation extract the sudoku in "full screen".

I would like to draw some text on the extracted sudoku and re introduce it in the big picture. Do you know how can I re introduce it ?

Here is the code I use:

/**
coordinates is a std::vector<Point2f> with inside:
[topLeft, topRight, bottomLeft, bottomRight]

original is the original picture (the left one in the link) and sudoku is the right one

*/

float w = (float)input.cols;
float h = (float)input.rows;
float hw = w / 2.0f;
float hh = h / 2.0f;

// to points
dst_p[0] = Point2f(0.0f, 0.0f);
dst_p[1] = Point2f(w, 0.0f);
dst_p[2] = Point2f(w, h);
dst_p[3] = Point2f(0.0f, h);

// create perspective transform matrix
Mat trans_mat33 = getPerspectiveTransform(coordinates, dst_p); //CV_64F->double
Mat inv_trans_mat33 = getPerspectiveTransform(dst_p, coordinates);
// perspective transform operation using transform matrix
warpPerspective(input, sudoku, trans_mat33, input.size(), INTER_LINEAR);

sudoku = writeOnPuzzle(sudoku, "012345000000000000000000000000000000000000000000000000000000000000000000000000000");

invert(trans_mat33, inv_trans_mat33);
warpPerspective(sudoku, original, trans_mat33, input.size(), WARP_INVERSE_MAP);


Thank you !

edit retag close merge delete

( 2017-01-05 03:05:48 -0500 )edit

can you try, if WARP_INVERSE_MAP does the job ?

also, much appreciated, if you'd replace the link with the code, you're actually using !

( 2017-01-05 03:26:44 -0500 )edit
1

It does the job yes but the background is black :(

( 2017-01-05 03:35:11 -0500 )edit

Sort by ยป oldest newest most voted

By using this:

    warpPerspective(sudoku, original, trans_mat33, input.size(), WARP_INVERSE_MAP, BORDER_TRANSPARENT);


I managed to re introduce the sudoku I had modified

Thank you !

more

Official site

GitHub

Wiki

Documentation