OpenCV undistorts only a central part of fisheye image
Asked Answered
C

2

3

I'm trying to perform fisheye camera calibration via OpenCV 3.4.0 (C++, MS Windows).

I used cv::fisheye::calibrate to make K and D (camera matrix and radial distortion coeffitients matrix). Then I used cv::fisheye::initUndistortRectifyMap to produce maps for X and Y coordinates. And finally I used cv::remap to undistort image from fisheye camera via maps from initUndistortRectifyMap. Everything looks right, but OpenCV dewarps only a central part of fisheye image. Edges are moved outside. I'd like to dewarp the whole image. I tried to change focal length in K matrix manually, and got undistorted edges, but they became very very blurry. I found some results in this task. For example

https://www.youtube.com/watch?v=Ll8KCnCw4iU

and

https://www.youtube.com/watch?v=p1kCR1i2nF0

As far as you can see these results are very similar with my results. Does anybody have a solution of this problem?

Crumpler answered 26/2, 2018 at 13:52 Comment(1)
You may want to share the K and D matrix, the code you use to unwrap and also the result you got.. It will help us to define the issueKetti
C
3

I analyzed a lot of papers in the last 2 weeks. I think I found the source of the problem. OpenCV 3.4.0 fisheye undistortion method is based on a pin-hole camera model. We have an angle between the optical axis of the camera and the ray of light from some object. We also have an angle between the direction to an undistorted point of this object and the camera optical axis. If the fisheye image was undistorted correctly, these two angles would be equal. FOV of my fisheye camera is 180 degrees. It means that distance fromthe undistorted image center and the point corresponding to the edge of the undistorted image is equal to infinity. In other words if we have a fisheye camera with FOV around 180 degrees, undistortion (via OpenCV) of 100% of fisheye image surface is impossible.

Crumpler answered 12/3, 2018 at 7:53 Comment(1)
can you link some of the papers you read about this topic. ThanksAdminicle
P
1

It can be achieved, only that using a projection instead of trying to undistort it.

More info here OpenCV fisheye calibration cuts too much of the resulting image

Example result:

enter image description here

Pullman answered 27/11, 2018 at 13:2 Comment(1)
We are talking about absolutely different tasks. The main goal of my task is "straight lines should be straight". Your corrected image does not have any straight lines at allCrumpler

© 2022 - 2024 — McMap. All rights reserved.