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>2011-10-13 21:54:05 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-10-13 21:54:05 +0400
commit594e9e0689b773af852a17353010d26024485937 (patch)
tree3d45d862dc25d1ccf2b23457cbc027046036111f /source/blender
parent1d27e1c849f5198b18984cfc1bdc9562ec2f9c33 (diff)
Camera tracking integration
=========================== Added option to choose which method to use for feature detector: FAST or Moravec Moravec was supposed to be more "stable", but it collected worse feedback. before returning back to FAST detector added option to easier toggle between different detector to compare it's result and find out if we can leave only FAST.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_tracking.h2
-rw-r--r--source/blender/blenkernel/intern/tracking.c8
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c39
3 files changed, 45 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 84e2acfb147..0e29bb44181 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -87,7 +87,7 @@ void BKE_tracking_projection_matrix(struct MovieTracking *tracking, int framenr,
void BKE_tracking_apply_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
void BKE_tracking_invert_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
-void BKE_tracking_detect(struct MovieTracking *tracking, struct ImBuf *imbuf, int framenr, int margin, int count, int min_distance);
+void BKE_tracking_detect(struct MovieTracking *tracking, struct ImBuf *imbuf, int framenr, int margin, int min_trackness, int count, int min_distance, int fast);
struct MovieTrackingTrack *BKE_tracking_indexed_bundle(struct MovieTracking *tracking, int bundlenr);
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 9ad7b963447..9f5478df0b1 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1526,14 +1526,18 @@ static unsigned char *acquire_ucharbuf(ImBuf *ibuf)
}
#endif
-void BKE_tracking_detect(MovieTracking *tracking, ImBuf *ibuf, int framenr, int margin, int count, int min_distance)
+void BKE_tracking_detect(MovieTracking *tracking, ImBuf *ibuf, int framenr, int margin, int min_trackness, int count, int min_distance, int fast)
{
#ifdef WITH_LIBMV
struct libmv_Features *features;
unsigned char *pixels= acquire_ucharbuf(ibuf);
int a;
- features= libmv_detectFeatures(pixels, ibuf->x, ibuf->y, ibuf->x, margin, count, min_distance);
+ if(fast)
+ features= libmv_detectFeaturesFAST(pixels, ibuf->x, ibuf->y, ibuf->x, margin, min_trackness, min_distance);
+ else
+ features= libmv_detectFeaturesMORAVEC(pixels, ibuf->x, ibuf->y, ibuf->x, margin, count, min_distance);
+
MEM_freeN(pixels);
a= libmv_countFeatures(features);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 1651d4cea7e..3a559bbf935 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -2214,7 +2214,9 @@ static int detect_features_exec(bContext *C, wmOperator *op)
MovieClip *clip= ED_space_clip(sc);
ImBuf *ibuf= BKE_movieclip_acquire_ibuf_flag(clip, &sc->user, 0);
MovieTrackingTrack *track= clip->tracking.tracks.first;
+ int detector= RNA_enum_get(op->ptr, "detector");
int margin= RNA_int_get(op->ptr, "margin");
+ int min_trackness= RNA_int_get(op->ptr, "min_trackness");
int count= RNA_int_get(op->ptr, "count");
int min_distance= RNA_int_get(op->ptr, "min_distance");
@@ -2227,7 +2229,7 @@ static int detect_features_exec(bContext *C, wmOperator *op)
track= track->next;
}
- BKE_tracking_detect(&clip->tracking, ibuf, sc->user.framenr, margin, count, min_distance);
+ BKE_tracking_detect(&clip->tracking, ibuf, sc->user.framenr, margin, min_trackness, count, min_distance, detector==0);
IMB_freeImBuf(ibuf);
@@ -2236,8 +2238,40 @@ static int detect_features_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static void detect_features_draw(bContext *C, wmOperator *op)
+{
+ uiLayout *layout = op->layout;
+ wmWindowManager *wm= CTX_wm_manager(C);
+ PointerRNA ptr;
+ int detector= RNA_enum_get(op->ptr, "detector");
+ PropertyRNA *prop_min_trackness;
+ PropertyRNA *prop_count;
+
+ prop_min_trackness= RNA_struct_find_property(op->ptr, "min_trackness");
+ prop_count= RNA_struct_find_property(op->ptr, "count");
+
+ if(detector==0) {
+ RNA_def_property_clear_flag(prop_min_trackness, PROP_HIDDEN);
+ RNA_def_property_flag(prop_count, PROP_HIDDEN);
+ } else {
+ RNA_def_property_flag(prop_min_trackness, PROP_HIDDEN);
+ RNA_def_property_clear_flag(prop_count, PROP_HIDDEN);
+ }
+
+ RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
+
+ /* main draw call */
+ uiDefAutoButsRNA(layout, &ptr, NULL, 'V');
+}
+
void CLIP_OT_detect_features(wmOperatorType *ot)
{
+ static EnumPropertyItem detector_items[] = {
+ {0, "FAST", 0, "FAST", "FAST corner detector"},
+ {1, "MORAVEC", 0, "Moravec", "Moravec corner detector"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* identifiers */
ot->name= "Detect Features";
ot->description= "Automatically detect features to track";
@@ -2246,12 +2280,15 @@ void CLIP_OT_detect_features(wmOperatorType *ot)
/* api callbacks */
ot->exec= detect_features_exec;
ot->poll= space_clip_frame_poll;
+ ot->ui= detect_features_draw;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
+ RNA_def_enum(ot->srna, "detector", detector_items, 0, "Detector", "Detector using for detecting features");
RNA_def_int(ot->srna, "margin", 16, 0, INT_MAX, "Margin", "Only corners further than margin pixels from the image edges are considered", 0, 300);
+ RNA_def_int(ot->srna, "min_trackness", 16, 0, INT_MAX, "Trackness", "Minimum score to add a corner", 0, 300);
RNA_def_int(ot->srna, "count", 50, 1, INT_MAX, "Count", "Count of corners to detect", 0, 300);
RNA_def_int(ot->srna, "min_distance", 120, 0, INT_MAX, "Distance", "Minimal distance accepted between two corners", 0, 300);
}