3

I was wondering, how the following is achieved (hopefully efficiently).

Turning this:

enter image description here

to this:

enter image description here

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..

rayryeng
  • 102,964
  • 22
  • 184
  • 193
Alex Goft
  • 1,114
  • 1
  • 11
  • 23
  • You need to know the camera intrinsics to do the dewarping successfully. For example, do you know the camera focal length? Principal point? What about the distortion coefficients? – rayryeng May 28 '19 at 09:26
  • All i have is an image. I can chose in advance principal point. – Alex Goft May 28 '19 at 10:08
  • That unfortunately is not enough. – rayryeng May 28 '19 at 10:10
  • @rayryeng please see edit – Alex Goft May 28 '19 at 13:08
  • `cv2.calibrateCamera` only works when you have a **calibration pattern** visible in the image. Also, the calibration pattern should occupy the majority of the image for the method to be accurate. You don't have this, so naturally it's going to give you garbage. You unfortunately cannot blindly find the camera intrinsics from the image without some higher level information. – rayryeng May 28 '19 at 18:10
  • @rayryeng thank you very much for the elaborated answer. You said "... cannot blindly find the camera intrinsics from the image without some higher level information. " what higher level information is missing? In addition, in the frame of the camera i am working with there's a square tile floor by which i chose `objpoints` manually, isn't that enough? Or presence of calibration pattern that covers majority of the image is a must? (Currently, its logistically not possible to to take some shots with calibration pattern..) – Alex Goft May 29 '19 at 06:54

0 Answers0