Is there a way to remove GoPro fisheye using ffmpeg

user4223883 picture user4223883 · Jun 14, 2015 · Viewed 9.9k times · Source

It seems possible to compensate the fisheye distortion using ffmpeg thanks to the lenscorrection filter:

ffmpeg -i in.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-.25:k2=-.25" out.mp4

What values for k1 and k2, particularly for a gopro? Is there a way to compute them?

Answer

VC.One picture VC.One · Nov 17, 2016

I don't think there's a generic one setting(s) to cover all GoPro models & lenses. Factor in also that people can use some customised/replacement lenses.

I was hoping for an example image featuring what you have to work with, but never mind...
Hope the below is useful to you in some way

Check this link for GoPro Hero 3 settings (applies to other models). To get a rough idea of best k1 and k2 values, you should find the nearest aspect ratio to your image resolution then...

Divide the H. FOV deg with the V. FOV deg and multiply result with Diag. FOV deg.

Example: where picture size is 1920 x 1080 : This makes it 16:9 widescreen.

GoPro 3 setting: 16 x 9 Widescreen :: H fov = 69.5 || V fov = 118.2 || Diag = 133.6

So 118.2 / 69.5 * 133.6 = 227.216 etc

for k1 the result is now integer 227 (drop the decimal points).

for k2 the value 0.022 seems universal (all test images), so you can try k2=-.022.

for cx and cy keep them as : cx=0.5:cy=0.5:.

Example:

ffmpeg -i in.mp4 -vf "lenscorrection=cx=0.5:cy=0.5:k1=-0.227:k2=-0.022" out.mp4

Result : (original image found via Google images of a GoPro Hero-2 video).