0

I have a 180 degree fisheye camera, and I want to obtain an undistorted image with as wide a field of view as possible. Eventually, I want to be able to use this to create a 180 degree top down image using the fisheye camera. To do this, I want to first undistort the image while retaining as much image data as I can.

I used the opencv fisheye.calibrate in python using chessboard images taken at different angles, and that correctly undistorts a fisheye image, giving me a decent result. However, the resulting image has a significantly worse field of view than the fisheye image due to how it undistorts the image.

Fisheye image:

enter image description here

Undistorted Image Lacking field of view:

enter image description here

Current code:

DIM=(960, 540)
K=np.array([[263.1021173128426, 0.0, 477.98780306608234], [0.0, 261.30612719984185, 300.714230825097], [0.0, 0.0, 1.0]])
D=np.array([[-0.0007727739728155351], [-0.10019345132548932], [0.10790597488851726], [-0.040655761660861996]])
def undistort(img):
    h,w = img.shape[:2]
    map1, map2 = cv2.fisheye.initUndistortRectifyMap(K, D, np.eye(3), K, DIM, cv2.CV_16SC2)
    return cv2.remap(img, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)

It is my understanding that there is no way to increase the field of view of the undistortion output without having the output be stretched into an undesirable shape (e.g. in this image). However, I have seen people able to create mutliple undistorted images from different perspectives. For example given the original fisheye image above, I want to be able to create images from different perspectives such as this and this, which could then be stitched together for a wider field of view. Is there a way to adjust the calibration parameters of the opencv undistortion function to achieve this?

I am assuming this is possible as I have seen it done in other contexts such as here (using java and boofCV).

Any advice on alternate ways of achieving a wider field of view would be appreciated as well.

amanb
  • 5,276
  • 3
  • 19
  • 38
person132
  • 111
  • 4
  • [this answer](https://stackoverflow.com/a/53500300/10699171) may be of some use – J.D. Feb 05 '19 at 22:34
  • @J.D. I have looked at that answer, and while that is one way of processing a fisheye image, I am more specifically looking for a method in opencv to generate multiple pinhole images at different angles from a fisheye image. Thanks though. – person132 Feb 07 '19 at 00:52
  • @person132 did you find a solution to your problem? – Philipp Jul 14 '22 at 14:03

0 Answers0