Page MenuHome

Only enable "Render Undistorted" in Background Images when there is lens distortion

Authored by Sebastian Koenig (sebastian_k) on Aug 18 2019, 11:30 AM.



The "Setup Scene" operator in the Clip Editor will alwas enable "Render Undistorted" for background images, no matter if the camera solution actually is using the lens distortion or not. Since the undistortion is being calculated on the fly, it will lead to worse playback rates.
With this patch the option "Render Undistorted" in Camera Background Images will only be enabled if the K1 value of the Lens Distortion parameters is not zero.

Diff Detail

rB Blender

Event Timeline

The idea is fine.

Unfortunately, there are some caveats in the implementation:

  • It is not invalid to have distortion model configured in a way that only second and third polynomial coefficients are not zero.
  • The check does not take divisions model into account.

Should become something like:

def checkCameraHasDistortion(tracking_camera):
    if tracking_camera.distortion_model == 'POLYNOMIAL':
        return not all(k == 0 for k in (tracking_camera.k1, tracking_camera.k2, tracking_camera.k3))
    elif tracking_camera.distortion_model == 'DIVISION':
        return not all(k == 0 for k in (tracking_camera.division_k1, tracking_camera.division_k2))
    return False

  if checkCameraHasDistortion(
      bgpic.clip_user.use_render_undistorted = True

I have updated the patch with @Sergey Sharybin (sergey)'s suggested changes.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 5 2019, 12:06 PM
This revision was automatically updated to reflect the committed changes.

Love it, good catch!