diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-02-20 17:41:05 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-04-17 15:28:41 +0400 |
commit | ed2ddc9f706b956ea955ac86b3e7ec5e0b41d9cd (patch) | |
tree | b8023b5604fef55f436c0d1be1a03e113f9ef39d /source/blender/blenkernel/intern/movieclip.c | |
parent | 39bfde674cfe4f6a9140b6d4c48a348de04d715a (diff) |
Support multiple distortion models, including a new division model
This commit makes it so CameraIntrinsics is no longer hardcoded
to use the traditional polynomial radial distortion model. Currently
the distortion code has generic logic which is shared between
different distortion models, but had no other models until now.
This moves everything specific to the polynomial radial distortion
to a subclass PolynomialDistortionCameraIntrinsics(), and adds a
new division distortion model suitable for cameras such as the
GoPro which have much stronger distortion due to their fisheye lens.
This also cleans up the internal API of CameraIntrinsics to make
it easier to understand and reduces old C-style code.
New distortion model is available in the Lens panel of MCE.
- Polynomial is the old well-known model
- Division is the new one which s intended to deal better with huge
distortion.
Coefficients of this model works independent from each other
and for division model one probably want to have positive values
to have a barrel distortion.
Diffstat (limited to 'source/blender/blenkernel/intern/movieclip.c')
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index de4846e1772..5012c08d95d 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -335,7 +335,9 @@ typedef struct MovieClipCache { /* cache for undistorted shot */ float principal[2]; - float k1, k2, k3; + float polynomial_k1, polynomial_k2, polynomial_k3; + float division_k1, division_k2; + short distortion_model; bool undistortion_used; int proxy; @@ -732,11 +734,21 @@ static bool check_undistortion_cache_flags(MovieClip *clip) MovieTrackingCamera *camera = &clip->tracking.camera; /* check for distortion model changes */ - if (!equals_v2v2(camera->principal, cache->postprocessed.principal)) + if (!equals_v2v2(camera->principal, cache->postprocessed.principal)) { return false; + } + + if (camera->distortion_model != cache->postprocessed.distortion_model) { + return false; + } - if (!equals_v3v3(&camera->k1, &cache->postprocessed.k1)) + if (!equals_v3v3(&camera->k1, &cache->postprocessed.polynomial_k1)) { return false; + } + + if (!equals_v2v2(&camera->division_k1, &cache->postprocessed.division_k1)) { + return false; + } return true; } @@ -823,8 +835,10 @@ static void put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *use } if (need_undistortion_postprocess(user)) { + cache->postprocessed.distortion_model = camera->distortion_model; copy_v2_v2(cache->postprocessed.principal, camera->principal); - copy_v3_v3(&cache->postprocessed.k1, &camera->k1); + copy_v3_v3(&cache->postprocessed.polynomial_k1, &camera->k1); + copy_v2_v2(&cache->postprocessed.division_k1, &camera->division_k1); cache->postprocessed.undistortion_used = true; } else { |