Camera tracking integration

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

initial re-design commit:
- Added Mode to Clip Editor. Currently the following modes are present:
  * Tracking/Solving mode (default)
	* Reconstruction mode
	* Distortion mode
- Hide all tools/properties which doesn't make sense in current mode.
- Keep a look at new template template_marker. It's needed to control
  marker's properties, changing of which should produce new keyframe.
  Currently only "Enabled" property can be control. Probably all
	properties from "Marker" panel could go there so this template
	wouldn't be so specific.
- No operators are disabled for non-their mode. It means they
  can be triggered from Space menu or hotkey.
	Need clear map operators into mode to prevent mess of poll function.
This commit is contained in:
Sergey Sharybin 2011-08-16 08:01:23 +00:00
parent 215da938ff
commit c32e8912de
14 changed files with 473 additions and 161 deletions

@ -21,9 +21,9 @@ import bpy
from bpy.types import Operator, Panel, Header, Menu
class CLIP_OT_apply_follow_track(Operator):
bl_idname = "clip.apply_follow_track"
bl_label = "Apply Follow Track"
class CLIP_OT_track_to_empty(Operator):
bl_idname = "clip.track_to_empty"
bl_label = "2D Track to Emppty"
bl_options = {'UNDO', 'REGISTER'}
@classmethod
@ -34,14 +34,24 @@ class CLIP_OT_apply_follow_track(Operator):
sc = context.space_data
clip = sc.clip
return clip and clip.tracking.active_track and context.active_object
return clip and clip.tracking.active_track
def execute(self, context):
ob = context.active_object
sc = context.space_data
clip = sc.clip
track = clip.tracking.active_track
constraint = None
ob = None
if track.name in bpy.data.objects:
if bpy.data.objects[track.name].type == 'Empty':
ob = bpy.data.objects[track.name]
if not ob:
ob = bpy.data.objects.new(name=track.name, object_data=None)
ob.select = True
bpy.context.scene.objects.link(ob)
bpy.context.scene.objects.active = ob
for con in ob.constraints:
if con.type == 'FOLLOW_TRACK':
@ -111,14 +121,20 @@ class CLIP_HT_header(Header):
sub.menu("CLIP_MT_select")
sub.menu("CLIP_MT_track")
layout.template_ID(sc, "clip")
layout.template_running_jobs()
if clip:
layout.prop(sc, "mode", text="")
row = layout.row()
row.template_ID(sc, "clip", open='clip.open')
if clip:
r = clip.tracking.reconstruction
if r.is_reconstructed:
layout.label(text="Average solve error: %.4f" % (r.average_error))
layout.label(text="Average solve error: %.4f" % \
(r.average_error))
layout.template_running_jobs()
class CLIP_PT_tools(Panel):
@ -126,94 +142,209 @@ class CLIP_PT_tools(Panel):
bl_region_type = 'TOOLS'
bl_label = "Tools"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return not clip and sc.mode == 'TRACKING'
def draw(self, context):
layout = self.layout
layout.operator('clip.open')
class CLIP_PT_tools_marker(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Marker"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return clip and sc.mode == 'TRACKING'
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.operator("clip.add_marker_move")
col.operator("clip.detect_features")
col.operator("clip.delete_track")
class CLIP_PT_tools_tracking(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Track"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return clip and sc.mode == 'TRACKING'
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
settings = clip.tracking.settings
if clip:
settings = clip.tracking.settings
row = layout.row(align=True)
col = layout.column(align=True)
col.label(text="Marker:")
col.operator("clip.add_marker_move")
col.operator("clip.delete_track")
col.operator("clip.delete_marker")
op = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
op.backwards = True
op = row.operator("clip.track_markers", text="", \
icon='PLAY_REVERSE')
op.backwards = True
op.sequence = True
op = row.operator("clip.track_markers", text="", icon='PLAY')
op.sequence = True
row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
col = layout.column(align=True)
col.label(text="2D tracking:")
row = col.row(align=True)
col = layout.column(align=True)
op = col.operator("clip.clear_track_path", \
text="Clear Remained Path")
op.action = 'REMAINED'
op = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
op.backwards = True
op = row.operator("clip.track_markers", text="", \
icon='PLAY_REVERSE')
op.backwards = True
op.sequence = True
op = row.operator("clip.track_markers", text="", icon='PLAY')
op.sequence = True
row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
op = col.operator("clip.clear_track_path", text="Clear Path Up To")
op.action = 'UPTO'
col = layout.column(align=True)
op = col.operator("clip.clear_track_path", \
text="Clear Remained Path")
op.action = 'REMAINED'
op = col.operator("clip.clear_track_path", text="Clear Track Path")
op.action = 'ALL'
op = col.operator("clip.clear_track_path", text="Clear Path Up To")
op.action = 'UPTO'
layout.operator("clip.join_tracks")
op = col.operator("clip.clear_track_path", text="Clear Track Path")
op.action = 'ALL'
layout.operator("clip.join_tracks")
layout.operator("clip.detect_features")
layout.operator("clip.apply_follow_track")
class CLIP_PT_tools_solving(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Solving"
col = layout.column(align=True)
col.label(text="Reconstruction:")
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
col.prop(settings, "keyframe1")
col.prop(settings, "keyframe2")
return clip and sc.mode == 'TRACKING'
col = layout.column(align=True)
col.operator("clip.solve_camera")
col.operator("clip.clear_reconstruction")
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
settings = clip.tracking.settings
col = layout.column(align=True)
col.operator("clip.bundles_to_mesh")
col = layout.column(align=True)
col.prop(settings, "keyframe1")
col.prop(settings, "keyframe2")
col = layout.column(align=True)
col.label(text="Scene Orientation:")
col.operator("clip.set_floor")
col.operator("clip.set_origin")
col = layout.column(align=True)
col.operator("clip.solve_camera")
col.operator("clip.clear_solution")
row = col.row()
row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
col = layout.column()
col.prop(settings, "distance")
col.operator("clip.set_scale")
class CLIP_PT_tools_cleanup(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Clean up"
col = layout.column(align=True)
col.label(text="Clean-up:")
col.operator("clip.clean_tracks")
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
col = layout.column(align=True)
col.label(text="Grease Pencil:")
return clip and sc.mode == 'TRACKING'
row = col.row()
row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
settings = clip.tracking.settings
row = col.row()
row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
layout.prop(settings, 'clean_frames', text="Frames")
layout.prop(settings, 'clean_error', text="Error")
layout.prop(settings, 'clean_action', text="")
row = col.row()
row.prop(context.tool_settings, "use_grease_pencil_sessions")
layout.operator("clip.clean_tracks")
else:
layout.operator('clip.open')
class CLIP_PT_tools_geometry(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Geometry"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return clip and sc.mode == 'RECONSTRUCTION'
def draw(self, context):
layout = self.layout
layout.operator("clip.bundles_to_mesh")
layout.operator("clip.track_to_empty")
class CLIP_PT_tools_orientation(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Orientation"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return clip and sc.mode == 'RECONSTRUCTION'
def draw(self, context):
sc = context.space_data
layout = self.layout
settings = sc.clip.tracking.settings
col = layout.column(align=True)
col.label(text="Scene Orientation:")
col.operator("clip.set_floor")
col.operator("clip.set_origin")
row = col.row()
row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
col = layout.column()
col.prop(settings, "distance")
col.operator("clip.set_scale")
class CLIP_PT_tools_grease_pencil(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Grease Pencil"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return clip and sc.mode == 'DISTORTION'
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
row = col.row(align=True)
row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
row = col.row(align=True)
row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
row = col.row()
row.prop(context.tool_settings, "use_grease_pencil_sessions")
class CLIP_PT_track(Panel):
@ -226,7 +357,7 @@ class CLIP_PT_track(Panel):
sc = context.space_data
clip = sc.clip
return clip and clip.tracking.active_track
return sc.mode == 'TRACKING' and clip and clip.tracking.active_track
def draw(self, context):
layout = self.layout
@ -234,8 +365,26 @@ class CLIP_PT_track(Panel):
clip = context.space_data.clip
act_track = clip.tracking.active_track
layout.prop(act_track, "name")
layout.prop(act_track, "locked")
marker = act_track.get_marker(sc.clip_user.current_frame)
row = layout.row()
row.prop(act_track, "name", text="")
sub = row.row(align=True)
sub.template_marker(clip.tracking, "active_track", sc.clip_user)
icon = 'LOCKED' if act_track.locked else 'UNLOCKED'
sub.prop(act_track, "locked", text="", icon=icon)
layout.template_track(sc, "scopes")
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")
layout.separator()
row = layout.row(align=True)
label = bpy.types.CLIP_MT_track_color_presets.bl_label
@ -251,44 +400,11 @@ class CLIP_PT_track(Panel):
if act_track.use_custom_color:
row.prop(act_track, "color", text="")
layout.template_track(sc, "scopes")
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")
if act_track.has_bundle:
label_text = "Average Error: %.4f" % (act_track.average_error)
layout.label(text=label_text)
class CLIP_PT_track_settings(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_label = "Tracking Settings"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
sc = context.space_data
return sc.clip
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
settings = clip.tracking.settings
layout.label(text="2D tracking:")
layout.prop(settings, "speed")
layout.prop(settings, "use_frames_limit")
row = layout.row()
row.active = settings.use_frames_limit
row.prop(settings, "frames_limit")
class CLIP_PT_tracking_camera(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
@ -299,7 +415,7 @@ class CLIP_PT_tracking_camera(Panel):
def poll(cls, context):
sc = context.space_data
return sc.clip
return sc.mode in ['TRACKING', 'DISTORTION'] and sc.clip
def draw(self, context):
layout = self.layout
@ -363,18 +479,19 @@ class CLIP_PT_display(Panel):
row = layout.row()
row.prop(sc, "show_names", text="Names")
row.prop(sc, "show_grid", text="Grid")
row = layout.row()
row.prop(sc, "show_tiny_markers", text="Tiny Markers")
row.prop(sc, "show_stable", text="Stable")
row = layout.row()
row.prop(sc, "show_grease_pencil", text="Grease Pencil")
row.prop(sc, "use_mute_footage", text="Mute")
if sc.mode == 'DISTORTION':
layout.prop(sc, "show_grid", text="Grid")
layout.prop(sc, "use_manual_calibration")
elif sc.mode == 'RECONSTRUCTION':
layout.prop(sc, "show_stable", text="Stable")
layout.prop(sc, "lock_selection")
layout.prop(sc, "use_manual_calibration")
clip = sc.clip
if clip:
@ -382,6 +499,27 @@ class CLIP_PT_display(Panel):
layout.prop(clip, "display_aspect", text="")
class CLIP_PT_track_settings(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_label = "Tracking Settings"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
sc = context.space_data
return sc.mode == 'TRACKING' and sc.clip
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
settings = clip.tracking.settings
layout.prop(settings, "speed")
layout.prop(settings, "frames_limit")
class CLIP_PT_stabilization(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
@ -392,7 +530,7 @@ class CLIP_PT_stabilization(Panel):
def poll(cls, context):
sc = context.space_data
return sc.clip
return sc.mode == 'RECONSTRUCTION' and sc.clip
def draw_header(self, context):
sc = context.space_data
@ -409,14 +547,16 @@ class CLIP_PT_stabilization(Panel):
layout.active = stab.use_2d_stabilization
row = layout.row()
row.template_list(stab, "tracks", stab, "active_track_index", rows=3)
sub = row.column(align=True)
sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
sub.menu('CLIP_MT_stabilize_2d_specials', text="", icon="DOWNARROW_HLT")
sub.menu('CLIP_MT_stabilize_2d_specials', text="", \
icon="DOWNARROW_HLT")
layout.prop(stab, "influence_location")
@ -460,7 +600,7 @@ class CLIP_PT_proxy(Panel):
layout.prop(clip, 'use_proxy_custom_directory')
if clip.use_proxy_custom_directory:
layout.prop(clip.proxy, "directory")
layout.prop(clip.proxy, "directory")
layout.operator("clip.rebuild_proxy", text="Rebuild Proxy")

@ -344,7 +344,7 @@ static MovieClip *movieclip_alloc(const char *name)
clip->tracking.camera.pixel_aspect= 1.0f;
clip->tracking.camera.units= CAMERA_UNITS_MM;
clip->tracking.settings.frames_limit= 20;
clip->tracking.settings.frames_limit= 0;
clip->tracking.settings.keyframe1= 1;
clip->tracking.settings.keyframe2= 30;
clip->tracking.settings.dist= 1;

@ -734,6 +734,7 @@ void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr
void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *userptr, int compact);
void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr);
/* items */
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);

@ -91,6 +91,13 @@ static void trackingMarker_buttons(const bContext *C, uiLayout *layout)
ED_space_clip_size(sc, &width, &height);
BKE_movieclip_last_selection(clip, &type, (void**)&track);
if(track->flag&TRACK_LOCKED) {
uiLayoutSetActive(layout, 0);
block= uiLayoutAbsoluteBlock(layout);
uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, "");
return;
}
step= 100;
digits= 2;
@ -115,7 +122,7 @@ static void trackingMarker_buttons(const bContext *C, uiLayout *layout)
block= uiLayoutAbsoluteBlock(layout);
uiDefButBitI(block, OPTION, MARKER_DISABLED, B_MARKER_FLAG, "Disabled", 10, 190, 145, 19, &sc->marker_flag,
uiDefButBitI(block, OPTIONN, MARKER_DISABLED, B_MARKER_FLAG, "Enabled", 10, 190, 145, 19, &sc->marker_flag,
0, 0, 0, 0, "Marker is disabled for current frame.");
col= uiLayoutColumn(layout, 1);
@ -264,7 +271,7 @@ static int clip_panel_marker_poll(const bContext *C, PanelType *UNUSED(pt))
int type;
MovieTrackingTrack *track;
if(!sc)
if(sc->mode!=SC_MODE_TRACKING)
return 0;
clip= ED_space_clip(sc);
@ -277,9 +284,6 @@ static int clip_panel_marker_poll(const bContext *C, PanelType *UNUSED(pt))
if(type!=MCLIP_SEL_TRACK)
return 0;
if(track->flag&TRACK_LOCKED)
return 0;
return 1;
}
@ -302,6 +306,7 @@ void ED_clip_buttons_register(ARegionType *art)
strcpy(pt->label, "Marker");
pt->draw= clip_panel_marker;
pt->poll= clip_panel_marker_poll;
pt->flag|= PNL_DEFAULT_CLOSED;
BLI_addtail(&art->paneltypes, pt);
@ -361,7 +366,7 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c
}
}
/********************* Marker Template ************************/
/********************* Track Template ************************/
void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
@ -397,3 +402,64 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname)
uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, "");
}
/********************* Marker Template ************************/
typedef struct {
int flag, framenr;
MovieTrackingTrack *track;
} MarkerUpdateCb;
static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
{
MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb;
MovieTrackingMarker *marker;
marker= BKE_tracking_ensure_marker(cb->track, cb->framenr);
marker->flag= cb->flag;
WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL);
}
void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr)
{
PropertyRNA *prop;
uiBlock *block;
uiBut *bt;
PointerRNA trackptr;
MovieClipUser *user;
MovieTrackingTrack *track;
MovieTrackingMarker *marker;
MarkerUpdateCb *cb;
if(!ptr->data)
return;
prop= RNA_struct_find_property(ptr, propname);
if(!prop) {
printf("uiTemplateMarker: 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);
return;
}
trackptr= RNA_property_pointer_get(ptr, prop);
track= (MovieTrackingTrack *)trackptr.data;
user= userptr->data;
marker= BKE_tracking_get_marker(track, user->framenr);
block= uiLayoutGetBlock(layout);
cb= MEM_callocN(sizeof(MarkerUpdateCb), "uiTemplateMarker update_cb");
cb->flag= marker->flag;
cb->track= track;
cb->framenr= user->framenr;
bt= uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_MUTE_IPO_OFF, 0, 0, 20, 20, &cb->flag, 0, 0, 1, 0, "Marker is disabled for current frame.");
uiButSetNFunc(bt, marker_update_cb, cb, NULL);
}

@ -943,6 +943,9 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid
float dx= (float)width/n, dy= (float)height/n;
MovieTracking *tracking= &clip->tracking;
if(sc->mode!=SC_MODE_DISTORTION)
return;
if(!tracking->camera.focal)
return;
@ -1162,7 +1165,7 @@ void draw_clip_grease_pencil(bContext *C, int onlyv2d)
if(onlyv2d) {
/* if manual calibration is used then grase pencil data is already
drawed in draw_distortion */
if((sc->flag&SC_MANUAL_CALIBRATION)==0) {
if((sc->flag&SC_MANUAL_CALIBRATION)==0 || sc->mode!=SC_MODE_DISTORTION) {
ibuf= ED_space_clip_acquire_buffer(sc);
if(ibuf) {

@ -70,7 +70,7 @@ void CLIP_OT_delete_marker(struct wmOperatorType *ot);
void CLIP_OT_track_markers(struct wmOperatorType *ot);
void CLIP_OT_solve_camera(struct wmOperatorType *ot);
void CLIP_OT_clear_reconstruction(struct wmOperatorType *ot);
void CLIP_OT_clear_solution(struct wmOperatorType *ot);
void CLIP_OT_clear_track_path(struct wmOperatorType *ot);
void CLIP_OT_join_tracks(struct wmOperatorType *ot);

@ -281,7 +281,7 @@ static void clip_operatortypes(void)
/* solving */
WM_operatortype_append(CLIP_OT_solve_camera);
WM_operatortype_append(CLIP_OT_clear_reconstruction);
WM_operatortype_append(CLIP_OT_clear_solution);
WM_operatortype_append(CLIP_OT_disable_markers);
WM_operatortype_append(CLIP_OT_hide_tracks);

@ -1216,7 +1216,7 @@ static void track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backwar
else tmj->efra= EFRA;
/* limit frames to be tracked by user setting */
if(settings->flag&TRACKING_FRAMES_LIMIT) {
if(settings->frames_limit) {
if(backwards) tmj->efra= MAX2(tmj->efra, tmj->sfra-settings->frames_limit);
else tmj->efra= MIN2(tmj->efra, tmj->sfra+settings->frames_limit);
}
@ -1328,7 +1328,7 @@ static int track_markers_exec(bContext *C, wmOperator *op)
else efra= EFRA;
/* limit frames to be tracked by user setting */
if(settings->flag&TRACKING_FRAMES_LIMIT) {
if(settings->frames_limit) {
if(backwards) efra= MAX2(efra, sfra-settings->frames_limit);
else efra= MIN2(efra, sfra+settings->frames_limit);
}
@ -1540,9 +1540,9 @@ void CLIP_OT_solve_camera(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/********************** clear reconstruction operator *********************/
/********************** clear solution operator *********************/
static int clear_reconstruction_exec(bContext *C, wmOperator *UNUSED(op))
static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceClip *sc= CTX_wm_space_clip(C);
MovieClip *clip= ED_space_clip(sc);
@ -1571,15 +1571,15 @@ static int clear_reconstruction_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_FINISHED;
}
void CLIP_OT_clear_reconstruction(wmOperatorType *ot)
void CLIP_OT_clear_solution(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Clear Reconstruction";
ot->description= "Clear all reconstruciton data";
ot->idname= "CLIP_OT_clear_reconstruction";
ot->name= "Clear Solution";
ot->description= "Clear all calculated data";
ot->idname= "CLIP_OT_clear_solution";
/* api callbacks */
ot->exec= clear_reconstruction_exec;
ot->exec= clear_solution_exec;
ot->poll= ED_space_clip_poll;
/* flags */
@ -2735,8 +2735,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
if(sel_type!=MCLIP_SEL_TRACK)
sel_track= NULL;
if(error && action==2)
action= 1;
if(error && action==TRACKING_CLEAN_DELETE_SEGMENT)
action= TRACKING_CLEAN_DELETE_TRACK;
track= tracking->tracks.first;
while(track) {
@ -2745,14 +2745,14 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) {
int ok= 1;
ok&= is_track_clean(track, frames, action==2);
ok&= is_track_clean(track, frames, action==TRACKING_CLEAN_DELETE_SEGMENT);
ok&= error == 0.f || (track->flag&TRACK_HAS_BUNDLE)==0 || track->error < error;
if(!ok) {
if(action==0) { /* select */
if(action==TRACKING_CLEAN_SELECT) {
BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0);
}
else if(action==1) { /* delete track */
else if(action==TRACKING_CLEAN_DELETE_TRACK) {
if(track==sel_track)
BKE_movieclip_set_selection(clip, MCLIP_SEL_NONE, NULL);
@ -2779,12 +2779,29 @@ static int clean_tracks_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
SpaceClip *sc= CTX_wm_space_clip(C);
MovieClip *clip= ED_space_clip(sc);
int frames= RNA_int_get(op->ptr, "frames");
float error= RNA_float_get(op->ptr, "error");
int action= RNA_enum_get(op->ptr, "action");
if(frames==0 && error==0 && action==0) {
RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames);
RNA_float_set(op->ptr, "error", clip->tracking.settings.clean_error);
RNA_enum_set(op->ptr, "action", clip->tracking.settings.clean_action);
}
return clean_tracks_exec(C, op);
}
void CLIP_OT_clean_tracks(wmOperatorType *ot)
{
static EnumPropertyItem actions_items[] = {
{0, "SELECT", 0, "Select", "Select un-clean tracks"},
{1, "DELETE_TRACK", 0, "Delete Track", "Delete un-clean tracks"},
{2, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete un-clean segments of tracks"},
{TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select un-clean tracks"},
{TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete un-clean tracks"},
{TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete un-clean segments of tracks"},
{0, NULL, 0, NULL, NULL}
};
@ -2795,6 +2812,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec= clean_tracks_exec;
ot->invoke= clean_tracks_invoke;
ot->poll= ED_space_clip_poll;
/* flags */
@ -2803,5 +2821,5 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot)
/* properties */
RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", "Affect on tracks which are tracked less than specified amount of frames.", 0, INT_MAX);
RNA_def_float(ot->srna, "error", 0.0f, 0.f, FLT_MAX, "Reprojection Error", "Affect on tracks with have got larger reprojection error.", 0.f, 100.0f);
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Cleanup action to execute");
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Cleanup action to execute.");
}

@ -578,7 +578,7 @@ typedef struct SpaceClip {
struct MovieClipScopes scopes; /* different scoped displayed in space panels */
int flag; /* flags */
int pad;
int mode; /*editor mode */
int path_length; /* length of displaying path, in frames */
@ -983,6 +983,10 @@ enum {
#define SC_MANUAL_CALIBRATION (1<<11)
#define SC_SHOW_GPENCIL (1<<12)
/* SpaceClip->mode */
#define SC_MODE_TRACKING 0
#define SC_MODE_RECONSTRUCTION 1
#define SC_MODE_DISTORTION 2
/* space types, moved from DNA_screen_types.h */
/* Do NOT change order, append on end. types are hardcoded needed */

@ -100,12 +100,20 @@ typedef struct MovieTrackingTrack {
} MovieTrackingTrack;
typedef struct MovieTrackingSettings {
int flag; /* different flags (frames nr limit..) */
short speed; /* speed of tracking */
short frames_limit; /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */
/* ** tool settings ** */
/* set scale */
float dist; /* distance between two bundles used for scene scaling */
float pad;
/* cleanup */
int clean_frames, clean_action;
float clean_error;
int pad;
} MovieTrackingSettings;
typedef struct MovieTrackingStabilization {
@ -165,9 +173,6 @@ enum {
#define TRACKING_SPEED_HALF 2
#define TRACKING_SPEED_QUARTER 4
/* MovieTrackingSettings->flag */
#define TRACKING_FRAMES_LIMIT (1<<0)
/* MovieTrackingStrabilization->flag */
#define TRACKING_2D_STABILIZATION (1<<0)
#define TRACKING_AUTOSCALE (1<<1)
@ -175,4 +180,8 @@ enum {
/* MovieTrackingReconstruction->flag */
#define TRACKING_RECONSTRUCTED (1<<0)
#define TRACKING_CLEAN_SELECT 0
#define TRACKING_CLEAN_DELETE_TRACK 1
#define TRACKING_CLEAN_DELETE_SEGMENT 2
#endif

@ -1148,6 +1148,7 @@ static void rna_def_background_image(BlenderRNA *brna)
prop= RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MovieClipUser");
RNA_def_property_pointer_sdna(prop, NULL, "cuser");
RNA_def_property_ui_text(prop, "Clip User", "Parameters defining which frame of the movie clip is displayed");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
@ -2643,6 +2644,12 @@ static void rna_def_space_clip(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem mode_items[] = {
{SC_MODE_TRACKING, "TRACKING", 0, "Tracking", "Show tracking and solving tools"},
{SC_MODE_RECONSTRUCTION, "RECONSTRUCTION", 0, "Reconstruction", "Show tracking/reconstruction tools"},
{SC_MODE_DISTORTION, "DISTORTION", 0, "Distortion", "Show distortion tools"},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "SpaceClipEditor", "Space");
RNA_def_struct_sdna(srna, "SpaceClip");
RNA_def_struct_ui_text(srna, "Space Clip Editor", "Clip editor space data");
@ -2657,10 +2664,18 @@ static void rna_def_space_clip(BlenderRNA *brna)
/* clip user */
prop= RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "MovieClipUser");
RNA_def_property_pointer_sdna(prop, NULL, "user");
RNA_def_property_ui_text(prop, "Movie Clip User", "Parameters defining which frame of the movie clip is displayed");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
/* mode */
prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "Current clip editor mode");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
/* show pattern */
prop= RNA_def_property(srna, "show_marker_pattern", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Show Marker Pattern", "Show pattern boundbox for markers");

@ -198,6 +198,13 @@ static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerR
DAG_id_tag_update(&clip->id, 0);
}
/* API */
static MovieTrackingMarker *rna_trackingTrack_marker_get(MovieTrackingTrack *track, int framenr)
{
return BKE_tracking_get_marker(track, framenr);
}
#else
static int rna_matrix_dimsize_4x4[]= {4, 4};
@ -214,6 +221,13 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
{TRACKING_SPEED_QUARTER, "QUARTER", 0, "Quarter", "Track with quarter of realtime speed"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem cleanup_items[] = {
{TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select un-clean tracks"},
{TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete un-clean tracks"},
{TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete un-clean segments of tracks"},
{0, NULL, 0, NULL, NULL}
};
srna= RNA_def_struct(brna, "MovieTrackingSettings", NULL);
RNA_def_struct_ui_text(srna, "Movie tracking settings", "Match-moving tracking settings");
@ -223,17 +237,11 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
RNA_def_property_enum_items(prop, speed_items);
RNA_def_property_ui_text(prop, "Speed", "Speed to make tracking with");
/* use limit frames */
prop= RNA_def_property(srna, "use_frames_limit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_FRAMES_LIMIT);
RNA_def_property_ui_text(prop, "Limit Frames", "Limit number of frames be tracked during single tracking operation");
/* limit frames */
prop= RNA_def_property(srna, "frames_limit", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "frames_limit");
RNA_def_property_range(prop, 1, INT_MAX);
RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_ui_text(prop, "Frames Limit", "Amount of frames to be tracked during single tracking operation");
/* keyframe1 */
@ -248,11 +256,34 @@ static void rna_def_trackingSettings(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "keyframe2");
RNA_def_property_ui_text(prop, "Keyframe 2", "Second keyframe used for reconstruction initialization");
/* tool settings */
/* distance */
prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "dist");
RNA_def_property_ui_text(prop, "Distance", "Distance between two bundles used for scene scaling");
/* frames count */
prop= RNA_def_property(srna, "clean_frames", PROP_INT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_int_sdna(prop, NULL, "clean_frames");
RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_ui_text(prop, "Tracked Frames", "Affect on tracks which are tracked less than specified amount of frames");
/* reprojection error */
prop= RNA_def_property(srna, "clean_error", PROP_FLOAT, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_float_sdna(prop, NULL, "clean_error");
RNA_def_property_range(prop, 0, FLT_MAX);
RNA_def_property_ui_text(prop, "Reprojection Error", "Affect on tracks with have got larger reprojection error");
/* cleanup action */
prop= RNA_def_property(srna, "clean_action", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "clean_action");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_enum_items(prop, cleanup_items);
RNA_def_property_ui_text(prop, "Action", "Cleanup action to execute");
}
static void rna_def_trackingCamera(BlenderRNA *brna)
@ -333,7 +364,7 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
srna= RNA_def_struct(brna, "MovieTrackingMarker", NULL);
RNA_def_struct_ui_text(srna, "Movie tracking marker data", "Match-moving marker data for tracking");
/* oosition */
/* position */
prop= RNA_def_property(srna, "pos", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 2);
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
@ -347,6 +378,12 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "framenr");
RNA_def_property_ui_text(prop, "Frame", "Frame number marker is keyframed on");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
/* enabled */
prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_DISABLED);
RNA_def_property_ui_text(prop, "Enabled", "Is marker enabled for current frame");
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
}
static void rna_def_trackingTrack(BlenderRNA *brna)
@ -354,6 +391,9 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
rna_def_trackingMarker(brna);
srna= RNA_def_struct(brna, "MovieTrackingTrack", NULL);
@ -472,6 +512,15 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Average Error", "Average error of re-projection");
/* ** api ** */
func= RNA_def_function(srna, "get_marker", "rna_trackingTrack_marker_get");
RNA_def_function_ui_description(func, "Get marker for specified frame.");
parm= RNA_def_int(func, "frame", 1, MINFRAME, MAXFRAME, "Frame", "type for the new spline.", MINFRAME, MAXFRAME);
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame.");
RNA_def_function_return(func, parm);
}
static void rna_def_trackingStabilization(BlenderRNA *brna)

@ -401,9 +401,15 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_boolean(func, "compact", 0, "", "Use more compact layout.");
func= RNA_def_function(srna, "template_track", "uiTemplateTrack");
RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data.");
RNA_def_function_ui_description(func, "Item. A movie-track widget to preview tracking image.");
api_ui_item_rna_common(func);
func= RNA_def_function(srna, "template_marker", "uiTemplateMarker");
RNA_def_function_ui_description(func, "Item. A movie-marker widget to control which depends on frame number.");
api_ui_item_rna_common(func);
parm= RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
func= RNA_def_function(srna, "template_list", "uiTemplateList");
RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups.");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);

@ -368,6 +368,7 @@ void uiTemplateWaveform(struct uiLayout *layout, struct PointerRNA *ptr, char *p
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 uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname){}
void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, PointerRNA *userptr){}
/* rna render */
struct RenderResult *RE_engine_begin_result(struct RenderEngine *engine, int x, int y, int w, int h){return (struct RenderResult *) NULL;}