[Bf-blender-cvs] [2785e8e] master: Split tracking.c into several files
Sergey Sharybin
noreply at git.blender.org
Wed Jan 1 17:37:54 CET 2014
Commit: 2785e8e73d3473cf481ba65a6b50a50c194e63d8
Author: Sergey Sharybin
Date: Mon Dec 30 17:03:59 2013 +0600
https://developer.blender.org/rB2785e8e73d3473cf481ba65a6b50a50c194e63d8
Split tracking.c into several files
File tracking.c became rather huge and annoying to
maintain and it really contains several independent
areas of motrack pipeline.
Now we've got:
* tracking.c: general-purpose functions which are used
by blender, clip editor, RNA and so.
* tracking_detect.c: feature detection functions
(blender-side, logic is still in libmv).
* tracking_plane_tracker.c: blender-side 2D tracking logic.
* tracking_plane_tracker.c: plane track tracker.
* tracking_solver.c: functions for camera solving.
* tracking_stabilize.c: 2D stabilization functions.
* tracking_util.c: utility functions for all those files
and which shouldn't be public.
===================================================================
M source/blender/blenkernel/BKE_tracking.h
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/tracking.c
A source/blender/blenkernel/intern/tracking_detect.c
A source/blender/blenkernel/intern/tracking_plane_tracker.c
A source/blender/blenkernel/intern/tracking_region_tracker.c
A source/blender/blenkernel/intern/tracking_solver.c
A source/blender/blenkernel/intern/tracking_stabilize.c
A source/blender/blenkernel/intern/tracking_util.c
A source/blender/blenkernel/tracking_private.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 94e5305..9936416 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -74,6 +74,7 @@ void BKE_tracking_clipboard_paste_tracks(struct MovieTracking *tracking, struct
/* **** Track **** */
struct MovieTrackingTrack *BKE_tracking_track_add(struct MovieTracking *tracking, struct ListBase *tracksbase,
float x, float y, int framenr, int width, int height);
+struct MovieTrackingTrack *BKE_tracking_track_duplicate(struct MovieTrackingTrack *track);
void BKE_tracking_track_unique_name(struct ListBase *tracksbase, struct MovieTrackingTrack *track);
void BKE_tracking_track_free(struct MovieTrackingTrack *track);
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index c4c4427..18ed401 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -154,6 +154,12 @@ set(SRC
intern/text.c
intern/texture.c
intern/tracking.c
+ intern/tracking_detect.c
+ intern/tracking_plane_tracker.c
+ intern/tracking_region_tracker.c
+ intern/tracking_solver.c
+ intern/tracking_stabilize.c
+ intern/tracking_util.c
intern/treehash.c
intern/unit.c
intern/world.c
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index e07d84a..fec6733 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -69,6 +69,7 @@
#include "raskter.h"
#include "libmv-capi.h"
+#include "tracking_private.h"
typedef struct MovieDistortion {
struct libmv_CameraIntrinsics *intrinsics;
@@ -80,21 +81,6 @@ static struct {
/*********************** Common functions *************************/
-/* Duplicate the specified track, result will no belong to any list. */
-static MovieTrackingTrack *tracking_track_duplicate(MovieTrackingTrack *track)
-{
- MovieTrackingTrack *new_track;
-
- new_track = MEM_callocN(sizeof(MovieTrackingTrack), "tracking_track_duplicate new_track");
-
- *new_track = *track;
- new_track->next = new_track->prev = NULL;
-
- new_track->markers = MEM_dupallocN(new_track->markers);
-
- return new_track;
-}
-
/* Free the whole list of tracks, list's head and tail are set to NULL. */
static void tracking_tracks_free(ListBase *tracks)
{
@@ -328,141 +314,6 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingOb
}
}
-/* **** space transformation functions **** */
-
-/* Three coordinate frames: Frame, Search, and Marker
- * Two units: Pixels, Unified
- * Notation: {coordinate frame}_{unit}; for example, "search_pixel" are search
- * window relative coordinates in pixels, and "frame_unified" are unified 0..1
- * coordinates relative to the entire frame.
- */
-static void unified_to_pixel(int frame_width, int frame_height,
- const float unified_coords[2], float pixel_coords[2])
-{
- pixel_coords[0] = unified_coords[0] * frame_width;
- pixel_coords[1] = unified_coords[1] * frame_height;
-}
-
-static void marker_to_frame_unified(const MovieTrackingMarker *marker, const float marker_unified_coords[2],
- float frame_unified_coords[2])
-{
- frame_unified_coords[0] = marker_unified_coords[0] + marker->pos[0];
- frame_unified_coords[1] = marker_unified_coords[1] + marker->pos[1];
-}
-
-static void marker_unified_to_frame_pixel_coordinates(int frame_width, int frame_height,
- const MovieTrackingMarker *marker,
- const float marker_unified_coords[2],
- float frame_pixel_coords[2])
-{
- marker_to_frame_unified(marker, marker_unified_coords, frame_pixel_coords);
- unified_to_pixel(frame_width, frame_height, frame_pixel_coords, frame_pixel_coords);
-}
-
-static void get_search_origin_frame_pixel(int frame_width, int frame_height,
- const MovieTrackingMarker *marker, float frame_pixel[2])
-{
- /* Get the lower left coordinate of the search window and snap to pixel coordinates */
- marker_unified_to_frame_pixel_coordinates(frame_width, frame_height, marker, marker->search_min, frame_pixel);
- frame_pixel[0] = (int)frame_pixel[0];
- frame_pixel[1] = (int)frame_pixel[1];
-}
-
-static void pixel_to_unified(int frame_width, int frame_height, const float pixel_coords[2], float unified_coords[2])
-{
- unified_coords[0] = pixel_coords[0] / frame_width;
- unified_coords[1] = pixel_coords[1] / frame_height;
-}
-
-static void marker_unified_to_search_pixel(int frame_width, int frame_height,
- const MovieTrackingMarker *marker,
- const float marker_unified[2], float search_pixel[2])
-{
- float frame_pixel[2];
- float search_origin_frame_pixel[2];
-
- marker_unified_to_frame_pixel_coordinates(frame_width, frame_height, marker, marker_unified, frame_pixel);
- get_search_origin_frame_pixel(frame_width, frame_height, marker, search_origin_frame_pixel);
- sub_v2_v2v2(search_pixel, frame_pixel, search_origin_frame_pixel);
-}
-
-static void search_pixel_to_marker_unified(int frame_width, int frame_height,
- const MovieTrackingMarker *marker,
- const float search_pixel[2], float marker_unified[2])
-{
- float frame_unified[2];
- float search_origin_frame_pixel[2];
-
- get_search_origin_frame_pixel(frame_width, frame_height, marker, search_origin_frame_pixel);
- add_v2_v2v2(frame_unified, search_pixel, search_origin_frame_pixel);
- pixel_to_unified(frame_width, frame_height, frame_unified, frame_unified);
-
- /* marker pos is in frame unified */
- sub_v2_v2v2(marker_unified, frame_unified, marker->pos);
-}
-
-/* Each marker has 5 coordinates associated with it that get warped with
- * tracking: the four corners ("pattern_corners"), and the center ("pos").
- * This function puts those 5 points into the appropriate frame for tracking
- * (the "search" coordinate frame).
- */
-static void get_marker_coords_for_tracking(int frame_width, int frame_height,
- const MovieTrackingMarker *marker,
- double search_pixel_x[5], double search_pixel_y[5])
-{
- int i;
- float unified_coords[2];
- float pixel_coords[2];
-
- /* Convert the corners into search space coordinates. */
- for (i = 0; i < 4; i++) {
- marker_unified_to_search_pixel(frame_width, frame_height, marker, marker->pattern_corners[i], pixel_coords);
- search_pixel_x[i] = pixel_coords[0] - 0.5f;
- search_pixel_y[i] = pixel_coords[1] - 0.5f;
- }
-
- /* Convert the center position (aka "pos"); this is the origin */
- unified_coords[0] = 0.0f;
- unified_coords[1] = 0.0f;
- marker_unified_to_search_pixel(frame_width, frame_height, marker, unified_coords, pixel_coords);
-
- search_pixel_x[4] = pixel_coords[0] - 0.5f;
- search_pixel_y[4] = pixel_coords[1] - 0.5f;
-}
-
-/* Inverse of above. */
-static void set_marker_coords_from_tracking(int frame_width, int frame_height, MovieTrackingMarker *marker,
- const double search_pixel_x[5], const double search_pixel_y[5])
-{
- int i;
- float marker_unified[2];
- float search_pixel[2];
-
- /* Convert the corners into search space coordinates. */
- for (i = 0; i < 4; i++) {
- search_pixel[0] = search_pixel_x[i] + 0.5;
- search_pixel[1] = search_pixel_y[i] + 0.5;
- search_pixel_to_marker_unified(frame_width, frame_height, marker, search_pixel, marker->pattern_corners[i]);
- }
-
- /* Convert the center position (aka "pos"); this is the origin */
- search_pixel[0] = search_pixel_x[4] + 0.5;
- search_pixel[1] = search_pixel_y[4] + 0.5;
- search_pixel_to_marker_unified(frame_width, frame_height, marker, search_pixel, marker_unified);
-
- /* If the tracker tracked nothing, then "marker_unified" would be zero.
- * Otherwise, the entire patch shifted, and that delta should be applied to
- * all the coordinates.
- */
- for (i = 0; i < 4; i++) {
- marker->pattern_corners[i][0] -= marker_unified[0];
- marker->pattern_corners[i][1] -= marker_unified[1];
- }
-
- marker->pos[0] += marker_unified[0];
- marker->pos[1] += marker_unified[1];
-}
-
/*********************** clipboard *************************/
/* Free clipboard by freeing memory used by all tracks in it. */
@@ -494,7 +345,7 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingOb
/* Then copy all selected visible tracks to it. */
while (track) {
if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
- MovieTrackingTrack *new_track = tracking_track_duplicate(track);
+ MovieTrackingTrack *new_track = BKE_tracking_track_duplicate(track);
BLI_addtail(&tracking_clipboard.tracks, new_track);
}
@@ -520,7 +371,7 @@ void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingO
MovieTrackingTrack *track = tracking_clipboard.tracks.first;
while (track) {
- MovieTrackingTrack *new_track = tracking_track_duplicate(track);
+ MovieTrackingTrack *new_track = BKE_tracking_track_duplicate(track);
BLI_addtail(tracksbase, new_track);
BKE_tracking_track_unique_name(tracksbase, new_track);
@@ -531,33 +382,6 @@ void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingO
/*********************** Tracks *************************/
-/* Place a disabled marker before or after specified ref_marker.
- *
- * If before is truth, disabled marker is placed before reference
- * one, and it's placed after it otherwise.
- *
- * If there's already a marker at the frame where disabled one
- * is expected to be placed, nothing will happen if overwrite
- * is false.
- */
-static void tracking_marker_insert_disabled(MovieTrackingTrack *track, const MovieTrackingMarker *ref_marker,
- bool before, bool overwrite)
-{
- MovieTrackingMarker marker_new;
-
- marker_new = *ref_marker
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list