I am trying to perform a perspective transform of a sudoku puzzle. The expected transformation is happening only on the left side. Please help me by pointing out my mistake.
Input Image:
Expected Output Image:
The output I am getting:
The corners of the sudoku puzzle found using cv2.approxpolydp() are as follows:
top_left = [71,62]
top_right = [59, 418]
bottom_right = [443, 442]
bottom_left = [438, 29]
The shape of the output image is [300,300].
The corresponding output coordinates are :
output_top_left = [0,0]
output_top_right = [0, 299]
output_bottom_right = [299, 299]
output_bottom_left = [299,0]
The following is the code I used for perspective transform:
#corners = [[71,62], [59, 418], [443, 442], [438, 29]]
new = np.float32([[0,0], [0,299], [299,299], [299,0]])
M = cv2.getPerspectiveTransform(np.float32(corners), new)
dst = cv2.warpPerspective(gray, M, (300,300))
The generated Transformation Matrix is :
[[ 9.84584842e-01 3.31882531e-02 -7.19631955e+01]
[ 8.23993265e-02 9.16380389e-01 -6.26659363e+01]
[ 4.58051741e-04 1.45318012e-04 1.00000000e+00]]




