Camera tracking integration

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

- Fixed sub-pixel precision error when sliding markers.
- Made sliding areas smaller.
- Remove "Debug" menu,
- pep8 cleanup.
This commit is contained in:
Sergey Sharybin 2011-07-10 18:12:29 +00:00
parent f4d2a3c8b0
commit 0277b36b76
6 changed files with 71 additions and 59 deletions

@ -108,7 +108,8 @@ class CLIP_PT_tools(bpy.types.Panel):
op = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
op.backwards = True
op = row.operator("clip.track_markers", text="", icon='PLAY_REVERSE')
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')
@ -116,9 +117,15 @@ class CLIP_PT_tools(bpy.types.Panel):
row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
col = layout.column(align=True)
col.operator("clip.clear_track_path", text="Clear Remained Path").action = 'REMAINED'
col.operator("clip.clear_track_path", text="Clear Path Up To").action = 'UPTO'
col.operator("clip.clear_track_path", text="Clear Track Path").action = 'ALL'
op = col.operator("clip.clear_track_path", \
text="Clear Remained Path")
op.action = 'REMAINED'
op = col.operator("clip.clear_track_path", text="Clear Path Up To")
op.action = 'UPTO'
op = col.operator("clip.clear_track_path", text="Clear Track Path")
op.action = 'ALL'
col = layout.column(align=True)
col.label(text="Reconstruction:")
@ -152,7 +159,8 @@ class CLIP_PT_track(bpy.types.Panel):
layout.prop(act_track, "name")
layout.template_track(clip.tracking, "active_track", sc.clip_user, clip)
layout.template_track(clip.tracking, "active_track", \
sc.clip_user, clip)
if act_track:
row = layout.row()
@ -240,6 +248,8 @@ class CLIP_PT_display(bpy.types.Panel):
row.active = sc.show_marker_path
row.prop(sc, "path_length")
layout.prop(sc, "show_tiny_markers")
class CLIP_PT_test(bpy.types.Panel):
bl_space_type = 'CLIP_EDITOR'
@ -255,20 +265,6 @@ class CLIP_PT_test(bpy.types.Panel):
layout.operator("clip.track_to_fcurves")
class CLIP_PT_debug(bpy.types.Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_label = "Debug"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
sc = context.space_data
layout.prop(sc, "show_cache")
layout.prop(sc, "show_tiny_markers")
class CLIP_PT_footage(bpy.types.Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
@ -351,16 +347,27 @@ class CLIP_MT_track(bpy.types.Menu):
layout.operator("clip.solve_camera")
layout.separator()
layout.operator("clip.clear_track_path", text="Clear Remained Path").action = 'REMAINED'
layout.operator("clip.clear_track_path", text="Clear Path Up To").action = 'UPTO'
layout.operator("clip.clear_track_path", text="Clear Track Path").action = 'ALL'
op = layout.operator("clip.clear_track_path", \
text="Clear Remained Path")
op.action = 'REMAINED'
op = layout.operator("clip.clear_track_path", \
text="Clear Path Up To")
op.action = 'UPTO'
op = layout.operator("clip.clear_track_path", \
text="Clear Track Path")
op.action = 'ALL'
layout.separator()
op = layout.operator("clip.track_markers", text="Track Frame Backwards")
op = layout.operator("clip.track_markers", \
text="Track Frame Backwards")
op.backwards = True
op = layout.operator("clip.track_markers", text="Track Backwards")
op.backwards = True
op.sequence = True
op = layout.operator("clip.track_markers", text="Track Forwards")
op.sequence = True
layout.operator("clip.track_markers", text="Track Frame Forwards")
@ -385,7 +392,9 @@ class CLIP_MT_track_visibility(bpy.types.Menu):
layout.operator("clip.hide_tracks_clear", text="Show Hidden")
layout.operator("clip.hide_tracks", text="Hide Selected")
layout.operator("clip.hide_tracks", text="Hide Unselected").unselected = True
op = layout.operator("clip.hide_tracks", text="Hide Unselected")
op.unselected = True
class CLIP_MT_track_transform(bpy.types.Menu):
@ -411,6 +420,7 @@ class CLIP_MT_select(bpy.types.Menu):
layout.operator("clip.select_all", text="Select/Deselect all")
layout.operator("clip.select_all", text="Inverse").action = 'INVERT'
class CLIP_MT_tracking_specials(bpy.types.Menu):
bl_label = "Specials"
@ -421,9 +431,17 @@ class CLIP_MT_tracking_specials(bpy.types.Menu):
def draw(self, context):
layout = self.layout
layout.operator("clip.disable_markers", text="Enable Markers").action = 'ENABLE'
layout.operator("clip.disable_markers", text="Disable markers").action = 'DISABLE'
op = layout.operator("clip.disable_markers", text="Enable Markers")
op.action = 'ENABLE'
op = layout.operator("clip.disable_markers", text="Disable markers")
op.action = 'DISABLE'
layout.operator("clip.set_origin")
layout.separator()
layout.operator("clip.hide_tracks")
layout.operator("clip.hide_tracks_clear", text="Show Tracks")
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)

@ -400,8 +400,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
x= track->search_min[0];
y= track->search_max[1];
dx= 15.0f/width/sc->zoom;
dy= 15.0f/height/sc->zoom;
dx= 12.0f/width/sc->zoom;
dy= 12.0f/height/sc->zoom;
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
tdx=MIN2(dx, (track->search_max[0]-track->search_min[0])/5);
@ -435,6 +435,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
}
if(sc->flag&SC_SHOW_MARKER_PATTERN) {
/* use smaller slider for pattern area */
dx= 10.0f/width/sc->zoom;
dy= 10.0f/height/sc->zoom;
if(!outline) {
if(track->pat_flag&SELECT) UI_ThemeColor(color);
else UI_ThemeColor(TH_MARKER);
@ -583,8 +587,7 @@ void draw_clip_main(SpaceClip *sc, ARegion *ar, Scene *scene)
draw_tracking(sc, ar, clip, zoomx, zoomy);
}
if(sc->debug_flag&SC_DBG_SHOW_CACHE)
draw_movieclip_cache(sc, ar, clip, scene);
draw_movieclip_cache(sc, ar, clip, scene);
}
static ImBuf *scale_ibuf(ImBuf *ibuf, float zoomx, float zoomy)

@ -78,7 +78,6 @@ static SpaceLink *clip_new(const bContext *UNUSED(C))
sc= MEM_callocN(sizeof(SpaceClip), "initclip");
sc->spacetype= SPACE_CLIP;
sc->flag= SC_SHOW_MARKER_PATTERN|SC_SHOW_MARKER_SEARCH|SC_SHOW_MARKER_PATH;
sc->debug_flag= SC_DBG_SHOW_CACHE;
sc->zoom= 1.0f;
sc->path_length= 20;

@ -1288,28 +1288,31 @@ static SlideMarkerData *create_slide_marker_data(MovieTrackingTrack *track, Movi
/* corner = 0: right-bottom corner,
corner = 1: left-top corner */
static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, float co[2], int corner,
static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, float size, float co[2], int corner,
float *pos, float *min, float *max, int width, int height)
{
int crn[2], inside= 0;
float dx, dy;
int inside= 0;
float nco[2], crn[2], dx, dy;
dx= 15.0f/sc->zoom;
dy= 15.0f/sc->zoom;
nco[0]= co[0]/width;
nco[1]= co[1]/height;
dx=MIN2(dx, (track->search_max[0]-track->search_min[0])*width/5);
dy=MIN2(dy, (track->search_max[1]-track->search_min[1])*height/5);
dx= size/width/sc->zoom;
dy= size/height/sc->zoom;
dx=MIN2(dx, (track->search_max[0]-track->search_min[0])/5);
dy=MIN2(dy, (track->search_max[1]-track->search_min[1])/5);
if(corner==0) {
crn[0]= (pos[0]+max[0])*width;
crn[1]= (pos[1]+min[1])*height;
crn[0]= pos[0]+max[0];
crn[1]= pos[1]+min[1];
inside= co[0]>=crn[0]-dx && co[0]<=crn[0] && co[1]>=crn[1] && co[1]<=crn[1]+dy;
inside= nco[0]>=crn[0]-dx && nco[0]<=crn[0] && nco[1]>=crn[1] && nco[1]<=crn[1]+dy;
} else {
crn[0]= (pos[0]+min[0])*width;
crn[1]= (pos[1]+max[1])*height;
crn[0]= pos[0]+min[0];
crn[1]= pos[1]+max[1];
inside= co[0]>=crn[0] && co[0]<=crn[0]+dx && co[1]>=crn[1]-dy && co[1]<=crn[1];
inside= nco[0]>=crn[0] && nco[0]<=crn[0]+dx && nco[1]>=crn[1]-dy && nco[1]<=crn[1];
}
return inside;
@ -1337,15 +1340,15 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(marker && (marker->flag&MARKER_DISABLED)==0) {
if(sc->flag&SC_SHOW_MARKER_SEARCH) {
if(mouse_on_corner(sc, track, co, 1, marker->pos, track->search_min, track->search_max, width, height))
if(mouse_on_corner(sc, track, 15.0f, co, 1, marker->pos, track->search_min, track->search_max, width, height))
op->customdata= create_slide_marker_data(track, marker, event, TRACK_AREA_POINT, width, height);
if(mouse_on_corner(sc, track, co, 0, marker->pos, track->search_min, track->search_max, width, height))
if(mouse_on_corner(sc, track, 15.0f, co, 0, marker->pos, track->search_min, track->search_max, width, height))
op->customdata= create_slide_marker_data(track, marker, event, TRACK_AREA_SEARCH, width, height);
}
if(sc->flag&SC_SHOW_MARKER_PATTERN)
if(mouse_on_corner(sc, track, co, 0, marker->pos, track->pat_min, track->pat_max, width, height))
if(mouse_on_corner(sc, track, 10.0f, co, 0, marker->pos, track->pat_min, track->pat_max, width, height))
op->customdata= create_slide_marker_data(track, marker, event, TRACK_AREA_PAT, width, height);
if(op->customdata) {

@ -576,7 +576,7 @@ typedef struct SpaceClip {
struct MovieClip *clip; /* clip data */
int flag; /* flags */
int debug_flag; /* flags for debugging */
int pad;
int path_length; /* length of displaying path, in frames */
@ -966,9 +966,6 @@ enum {
#define SC_SHOW_TINY_MARKER (1<<3)
#define SC_SHOW_MARKER_PATH (1<<4)
/* SpaceClip->debug_flag */
#define SC_DBG_SHOW_CACHE (1<<0)
/* space types, moved from DNA_screen_types.h */
/* Do NOT change order, append on end. types are hardcoded needed */

@ -2671,14 +2671,6 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Path Length", "Length of displaying path, in frames");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
/* ** debug flags ** */
/* show cache */
prop= RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Show Cache", "Show cached frames for current clip");
RNA_def_property_boolean_sdna(prop, NULL, "debug_flag", SC_DBG_SHOW_CACHE);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
/* show tiny markers */
prop= RNA_def_property(srna, "show_tiny_markers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_ui_text(prop, "Show Tiny Markers", "Show markers tiny");