I was wondering, how the following is achieved (hopefully efficiently).
Turning this:
to this:
I have seen methods to dewrap (for example Circular Fisheye Image dewarp to flat image), but none of them target the case above.
EDIT
I managed to get camera matrix, distortion coefficients, rotation and translation vectors using the following line of code
ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, gray.shape[::-1],None,None)
and then undistorting with:
dst = cv2.undistort(img, mtx, dist, None, None)
but i got garbage..