Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-10-26 17:22:38 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-10-26 17:22:38 +0400
commit9f32e83175448eaf654cc228caa70065d63df13a (patch)
tree28e33dd37d490209be9c960b7621055ae5628458 /source
parent4a15df15711628c65282cc4d5a1dfd852776e014 (diff)
Weighted tracks
Added a weight slider to track which defines how much particular track affects in a final reconstruction. This weight is for sure animateable. Currently it affects on BA step only which in most cases will work just fine. The usecase of this slider is to have it set to 1.0 most of the time where the track is good, but blend it's weight down to 0 when tracker looses the track. This will prevent camera from jump. Tutorial is to be done by Sebastian.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_tracking.h2
-rw-r--r--source/blender/blenkernel/intern/tracking.c27
-rw-r--r--source/blender/blenloader/intern/readfile.c21
-rw-r--r--source/blender/editors/space_clip/clip_utils.c9
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c2
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h11
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c6
7 files changed, 71 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 51f97180ddb..94e530529ec 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -225,7 +225,7 @@ void BKE_tracking_homography_between_two_quads(/*const*/ float reference_corners
bool BKE_tracking_reconstruction_check(struct MovieTracking *tracking, struct MovieTrackingObject *object,
char *error_msg, int error_size);
-struct MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieTracking *tracking,
+struct MovieReconstructContext *BKE_tracking_reconstruction_context_new(struct MovieClip *clip,
struct MovieTrackingObject *object,
int keyframe1, int keyframe2,
int width, int height);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 0ce4d54a74c..d519b93f963 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -36,6 +36,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_camera_types.h"
#include "DNA_movieclip_types.h"
@@ -53,6 +54,7 @@
#include "BLF_translation.h"
+#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_tracking.h"
#include "BKE_movieclip.h"
@@ -62,6 +64,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "RNA_access.h"
+
#include "raskter.h"
#include "libmv-capi.h"
@@ -590,6 +594,7 @@ MovieTrackingTrack *BKE_tracking_track_add(MovieTracking *tracking, ListBase *tr
track->frames_limit = settings->default_frames_limit;
track->flag = settings->default_flag;
track->algorithm_flag = settings->default_algorithm_flag;
+ track->weight = 1.0f;
memset(&marker, 0, sizeof(marker));
marker.pos[0] = x;
@@ -3467,7 +3472,7 @@ typedef struct ReconstructProgressData {
} ReconstructProgressData;
/* Create new libmv Tracks structure from blender's tracks list. */
-static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, int height)
+static struct libmv_Tracks *libmv_tracks_new(MovieClip *clip, ListBase *tracksbase, int width, int height)
{
int tracknr = 0;
MovieTrackingTrack *track;
@@ -3475,15 +3480,28 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in
track = tracksbase->first;
while (track) {
+ FCurve *weight_fcurve;
int a = 0;
+ weight_fcurve = id_data_find_fcurve(&clip->id, track, &RNA_MovieTrackingTrack,
+ "weight", 0, NULL);
+
for (a = 0; a < track->markersnr; a++) {
MovieTrackingMarker *marker = &track->markers[a];
if ((marker->flag & MARKER_DISABLED) == 0) {
+ float weight = track->weight;
+
+ if (weight_fcurve) {
+ int scene_framenr =
+ BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
+ weight = evaluate_fcurve(weight_fcurve, scene_framenr);
+ }
+
libmv_tracksInsert(tracks, marker->framenr, tracknr,
(marker->pos[0] + track->offset[0]) * width,
- (marker->pos[1] + track->offset[1]) * height);
+ (marker->pos[1] + track->offset[1]) * height,
+ weight);
}
}
@@ -3730,9 +3748,10 @@ bool BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObj
* clip datablock, so editing this clip is safe during
* reconstruction job is in progress.
*/
-MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *tracking, MovieTrackingObject *object,
+MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip, MovieTrackingObject *object,
int keyframe1, int keyframe2, int width, int height)
{
+ MovieTracking *tracking = &clip->tracking;
MovieReconstructContext *context = MEM_callocN(sizeof(MovieReconstructContext), "MovieReconstructContext data");
MovieTrackingCamera *camera = &tracking->camera;
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
@@ -3793,7 +3812,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
context->sfra = sfra;
context->efra = efra;
- context->tracks = libmv_tracks_new(tracksbase, width, height * aspy);
+ context->tracks = libmv_tracks_new(clip, tracksbase, width, height * aspy);
context->keyframe1 = keyframe1;
context->keyframe2 = keyframe2;
context->refine_flags = reconstruct_refine_intrinsics_get_flags(tracking, object);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index e6804725587..51158fc5321 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9735,6 +9735,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "MovieTrackingTrack", "float", "weight")) {
+ MovieClip *clip;
+ for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object;
+ for (tracking_object = tracking->objects.first;
+ tracking_object;
+ tracking_object = tracking_object->next)
+ {
+ ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
+ MovieTrackingTrack *track;
+ for (track = tracksbase->first;
+ track;
+ track = track->next)
+ {
+ track->weight = 1.0f;
+ }
+ }
+ }
+ }
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index dfd2b6e259d..060531ae82c 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -37,7 +37,9 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BKE_animsys.h"
#include "BKE_context.h"
#include "BKE_movieclip.h"
#include "BKE_tracking.h"
@@ -184,8 +186,8 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
MovieTrackingPlaneTrack *plane_track, *next_plane_track;
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
-
bool has_bundle = false, update_stab = false;
+ char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2];
if (track == act_track)
tracking->act_track = NULL;
@@ -245,6 +247,11 @@ void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track)
}
}
+ /* Delete f-curves associated with the track (such as weight, i.e.) */
+ BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped));
+ BLI_snprintf(prefix, sizeof(prefix), "tracks[\"%s\"]", track_name_escaped);
+ BKE_animdata_fix_paths_remove(&clip->id, prefix);
+
BKE_tracking_track_free(track);
BLI_freelinkN(tracksbase, track);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 246ea7fe140..51d7bc3139a 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1550,7 +1550,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op
scj->reports = op->reports;
scj->user = sc->user;
- scj->context = BKE_tracking_reconstruction_context_new(tracking, object,
+ scj->context = BKE_tracking_reconstruction_context_new(clip, object,
object->keyframe1, object->keyframe2, width, height);
tracking->stats = MEM_callocN(sizeof(MovieTrackingStats), "solve camera stats");
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 65d36adde18..ad9a2ea169c 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -142,6 +142,17 @@ typedef struct MovieTrackingTrack {
float minimum_correlation; /* minimal correlation which is still treated as successful tracking */
struct bGPdata *gpd; /* grease-pencil data */
+
+ /* Weight of this track.
+ *
+ * Weight defines how much the track affects on the final reconstruction,
+ * usually gets animated in a way so when track has just appeared it's
+ * weight is zero and then it gets faded up.
+ *
+ * Used to prevent jumps of the camera when tracks are appearing or
+ * disappearing.
+ */
+ float weight, pad;
} MovieTrackingTrack;
typedef struct MovieTrackingPlaneMarker {
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index 8e26bb96a1f..f62778a5c1e 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -1339,6 +1339,12 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "GreasePencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
+ /* weight */
+ prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "weight");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Weight", "How much this track affects on a final solution");
}
static void rna_def_trackingPlaneMarker(BlenderRNA *brna)