c++opencvdistortionfisheyeradial

OpenCV undistorts only a central part of fisheye image


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?


Solution

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