28
$\begingroup$

In the camera setting in motion tracking, how do I tweak the K1, K2 and K3 value properly. I was told that these values are not necessary to tweak but I do want to adjust it, just for the sake of perfection.

$\endgroup$
  • 3
    $\begingroup$ Do note that the lens distortion will change at different focal lengths. $\endgroup$ – David Sep 6 '14 at 20:37
  • $\begingroup$ There is a pretty good explanation by Sebastian König in his Track, Match, Blend! tutorial, Part 08 at 14:25. $\endgroup$ – Samoth Mar 21 '16 at 21:32
40
$\begingroup$

All camera lenses in the real world create some kind of distortion. CG imagery does not have the imperfections of glass.

Setting the distortion values for the lens is crucial if you are trying to do accurate scene reconstruction and integration with 3D generated elements.

To determine the values for a particular lens you can shoot a picture of something that shows the lens distortion very clearly (It doesn't have to be a grid but is easier if the image has straight lines).

Photo of graph paper

Use the grease pencil to draw straight lines to use as reference . Find the beginning and ending points of lines that should be straight and draw a line that connects them (To draw straight lines use CtrlD and Left Mouse Button).

Grease Pencil lines added

Enable calibration on the Display tab.

Properties Panel in Movie Clip Editor

Play with the K1, K2 settings distorting the grease pencil lines until they match the curvature of the distorted lines in your image.

Distorted Grease Pencil lines

If you find that the line distort correctly on the top of the frame and not on the bottom (or vice versa, or on one side of the frame and not in the other) you might need to manually find the optical center in the camera settings. The slider on the left will move the optical center horizontally, the one on the right will move it vertically.

enter image description here

To check the result in your image you can use the Render Undistorted option.

Undistorted Graph Paper

Use the same values for images made with the same lens. If you change lenses, you will have to determine the values for each one.

Currently there is no way in blender to use images made with a variable focal length during the shot. In other words don't use a zoom during the shot.

To use the undistorted image in the compositor you should add a Movie Distortion node (ShiftA > Distort > Movie Distortion - with the undistort option enabled) after the video clip, and before the nodes to combine with the 3D scene.

Undistortion node setup

Depending of your needs, there is another way to use the distortion values of the lens, and that is to leave the video footage alone and apply de distortion to the 3D scene generated in blender. In that case you'd plug the Movie Distortion node to the rendered layers using the Distort option.

Distortion Node Setup

NOTE: There are currently two choices to undistort.

Distortion Model Popup

Divisions will olny give you two parameters to play: K1 and K2.

Polynomial will give you an additional K3.

To understand the difference between the two you can read this IPOL article about division models, but for the mathematically challenged it may suffice to quote:

The main advantage of the division model is the requirement of fewer terms than the polynomial model for the case of severe distortion. Therefore, the division model seems to be more adequate for wide-angle lenses.

Blender uses algorithms based on OpenCV. You might want to read more in the following link: https://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html

Other Note When undistorting it is likely that you'll run into problems with the edges of the frame:

It is possible that the undistorted image shows repeated pixels at the edge of the frame:

enter image description here

Or that the edges of the image are missing.

enter image description here

Read these links:

Solve camera motion in Blender: exact camera data or refinement?

Motion tracking. The edges of undistorted footage are cropped, and so are the elements of the 3D scene

and

Why is my footage smearing out towards the border on rendering an image? 3

$\endgroup$
  • 2
    $\begingroup$ @cegaton Could you elaborate K1 and K2? I think this would be a useful addition to this nice answer. $\endgroup$ – p2or Feb 3 '15 at 12:53
  • $\begingroup$ Could you add a few lines of explanations? I never used Blender and just want the k-values of a deformed image but after an hour of searching, I still can not find the buttons you are talking about. :/ $\endgroup$ – Suuuehgi Dec 7 '18 at 16:40

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.