4

It seems to be possible to correct lens distortion with ffmpeg. According to the manual you can adjust K1 and K2 values. What this means? How to use it correctly?

enter image description here Example still image - captured with a canon 60D and a focal length of 18mm (EFS 18-55mm zoom lens)

  • Can you provide a screenshot to use as an example input? ffmpeg -ss 10 -i input -vframes 1 output.png – llogan Feb 3 '15 at 18:47
  • @LordNeckbeard, of course :) – p2or Feb 4 '15 at 16:31
  • Thanks. What lens are you using? – llogan Feb 4 '15 at 16:33
  • @LordNeckbeard lens added to question. – p2or Feb 4 '15 at 16:35
4
+50

In the manual it says:

To use opencv use the calibration sample (under samples/cpp) from the opencv sources and extract the k1 and k2 coefficients from the resulting matrix.

If you go to the opencv website there's a sample source code for a lens correction program, written in c++, here. You'll have to compile it yourself, after installing OpenCV (sounds like you better put on a pot of coffee). When you run it it will spit out an xml file containing the values for k1 and k2, which you can then use as inputs to the filter.

  • Haha - Thanks stib as always! Note: You could also preview k1 and k2 values in Blender. But I'm not sure what these values mean. I'm trying to figure it out :) – p2or Feb 6 '15 at 15:10
  • Also, you can obtain the xcenter and ycenter values from the OpenCV camera matrix. You'll need to scale them from their OpenCV pixel coordinates to fractional width and height coordinates for use in ffmpeg. I'm not sure if ffmpeg's coordinate system is the same as OpenCV's, though – that's something to look into. – billyjmc Jan 6 '16 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.