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 !
Somebody ask the same question here without answer:
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 !
It does the job yes but the background is black :(