Camera tracking integration

===========================

- Internal changes:
  * Rename uiTemplateMarker to uiTemplateTrack.
  * Fixed some comments in movieclip.c.
- Control channels which are affect on track.
- Fixed track deletion when it's point isn't selected.
This commit is contained in:
Sergey Sharybin
2011-06-28 10:09:57 +00:00
parent def04fa523
commit 75889661de
10 changed files with 65 additions and 19 deletions

View File

@@ -82,10 +82,10 @@ class CLIP_PT_tools(bpy.types.Panel):
layout.operator('clip.open')
class CLIP_PT_marker_preview(bpy.types.Panel):
class CLIP_PT_track(bpy.types.Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_label = "Marker Preview"
bl_label = "Track"
@classmethod
def poll(cls, context):
@@ -99,7 +99,15 @@ class CLIP_PT_marker_preview(bpy.types.Panel):
sc = context.space_data
clip = context.space_data.clip
layout.template_marker(clip.tracking, "act_track", sc.clip_user, clip)
layout.template_track(clip.tracking, "act_track", sc.clip_user, clip)
act_track = clip.tracking.act_track
if act_track:
row = layout.row()
row.prop(act_track, "use_red_channel", text="Red")
row.prop(act_track, "use_green_channel", text="Green")
row.prop(act_track, "use_blue_channel", text="Blue")
class CLIP_PT_track_settings(bpy.types.Panel):

View File

@@ -357,11 +357,7 @@ void BKE_movieclip_reload(MovieClip *clip)
else clip->source= MCLIP_SRC_SEQUENCE;
}
/* area - which part of marker should be selected:
0 - the whole marker and pattern/search
1 - only marker
2 - only pattern
3 - only search */
/* area - which part of marker should be selected. see TRACK_AREA_* constants */
void BKE_movieclip_select_track(MovieClip *clip, MovieTrackingTrack *track, int area, int extend)
{
if(extend) {

View File

@@ -354,6 +354,25 @@ void BKE_tracking_context_free(MovieTrackingContext *context)
MEM_freeN(context);
}
static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track)
{
int x, y;
if((track->flag&(TRACK_DISABLE_RED|TRACK_DISABLE_GREEN|TRACK_DISABLE_BLUE))==0)
return;
for(y= 0; y<ibuf->x; y++) {
for (x= 0; x<ibuf->y; x++) {
int pixel= ibuf->x*y + x;
char *rrgb= (char*)ibuf->rect + pixel*4;
if(track->flag&TRACK_DISABLE_RED) rrgb[0]= 0;
if(track->flag&TRACK_DISABLE_GREEN) rrgb[1]= 0;
if(track->flag&TRACK_DISABLE_BLUE) rrgb[2]= 0;
}
}
}
static ImBuf *acquire_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, float min[2], float max[2], int pos[2])
{
ImBuf *tmpibuf;
@@ -381,6 +400,8 @@ static ImBuf *acquire_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTr
pos[0]= x-x1;
pos[1]= y-y1;
disable_imbuf_channels(tmpibuf, track);
return tmpibuf;
}
@@ -409,6 +430,7 @@ static float *acquire_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo
IMB_rectcpy(tmpibuf, ibuf, 0, 0,
(track->search_min[0]+marker->pos[0])*ibuf->x,
(track->search_min[1]+marker->pos[1])*ibuf->y, width, height);
disable_imbuf_channels(tmpibuf, track);
*width_r= width;
*height_r= height;

View File

@@ -726,7 +726,7 @@ void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, int rows, int maxrows, int type);
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr);
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr);
/* items */
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);

View File

@@ -278,8 +278,8 @@ void ED_clip_buttons_register(ARegionType *art)
PanelType *pt;
pt= MEM_callocN(sizeof(PanelType), "spacetype clip panel marker");
strcpy(pt->idname, "CLIP_PT_active_marker");
strcpy(pt->label, "Active Marker");
strcpy(pt->idname, "CLIP_PT_marker");
strcpy(pt->label, "Marker");
pt->draw= clip_panel_marker;
pt->poll= clip_panel_marker_poll;
@@ -336,7 +336,7 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
/********************* Marker Template ************************/
void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *clipptr)
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *clipptr)
{
PropertyRNA *prop;
PointerRNA trackptr;
@@ -352,12 +352,12 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
printf("uiTemplateMarker: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
printf("uiTemplateTrack: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}
if(RNA_property_type(prop) != PROP_POINTER) {
printf("uiTemplateMarker: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname);
printf("uiTemplateTrack: expected pointer property for %s.%s\n", RNA_struct_identifier(ptr->type), propname);
return;
}

View File

@@ -216,7 +216,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
while(track) {
next= track->next;
if(track->flag&SELECT) {
if(TRACK_SELECTED(track)) {
BKE_tracking_free_track(track);
BLI_freelinkN(&clip->tracking.tracks, track);
}

View File

@@ -107,7 +107,10 @@ typedef struct MovieTracking {
#define MARKER_DISABLED 1
/* MovieTrackingTrack->flag */
#define TRACK_PROCESSED 2
#define TRACK_PROCESSED (1<<1)
#define TRACK_DISABLE_RED (1<<2)
#define TRACK_DISABLE_GREEN (1<<3)
#define TRACK_DISABLE_BLUE (1<<4)
/* MovieTrackingSettings->speed */
#define TRACKING_SPEED_FASTEST 0

View File

@@ -235,6 +235,23 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "MovieTrackingMarker");
RNA_def_property_collection_sdna(prop, NULL, "markers", "markersnr");
RNA_def_property_ui_text(prop, "Markers", "Collection of markers in track");
/* ** channels ** */
/* use_red_channel */
prop= RNA_def_property(srna, "use_red_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_RED);
RNA_def_property_ui_text(prop, "Use Red Channel", "Use red channel from footage for tracking");
/* use_green_channel */
prop= RNA_def_property(srna, "use_green_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_GREEN);
RNA_def_property_ui_text(prop, "Use Green Channel", "Use green channel from footage for tracking");
/* use_blue_channel */
prop= RNA_def_property(srna, "use_blue_channel", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_BLUE);
RNA_def_property_ui_text(prop, "Use Blue Channel", "Use blue channel from footage for tracking");
}
static void rna_def_tracking(BlenderRNA *brna)

View File

@@ -400,8 +400,8 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
RNA_def_boolean(func, "compact", 0, "", "Use more compact layout.");
func= RNA_def_function(srna, "template_marker", "uiTemplateMarker");
RNA_def_function_ui_description(func, "Item. A marker widget to analyze imaga marker is pointed to.");
func= RNA_def_function(srna, "template_track", "uiTemplateTrack");
RNA_def_function_ui_description(func, "Item. A tarck widget to analyze imaga marker is pointed to.");
api_ui_item_rna_common(func);
parm= RNA_def_pointer(func, "clip", "MovieClip", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);

View File

@@ -364,7 +364,7 @@ void uiTemplateReportsBanner(struct uiLayout *layout, struct bContext *C, struct
void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *propname, int expand){}
void uiTemplateVectorscope(struct uiLayout *_self, struct PointerRNA *data, char* property, int expand){}
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact){}
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr){}
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, struct PointerRNA *clipptr){}
/* rna render */
struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;}