Blender
V3.3
|
#include <limits.h>
#include "DNA_anim_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "RNA_access.h"
#include "RNA_prototypes.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_math_vector.h"
#include "BLI_sort_utils.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_fcurve.h"
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "MEM_guardedalloc.h"
Go to the source code of this file.
Classes | |
struct | TrackStabilizationBase |
struct | TrackInitOrder |
struct | StabContext |
struct | TrackingStabilizeFrameInterpolationData |
Typedefs | |
typedef struct TrackStabilizationBase | TrackStabilizationBase |
typedef struct TrackInitOrder | TrackInitOrder |
typedef struct StabContext | StabContext |
typedef void(* | interpolation_func) (const struct ImBuf *, struct ImBuf *, float, float, int, int) |
typedef struct TrackingStabilizeFrameInterpolationData | TrackingStabilizeFrameInterpolationData |
Variables | |
static float | SCALE_ERROR_LIMIT_BIAS = 0.01f |
static float | EPSILON_WEIGHT = 0.005f |
This file contains implementation of 2D image stabilization.
Definition in file tracking_stabilize.c.
Definition at line 1277 of file tracking_stabilize.c.
typedef struct StabContext StabContext |
typedef struct TrackInitOrder TrackInitOrder |
typedef struct TrackStabilizationBase TrackStabilizationBase |
|
static |
Definition at line 102 of file tracking_stabilize.c.
References BLI_ghash_lookup(), and StabContext::private_track_data.
Referenced by average_track_contributions(), get_animated_weight(), init_all_tracks(), init_track_for_stabilization(), and is_init_for_stabilization().
|
static |
Definition at line 108 of file tracking_stabilize.c.
References BLI_ghash_insert(), and StabContext::private_track_data.
Referenced by init_all_tracks().
|
static |
Definition at line 617 of file tracking_stabilize.c.
References EPSILON_WEIGHT, get_tracking_data_point(), LISTBASE_FOREACH, MAXFRAME, MINAFRAME, MINFRAME, MovieTrackingMarker::pos, retrieve_next_higher_usable_frame(), retrieve_next_lower_usable_frame(), search_closest_marker_index(), TRACK_USE_2D_STAB, StabContext::tracking, MovieTracking::tracks, use_values_from_fcurves(), and zero_v2().
Referenced by init_all_tracks().
|
static |
Definition at line 505 of file tracking_stabilize.c.
References access_stabilization_baseline_data(), BLI_assert, EPSILON_WEIGHT, MovieTrackingStabilization::flag, get_tracking_data_point(), is_init_for_stabilization(), LISTBASE_FOREACH, logf, NULL, offset, MovieTrackingMarker::pos, rotation_contribution(), setup_pivot(), MovieTracking::stabilization, TRACK_USE_2D_STAB, TRACK_USE_2D_STAB_ROT, StabContext::tracking, TRACKING_2D_STABILIZATION, TRACKING_STABILIZE_ROTATION, TRACKING_STABILIZE_SCALE, MovieTracking::tracks, translation_contribution(), and zero_v2().
Referenced by init_all_tracks(), interpolate_averaged_track_contributions(), and stabilization_determine_offset_for_frame().
void BKE_tracking_stabilization_data_get | ( | struct MovieClip * | clip, |
int | framenr, | ||
int | width, | ||
int | height, | ||
float | translation[2], | ||
float * | scale, | ||
float * | angle | ||
) |
Get stabilization data (translation, scaling and angle) for a given frame. Returned data describes how to compensate the detected movement, but with any chosen scale factor already applied and any target frame position already compensated. In case stabilization fails or is disabled, neutral values are returned.
framenr | is a frame number, relative to the clip (not relative to the scene timeline). |
width | is an effective width of the canvas (square pixels), used to scale the determined translation. |
Outputs:
translation | of the lateral shift, absolute canvas coordinates (square pixels). |
scale | of the scaling to apply. |
angle | of the rotation angle, relative to the frame center. |
TODO(sergey): Use r_
prefix for output parameters here.
Definition at line 1240 of file tracking_stabilize.c.
References angle(), MovieTracking::camera, compensate_rotation_center(), discard_stabilization_working_context(), enabled, MovieTrackingStabilization::flag, float(), height, init_stabilizer(), NULL, MovieTrackingCamera::pixel_aspect, size(), MovieTracking::stabilization, stabilization_calculate_data(), stabilization_determine_offset_for_frame(), MovieClip::tracking, TRACKING_2D_STABILIZATION, width, and zero_v2().
Referenced by BKE_tracking_stabilize_frame(), blender::compositor::MovieClipNode::convert_to_operations(), and get_stable_cached_frame().
void BKE_tracking_stabilization_data_to_mat4 | ( | int | width, |
int | height, | ||
float | aspect, | ||
float | translation[2], | ||
float | scale, | ||
float | angle, | ||
float | mat[4][4] | ||
) |
Build a 4x4 transformation matrix based on the given 2D stabilization data. mat is a 4x4 matrix in homogeneous coordinates, adapted to the final image buffer size and compensated for pixel aspect ratio, ready for direct OpenGL drawing.
TODO(sergey): The signature of this function should be changed. we actually don't need the dimensions of the image buffer. Instead we should consider to provide the pivot point of the rotation as a further stabilization data parameter.
Definition at line 1413 of file tracking_stabilize.c.
References angle(), and stabilization_data_to_mat4().
Referenced by BKE_tracking_stabilize_frame(), and clip_draw_main().
ImBuf* BKE_tracking_stabilize_frame | ( | struct MovieClip * | clip, |
int | framenr, | ||
struct ImBuf * | ibuf, | ||
float | translation[2], | ||
float * | scale, | ||
float * | angle | ||
) |
Stabilize given image buffer using stabilization data for a specified frame number.
TODO(sergey): Use r_
prefix for output parameters here.
Definition at line 1306 of file tracking_stabilize.c.
References angle(), bicubic_interpolation(), bilinear_interpolation(), BKE_tracking_stabilization_data_get(), BKE_tracking_stabilization_data_to_mat4(), BLI_parallel_range_settings_defaults(), BLI_task_parallel_range(), MovieTracking::camera, copy_v2_v2(), data, MovieTrackingStabilization::filter, filter(), MovieTrackingStabilization::flag, height, IB_rect, IB_RECT_INVALID, IB_rectfloat, IMB_allocImBuf(), IMB_colormanagegent_copy_settings(), invert_m4(), nearest_interpolation(), NULL, MovieTrackingCamera::pixel_aspect, ImBuf::planes, ImBuf::rect, ImBuf::rect_float, MovieTracking::stabilization, MovieClip::tracking, TRACKING_2D_STABILIZATION, TRACKING_FILTER_BICUBIC, TRACKING_FILTER_BILINEAR, TRACKING_FILTER_NEAREST, tracking_stabilize_frame_interpolation_cb(), TaskParallelSettings::use_threading, ImBuf::userflags, width, ImBuf::x, ImBuf::y, and zero_v2().
Referenced by put_stabilized_frame_to_cache().
|
static |
Definition at line 1102 of file tracking_stabilize.c.
References add_v2_v2v2(), angle(), MovieTracking::camera, copy_v2_v2(), cross_v2v2(), dist_to_line_v2(), MovieTrackingStabilization::flag, height, LISTBASE_FOREACH, max_ff(), max_ii(), MovieTrackingStabilization::maxscale, min_ff(), min_ii(), mul_m4_v3(), MovieTrackingCamera::pixel_aspect, point, point_index, size(), StabContext::stab, stabilization_calculate_data(), stabilization_data_to_mat4(), stabilization_determine_offset_for_frame(), sub_v3_v3v3(), TRACK_USE_2D_STAB, TRACK_USE_2D_STAB_ROT, StabContext::tracking, TRACKING_STABILIZE_ROTATION, MovieTracking::tracks, use_values_from_fcurves(), and width.
Referenced by init_stabilizer().
|
static |
Definition at line 471 of file tracking_stabilize.c.
References add_v2_v2(), angle(), angle_to_mat2(), copy_v2_v2(), mul_m2_v2(), mul_v2_fl(), size(), and sub_v2_v2().
Referenced by BKE_tracking_stabilization_data_get().
Definition at line 115 of file tracking_stabilize.c.
References MEM_freeN, and NULL.
Referenced by discard_stabilization_working_context().
|
static |
Discard all private working data attached to this call context.
Definition at line 229 of file tracking_stabilize.c.
References BLI_ghash_free(), discard_stabilization_baseline_data(), MEM_freeN, NULL, and StabContext::private_track_data.
Referenced by BKE_tracking_stabilization_data_get().
|
static |
Definition at line 736 of file tracking_stabilize.c.
References blender::math::abs(), MovieTrackingStabilization::anchor_frame, BLI_sortutil_cmp_int(), MovieTrackingMarker::framenr, get_closest_marker(), LISTBASE_FOREACH, NULL, order, MovieTracking::stabilization, TRACK_USE_2D_STAB, TRACK_USE_2D_STAB_ROT, StabContext::tracking, and MovieTracking::tracks.
Referenced by init_all_tracks().
|
static |
Definition at line 139 of file tracking_stabilize.c.
References BKE_movieclip_remap_clip_to_scene_frame(), StabContext::clip, evaluate_fcurve(), and StabContext::use_animation.
Referenced by get_animated_locinf(), get_animated_rotinf(), get_animated_scaleinf(), get_animated_target_pos(), get_animated_target_rot(), and get_animated_target_scale().
|
static |
Definition at line 300 of file tracking_stabilize.c.
References is_usable_for_stabilization(), LISTBASE_FOREACH, retrieve_next_higher_usable_frame(), retrieve_next_lower_usable_frame(), search_closest_marker_index(), StabContext::tracking, and MovieTracking::tracks.
Referenced by stabilization_determine_offset_for_frame().
|
static |
Definition at line 151 of file tracking_stabilize.c.
References fetch_from_fcurve(), StabContext::locinf, MovieTrackingStabilization::locinf, and StabContext::stab.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 156 of file tracking_stabilize.c.
References fetch_from_fcurve(), StabContext::rotinf, MovieTrackingStabilization::rotinf, and StabContext::stab.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 161 of file tracking_stabilize.c.
References fetch_from_fcurve(), StabContext::scaleinf, MovieTrackingStabilization::scaleinf, and StabContext::stab.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 166 of file tracking_stabilize.c.
References fetch_from_fcurve(), StabContext::stab, StabContext::target_pos, and MovieTrackingStabilization::target_pos.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 172 of file tracking_stabilize.c.
References fetch_from_fcurve(), StabContext::stab, StabContext::target_rot, and MovieTrackingStabilization::target_rot.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 177 of file tracking_stabilize.c.
References fetch_from_fcurve(), MovieTrackingStabilization::scale, StabContext::stab, and StabContext::target_scale.
Referenced by stabilization_calculate_data().
|
static |
Definition at line 182 of file tracking_stabilize.c.
References access_stabilization_baseline_data(), BKE_movieclip_remap_clip_to_scene_frame(), StabContext::clip, evaluate_fcurve(), TrackStabilizationBase::track_weight_curve, and MovieTrackingTrack::weight_stab.
Referenced by get_tracking_data_point(), and is_effectively_disabled().
|
static |
Definition at line 315 of file tracking_stabilize.c.
References BKE_tracking_marker_get_exact(), MAXFRAME, MINAFRAME, retrieve_next_higher_usable_frame(), retrieve_next_lower_usable_frame(), and search_closest_marker_index().
Referenced by establish_track_initialization_order().
|
static |
Definition at line 337 of file tracking_stabilize.c.
References BKE_tracking_marker_get_exact(), MovieTrackingMarker::flag, get_animated_weight(), MARKER_DISABLED, and NULL.
Referenced by average_marker_positions(), and average_track_contributions().
|
static |
Definition at line 845 of file tracking_stabilize.c.
References access_stabilization_baseline_data(), MovieTrackingStabilization::anchor_frame, attach_stabilization_baseline_data(), average_marker_positions(), average_track_contributions(), BLI_assert, StabContext::clip, establish_track_initialization_order(), init_track_for_stabilization(), TrackStabilizationBase::is_init_for_stabilization, LISTBASE_FOREACH, MEM_callocN, MEM_freeN, MEM_mallocN, NULL, order, retrieve_track_weight_animation(), setup_pivot(), MovieTracking::stabilization, TrackStabilizationBase::track_weight_curve, StabContext::tracking, MovieTracking::tracks, and zero_v2().
Referenced by init_stabilizer().
|
static |
Definition at line 203 of file tracking_stabilize.c.
References BLI_ghash_ptr_new(), StabContext::clip, StabContext::locinf, MEM_callocN, StabContext::private_track_data, retrieve_stab_animation(), StabContext::rotinf, StabContext::scaleinf, StabContext::stab, MovieTracking::stabilization, StabContext::target_pos, StabContext::target_rot, StabContext::target_scale, StabContext::tracking, MovieClip::tracking, and StabContext::use_animation.
Referenced by init_stabilizer().
|
static |
Definition at line 1224 of file tracking_stabilize.c.
References BLI_assert, calculate_autoscale_factor(), MovieTrackingStabilization::flag, init_all_tracks(), init_stabilization_working_context(), NULL, MovieTrackingStabilization::scale, size(), StabContext::stab, TRACKING_AUTOSCALE, and use_values_from_fcurves().
Referenced by BKE_tracking_stabilization_data_get().
|
static |
Definition at line 810 of file tracking_stabilize.c.
References access_stabilization_baseline_data(), angle(), angle_to_mat2(), atan2f, BKE_tracking_marker_get_exact(), BLI_assert, expf, TrackStabilizationBase::is_init_for_stabilization, len, len_v2(), NULL, pos, MovieTrackingMarker::pos, SCALE_ERROR_LIMIT_BIAS, TrackStabilizationBase::stabilization_offset_base, TrackStabilizationBase::stabilization_rotation_base, TrackStabilizationBase::stabilization_scale_base, and sub_v2_v2v2().
Referenced by init_all_tracks().
|
static |
Definition at line 679 of file tracking_stabilize.c.
References average_track_contributions(), BLI_assert, float(), interp_v2_v2v2(), and t.
Referenced by stabilization_determine_offset_for_frame().
|
static |
Definition at line 248 of file tracking_stabilize.c.
References EPSILON_WEIGHT, MovieTrackingMarker::flag, MovieTrackingMarker::framenr, get_animated_weight(), and MARKER_DISABLED.
Referenced by retrieve_next_higher_usable_frame(), and retrieve_next_lower_usable_frame().
|
static |
Definition at line 237 of file tracking_stabilize.c.
References access_stabilization_baseline_data(), TrackStabilizationBase::is_init_for_stabilization, and NULL.
Referenced by average_track_contributions(), and is_usable_for_stabilization().
|
static |
Definition at line 243 of file tracking_stabilize.c.
References MovieTrackingTrack::flag, is_init_for_stabilization(), and TRACK_USE_2D_STAB.
Referenced by find_next_working_frames().
|
static |
Definition at line 262 of file tracking_stabilize.c.
References BLI_assert, is_effectively_disabled(), markers, MovieTrackingTrack::markers, and MovieTrackingTrack::markersnr.
Referenced by average_marker_positions(), find_next_working_frames(), and get_closest_marker().
|
static |
Definition at line 279 of file tracking_stabilize.c.
References BLI_assert, is_effectively_disabled(), markers, and MovieTrackingTrack::markers.
Referenced by average_marker_positions(), find_next_working_frames(), and get_closest_marker().
Definition at line 124 of file tracking_stabilize.c.
References MovieClip::id, id_data_find_fcurve(), NULL, MovieTracking::stabilization, and MovieClip::tracking.
Referenced by init_stabilization_working_context().
|
static |
Definition at line 134 of file tracking_stabilize.c.
References MovieClip::id, id_data_find_fcurve(), and NULL.
Referenced by init_all_tracks().
|
static |
Definition at line 434 of file tracking_stabilize.c.
References atan2f, BLI_assert, expf, len, len_v2(), mul_m2_v2(), pos, MovieTrackingMarker::pos, SCALE_ERROR_LIMIT_BIAS, TrackStabilizationBase::stabilization_rotation_base, TrackStabilizationBase::stabilization_scale_base, and sub_v2_v2v2().
Referenced by average_track_contributions().
|
static |
Definition at line 256 of file tracking_stabilize.c.
References BKE_tracking_marker_get(), and MovieTrackingTrack::markers.
Referenced by average_marker_positions(), find_next_working_frames(), and get_closest_marker().
Definition at line 368 of file tracking_stabilize.c.
References add_v2_v2(), and zero_v2().
Referenced by average_track_contributions(), and init_all_tracks().
|
static |
Definition at line 999 of file tracking_stabilize.c.
References expf, MovieTrackingStabilization::flag, float(), get_animated_locinf(), get_animated_rotinf(), get_animated_scaleinf(), get_animated_target_pos(), get_animated_target_rot(), get_animated_target_scale(), mul_v2_fl(), size(), StabContext::stab, sub_v2_v2(), and TRACKING_STABILIZE_SCALE.
Referenced by BKE_tracking_stabilization_data_get(), and calculate_autoscale_factor().
|
static |
Definition at line 1054 of file tracking_stabilize.c.
References add_v2_v2(), angle(), invert_m4_m4(), mul_m4_series, rotate_m4(), size_to_mat4(), sub_v2_v2(), and unit_m4().
Referenced by BKE_tracking_stabilization_data_to_mat4(), and calculate_autoscale_factor().
|
static |
Definition at line 931 of file tracking_stabilize.c.
References average_track_contributions(), find_next_working_frames(), MovieTrackingStabilization::flag, interpolate_averaged_track_contributions(), MAXFRAME, MINAFRAME, MINFRAME, StabContext::stab, TRACKING_2D_STABILIZATION, use_values_from_fcurves(), and zero_v2().
Referenced by BKE_tracking_stabilization_data_get(), and calculate_autoscale_factor().
|
static |
Definition at line 1287 of file tracking_stabilize.c.
References data, float(), mul_v3_m4v3(), and ImBuf::x.
Referenced by BKE_tracking_stabilize_frame().
|
static |
Definition at line 390 of file tracking_stabilize.c.
References add_v2_v2v2(), MovieTrackingMarker::pos, and TrackStabilizationBase::stabilization_offset_base.
Referenced by average_track_contributions().
|
static |
Definition at line 193 of file tracking_stabilize.c.
References NULL, and StabContext::use_animation.
Referenced by average_marker_positions(), calculate_autoscale_factor(), init_stabilizer(), and stabilization_determine_offset_for_frame().
|
static |
Definition at line 52 of file tracking_stabilize.c.
Referenced by average_marker_positions(), average_track_contributions(), and is_effectively_disabled().
|
static |
Definition at line 46 of file tracking_stabilize.c.
Referenced by init_track_for_stabilization(), and rotation_contribution().