1

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.

André
  • 142
  • 1
  • 15
  • 2
    You can't produce a rectilinear image with field of view of 180 degrees or more, you can, however produce several rotated rectilinear images from a single fisheye image, [this](https://answers.opencv.org/question/224773/find-rotation-vector-centering-undistorted-image-on-specific-fisheye-image-pixel/) should get you started. – zteffi Jan 28 '22 at 15:49
  • 2
    fisheye lenses usually require a mapping to cylindrical or equirectangular (!= rectilinear) projection. anything based on mapping to flat planes must fail. last I checked, OpenCV has some code for calibrating "*super*-fisheye" (>180 degree) lenses (weird definition but ok). I haven't needed it, and I remember people who struggled with this stuff. – Christoph Rackwitz Jan 28 '22 at 17:13
  • Please show your code and input. The warp-drive region is likely an out of distortion correction region and so just outside the proper input image range and is just stretching out the edges of your input. You likely have the option in the warping function to set that region to some constant color rather than extend the edges of your input, which is likely the default. – fmw42 Sep 14 '22 at 18:27

1 Answers1

0

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.

André
  • 142
  • 1
  • 15