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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-01-28 16:01:03 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-01-28 16:02:22 +0400
commitbe6643b5ec01c8f64a1065762c38ce8803b717c0 (patch)
treeec8ffa055277aba2b1fecc636efde0a84140fc35
parentc2da706a36ca355509d9dc2abcffc1edc6c49fff (diff)
Followup to the previous commit
Need to take weight into account when drawing per-frame track reprojection curve and when computing per-track average error.
-rw-r--r--extern/libmv/libmv-capi.cc7
-rw-r--r--source/blender/blenkernel/BKE_tracking.h2
-rw-r--r--source/blender/blenkernel/intern/tracking.c17
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c5
4 files changed, 27 insertions, 4 deletions
diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc
index 9a536f718aa..5bc159c64af 100644
--- a/extern/libmv/libmv-capi.cc
+++ b/extern/libmv/libmv-capi.cc
@@ -760,18 +760,19 @@ double libmv_reprojectionErrorForTrack(const struct libmv_Reconstruction *libmv_
double total_error = 0.0;
for (int i = 0; i < markers.size(); ++i) {
+ double weight = markers[i].weight;
const libmv::EuclideanCamera *camera = reconstruction->CameraForImage(markers[i].image);
const libmv::EuclideanPoint *point = reconstruction->PointForTrack(markers[i].track);
- if (!camera || !point) {
+ if (!camera || !point || weight == 0.0) {
continue;
}
num_reprojected++;
libmv::Marker reprojected_marker = ProjectMarker(*point, *camera, *intrinsics);
- double ex = reprojected_marker.x - markers[i].x;
- double ey = reprojected_marker.y - markers[i].y;
+ double ex = (reprojected_marker.x - markers[i].x) * weight;
+ double ey = (reprojected_marker.y - markers[i].y) * weight;
total_error += sqrt(ex * ex + ey * ey);
}
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 62149bbaf88..081547f94f0 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -98,6 +98,8 @@ struct MovieTrackingTrack *BKE_tracking_track_get_active(struct MovieTracking *t
float *BKE_tracking_track_get_mask(int frame_width, int frame_height, struct MovieTrackingTrack *track,
struct MovieTrackingMarker *marker);
+float BKE_tracking_track_get_weight_for_marker(struct MovieClip *clip, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker);
+
/* selection */
void BKE_tracking_track_select(struct ListBase *tracksbase, struct MovieTrackingTrack *track, int area, bool extend);
void BKE_tracking_track_deselect(struct MovieTrackingTrack *track, int area);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index e01909322eb..ab314d8b148 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -864,6 +864,23 @@ float *BKE_tracking_track_get_mask(int frame_width, int frame_height,
return mask;
}
+float BKE_tracking_track_get_weight_for_marker(MovieClip *clip, MovieTrackingTrack *track, MovieTrackingMarker *marker)
+{
+ FCurve *weight_fcurve;
+ float weight = track->weight;
+
+ weight_fcurve = id_data_find_fcurve(&clip->id, track, &RNA_MovieTrackingTrack,
+ "weight", 0, NULL);
+
+ if (weight_fcurve) {
+ int scene_framenr =
+ BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
+ weight = evaluate_fcurve(weight_fcurve, scene_framenr);
+ }
+
+ return weight;
+}
+
/* area - which part of marker should be selected. see TRACK_AREA_* constants */
void BKE_tracking_track_select(ListBase *tracksbase, MovieTrackingTrack *track, int area, bool extend)
{
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index 16845bb10fb..67c8bd87527 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -192,6 +192,7 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc)
}
typedef struct TrackErrorCurveUserData {
+ MovieClip *clip;
MovieTracking *tracking;
MovieTrackingObject *tracking_object;
MovieTrackingTrack *active_track;
@@ -210,6 +211,7 @@ static void tracking_error_segment_point_cb(void *userdata,
TrackErrorCurveUserData *data = (TrackErrorCurveUserData *) userdata;
float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];
float reprojection_error;
+ float weight = BKE_tracking_track_get_weight_for_marker(data->clip, track, marker);
if (!data->matrix_initialized || data->matrix_frame != scene_framenr) {
BKE_tracking_get_projection_matrix(data->tracking, data->tracking_object,
@@ -232,7 +234,7 @@ static void tracking_error_segment_point_cb(void *userdata,
marker_position[1] = (marker->pos[1] + track->offset[1]) * data->height * data->aspy;
sub_v2_v2v2(delta, reprojected_position, marker_position);
- reprojection_error = len_v2(delta);
+ reprojection_error = len_v2(delta) * track->weight;
glVertex2f(scene_framenr, reprojection_error);
}
@@ -273,6 +275,7 @@ static void draw_tracks_error_curves(SpaceClip *sc)
MovieTracking *tracking = &clip->tracking;
TrackErrorCurveUserData data;
+ data.clip = clip;
data.tracking = tracking;
data.tracking_object = BKE_tracking_object_get_active(tracking);
data.active_track = BKE_tracking_track_get_active(tracking);