pythonopencvdistortionfisheye

Undistort ultra-wide angle (>180 degrees) fisheye lens


I am trying to undistort a 220deg fisheye lens image. I worked with fisheye before using OpenCV and a script similar to this. However, whenever I used a lens with more than 180deg it seems to fail, getting a warp-drive stretching towards the edge. Undistorted 220deg image with stretching towards the edges

Thinking of it practically makes me almost doubt it's possible/easy, since it covers more than the half sphere and hence an undistorted projection is tricky. Googling it I found only old discussions or research papers without usable code. Does anyone have experience with this and can give a hint how to fix this? Ideally with openCV or another Python library to allow me implementing it.


Solution

  • This is not a complete solution, but I found that ffmpeg can transform the picture/video into a 360degree view, which then can be panned and cropped into the right angle (similar as some commenters suggested above, just that ffmpeg does most of the work already). The command is

    ffmpeg -i input_video_file.mp4 -vf v360=fisheye:equirect:ih_fov=220:yaw=90 -y output.mp4
    

    I didn't do the cropping yet since this step was sufficient for me, but I hope it could help someone that stumbles on this question in the future.