2011-11-07 12:55:18 +00:00
/*
* * * * * * BEGIN GPL LICENSE BLOCK * * * * *
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software Foundation ,
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
* The Original Code is Copyright ( C ) 2011 Blender Foundation .
* All rights reserved .
*
*
* Contributor ( s ) : Blender Foundation ,
* Sergey Sharybin
*
* * * * * * END GPL LICENSE BLOCK * * * * *
*/
/** \file blender/editors/space_clip/tracking_ops.c
* \ ingroup spclip
*/
# include "MEM_guardedalloc.h"
# include "DNA_camera_types.h"
2011-12-15 16:09:57 +00:00
# include "DNA_constraint_types.h"
2011-11-07 12:55:18 +00:00
# include "DNA_gpencil_types.h"
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
# include "DNA_mask_types.h"
2011-11-07 12:55:18 +00:00
# include "DNA_movieclip_types.h"
2012-06-10 19:59:02 +00:00
# include "DNA_object_types.h" /* SELECT */
2011-11-07 12:55:18 +00:00
# include "DNA_scene_types.h"
# include "BLI_utildefines.h"
# include "BLI_math.h"
# include "BLI_listbase.h"
# include "BLI_rect.h"
# include "BLI_blenlib.h"
# include "BKE_main.h"
# include "BKE_context.h"
2011-12-15 16:09:57 +00:00
# include "BKE_constraint.h"
2011-11-07 12:55:18 +00:00
# include "BKE_movieclip.h"
# include "BKE_tracking.h"
# include "BKE_global.h"
# include "BKE_depsgraph.h"
# include "BKE_object.h"
# include "BKE_report.h"
# include "BKE_scene.h"
# include "BKE_library.h"
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
# include "BKE_mask.h"
# include "BKE_node.h"
2011-11-07 12:55:18 +00:00
# include "BKE_sound.h"
# include "WM_api.h"
# include "WM_types.h"
# include "ED_screen.h"
# include "ED_clip.h"
# include "ED_keyframing.h"
# include "IMB_imbuf_types.h"
# include "IMB_imbuf.h"
# include "UI_interface.h"
# include "RNA_access.h"
# include "RNA_define.h"
2013-05-30 11:37:53 +00:00
# include "BLF_translation.h"
2011-11-07 12:55:18 +00:00
# include "PIL_time.h"
# include "UI_view2d.h"
2012-06-10 19:59:02 +00:00
# include "clip_intern.h" // own include
2011-11-07 12:55:18 +00:00
/********************** add marker operator *********************/
2013-05-22 06:28:59 +00:00
static bool add_marker ( const bContext * C , float x , float y )
2011-11-07 12:55:18 +00:00
{
2012-06-20 10:28:51 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
int width , height ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-03-25 23:19:21 +00:00
2012-07-26 22:41:40 +00:00
ED_space_clip_get_size ( sc , & width , & height ) ;
2011-11-07 12:55:18 +00:00
2013-05-22 06:28:59 +00:00
if ( width = = 0 | | height = = 0 ) {
return false ;
}
2012-06-15 11:03:23 +00:00
track = BKE_tracking_track_add ( tracking , tracksbase , x , y , framenr , width , height ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_track_select ( tracksbase , track , TRACK_AREA_ALL , 0 ) ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
BKE_tracking_plane_tracks_deselect_all ( plane_tracks_base ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
clip - > tracking . act_track = track ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
clip - > tracking . act_plane_track = NULL ;
2013-05-22 06:28:59 +00:00
return true ;
2011-11-07 12:55:18 +00:00
}
static int add_marker_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
float pos [ 2 ] ;
RNA_float_get_array ( op - > ptr , " location " , pos ) ;
2013-05-22 06:28:59 +00:00
if ( ! add_marker ( C , pos [ 0 ] , pos [ 1 ] ) ) {
return OPERATOR_CANCELLED ;
}
2011-11-07 12:55:18 +00:00
/* reset offset from locked position, so frame jumping wouldn't be so confusing */
2012-03-25 23:19:21 +00:00
sc - > xlockof = 0 ;
sc - > ylockof = 0 ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
2013-03-13 09:03:46 +00:00
static int add_marker_invoke ( bContext * C , wmOperator * op , const wmEvent * event )
2011-11-07 12:55:18 +00:00
{
2012-07-26 22:41:40 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
2013-05-21 14:44:50 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " location " ) ) {
/* If location is not set, use mouse positio nas default. */
float co [ 2 ] ;
ED_clip_mouse_pos ( sc , ar , event - > mval , co ) ;
RNA_float_set_array ( op - > ptr , " location " , co ) ;
}
2011-11-07 12:55:18 +00:00
return add_marker_exec ( C , op ) ;
}
void CLIP_OT_add_marker ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Add Marker " ;
ot - > idname = " CLIP_OT_add_marker " ;
ot - > description = " Place new marker at specified location " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > invoke = add_marker_invoke ;
ot - > exec = add_marker_exec ;
2012-06-07 16:36:19 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
2012-10-11 23:46:12 +00:00
RNA_def_float_vector ( ot - > srna , " location " , 2 , NULL , - FLT_MAX , FLT_MAX ,
2012-06-10 19:59:02 +00:00
" Location " , " Location of marker on frame " , - 1.0f , 1.0f ) ;
2011-11-07 12:55:18 +00:00
}
2013-05-22 06:06:22 +00:00
/********************** add marker operator *********************/
2013-05-30 11:37:53 +00:00
static int add_marker_at_click_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2013-05-22 06:06:22 +00:00
{
2013-05-30 11:37:53 +00:00
ED_area_headerprint ( CTX_wm_area ( C ) , IFACE_ ( " Use LMB click to define location where place the marker " ) ) ;
2013-05-22 06:06:22 +00:00
2013-05-30 11:37:53 +00:00
/* add modal handler for ESC */
WM_event_add_modal_handler ( C , op ) ;
2013-05-22 06:06:22 +00:00
2013-05-30 11:37:53 +00:00
return OPERATOR_RUNNING_MODAL ;
}
2013-05-22 06:06:22 +00:00
2013-05-30 11:37:53 +00:00
static int add_marker_at_click_modal ( bContext * C , wmOperator * UNUSED ( op ) , const wmEvent * event )
{
2013-05-31 22:35:25 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
ARegion * ar = CTX_wm_region ( C ) ;
float pos [ 2 ] ;
2013-05-22 06:06:22 +00:00
2013-05-31 22:35:25 +00:00
switch ( event - > type ) {
case MOUSEMOVE :
2013-05-30 11:37:53 +00:00
return OPERATOR_RUNNING_MODAL ;
2013-05-22 06:06:22 +00:00
2013-05-31 22:35:25 +00:00
case LEFTMOUSE :
2013-05-30 11:37:53 +00:00
ED_area_headerprint ( CTX_wm_area ( C ) , NULL ) ;
ED_clip_point_stable_pos ( sc , ar ,
event - > x - ar - > winrct . xmin ,
event - > y - ar - > winrct . ymin ,
& pos [ 0 ] , & pos [ 1 ] ) ;
if ( ! add_marker ( C , pos [ 0 ] , pos [ 1 ] ) )
return OPERATOR_CANCELLED ;
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
return OPERATOR_FINISHED ;
case ESCKEY :
2013-05-31 22:35:25 +00:00
ED_area_headerprint ( CTX_wm_area ( C ) , NULL ) ;
return OPERATOR_CANCELLED ;
}
2013-05-30 11:37:53 +00:00
2013-05-31 22:35:25 +00:00
return OPERATOR_PASS_THROUGH ;
2013-05-22 06:06:22 +00:00
}
2013-05-30 11:37:53 +00:00
void CLIP_OT_add_marker_at_click ( wmOperatorType * ot )
2013-05-22 06:06:22 +00:00
{
/* identifiers */
2013-05-30 11:37:53 +00:00
ot - > name = " Add Marker at Click " ;
ot - > idname = " CLIP_OT_add_marker_at_click " ;
ot - > description = " Place new marker at the desired (clicked) position " ;
2013-05-22 06:06:22 +00:00
/* api callbacks */
2013-05-30 11:37:53 +00:00
ot - > invoke = add_marker_at_click_invoke ;
2013-05-22 06:06:22 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2013-05-30 11:37:53 +00:00
ot - > modal = add_marker_at_click_modal ;
2013-05-22 06:06:22 +00:00
/* flags */
2013-05-30 11:37:53 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING ;
2013-05-22 06:06:22 +00:00
}
2011-11-07 12:55:18 +00:00
/********************** delete track operator *********************/
2013-12-20 01:38:07 +01:00
static int delete_track_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first , * next ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
MovieTrackingPlaneTrack * plane_track , * next_plane_track ;
2013-11-26 06:39:14 +11:00
bool changed = false ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
/* Delete selected plane tracks. */
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = next_plane_track )
{
next_plane_track = plane_track - > next ;
2014-03-06 20:07:14 +06:00
if ( PLANE_TRACK_VIEW_SELECTED ( plane_track ) ) {
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
BKE_tracking_plane_track_free ( plane_track ) ;
BLI_freelinkN ( plane_tracks_base , plane_track ) ;
2013-11-26 06:39:14 +11:00
changed = true ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
}
}
2011-11-07 12:55:18 +00:00
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
/* Remove selected point tracks (they'll also be removed from planes which uses them). */
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
next = track - > next ;
2011-11-07 12:55:18 +00:00
2013-11-26 00:38:50 +01:00
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
clip_delete_track ( C , clip , track ) ;
2013-11-26 00:38:50 +01:00
changed = true ;
}
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = next ;
2011-11-07 12:55:18 +00:00
}
/* nothing selected now, unlock view so it can be scrolled nice again */
2012-03-25 23:19:21 +00:00
sc - > flag & = ~ SC_LOCK_SELECTION ;
2011-11-07 12:55:18 +00:00
2013-12-20 01:38:07 +01:00
if ( changed )
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_delete_track ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Delete Track " ;
ot - > idname = " CLIP_OT_delete_track " ;
ot - > description = " Delete selected tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2013-12-20 01:38:07 +01:00
ot - > invoke = WM_operator_confirm ;
2012-03-22 07:26:09 +00:00
ot - > exec = delete_track_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** delete marker operator *********************/
2013-12-20 01:38:07 +01:00
static int delete_marker_exec ( bContext * C , wmOperator * UNUSED ( op ) )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( & clip - > tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first , * next ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
MovieTrackingPlaneTrack * plane_track , * plane_track_next ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2014-02-03 18:55:59 +11:00
bool has_selection = false ;
2013-11-26 00:38:50 +01:00
bool changed = false ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
next = track - > next ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
2012-06-15 11:03:23 +00:00
MovieTrackingMarker * marker = BKE_tracking_marker_get_exact ( track , framenr ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( marker ) {
2012-05-07 08:53:59 +00:00
has_selection | = track - > markersnr > 1 ;
2011-11-07 12:55:18 +00:00
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
clip_delete_marker ( C , clip , track , marker ) ;
2013-11-26 00:38:50 +01:00
changed = true ;
2011-11-07 12:55:18 +00:00
}
}
2012-03-25 23:19:21 +00:00
track = next ;
2011-11-07 12:55:18 +00:00
}
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = plane_track_next )
{
plane_track_next = plane_track - > next ;
2014-03-06 20:07:14 +06:00
if ( PLANE_TRACK_VIEW_SELECTED ( plane_track ) ) {
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
MovieTrackingPlaneMarker * plane_marker = BKE_tracking_plane_marker_get_exact ( plane_track , framenr ) ;
if ( plane_marker ) {
if ( plane_track - > markersnr = = 1 ) {
BKE_tracking_plane_track_free ( plane_track ) ;
BLI_freelinkN ( plane_tracks_base , plane_track ) ;
}
else {
BKE_tracking_plane_marker_delete ( plane_track , framenr ) ;
}
2013-11-26 00:38:50 +01:00
changed = true ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
}
}
}
2012-03-24 06:38:07 +00:00
if ( ! has_selection ) {
2011-11-07 12:55:18 +00:00
/* nothing selected now, unlock view so it can be scrolled nice again */
2012-03-25 23:19:21 +00:00
sc - > flag & = ~ SC_LOCK_SELECTION ;
2011-11-07 12:55:18 +00:00
}
2013-11-26 00:38:50 +01:00
if ( ! changed )
return OPERATOR_CANCELLED ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_delete_marker ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Delete Marker " ;
ot - > idname = " CLIP_OT_delete_marker " ;
ot - > description = " Delete marker for current frame from selected tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2013-12-20 01:38:07 +01:00
ot - > invoke = WM_operator_confirm ;
2012-03-22 07:26:09 +00:00
ot - > exec = delete_marker_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** slide marker operator *********************/
2012-06-15 18:31:46 +00:00
# define SLIDE_ACTION_POS 0
# define SLIDE_ACTION_SIZE 1
# define SLIDE_ACTION_OFFSET 2
# define SLIDE_ACTION_TILT_SIZE 3
2011-11-07 12:55:18 +00:00
typedef struct {
2012-06-15 16:07:33 +00:00
short area , action ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
MovieTrackingMarker * marker ;
int mval [ 2 ] ;
int width , height ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
float * min , * max , * pos , * offset , ( * corners ) [ 2 ] ;
2012-06-15 16:07:33 +00:00
float spos [ 2 ] ;
2011-11-07 12:55:18 +00:00
2014-03-31 15:31:28 +06:00
bool lock , accurate ;
2012-06-15 16:07:33 +00:00
/* data to restore on cancel */
float old_search_min [ 2 ] , old_search_max [ 2 ] , old_pos [ 2 ] , old_offset [ 2 ] ;
float old_corners [ 4 ] [ 2 ] ;
float ( * old_markers ) [ 2 ] ;
2011-11-07 12:55:18 +00:00
} SlideMarkerData ;
2012-06-15 18:31:46 +00:00
static void slide_marker_tilt_slider ( MovieTrackingMarker * marker , float slider [ 2 ] )
{
add_v2_v2v2 ( slider , marker - > pattern_corners [ 1 ] , marker - > pattern_corners [ 2 ] ) ;
add_v2_v2 ( slider , marker - > pos ) ;
}
2011-11-07 12:55:18 +00:00
static SlideMarkerData * create_slide_marker_data ( SpaceClip * sc , MovieTrackingTrack * track ,
2013-03-13 09:03:46 +00:00
MovieTrackingMarker * marker , const wmEvent * event ,
2012-06-10 19:59:02 +00:00
int area , int corner , int action , int width , int height )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SlideMarkerData * data = MEM_callocN ( sizeof ( SlideMarkerData ) , " slide marker data " ) ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
marker = BKE_tracking_marker_ensure ( track , framenr ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
data - > area = area ;
data - > action = action ;
data - > track = track ;
data - > marker = marker ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( area = = TRACK_AREA_POINT ) {
data - > pos = marker - > pos ;
data - > offset = track - > offset ;
2012-03-24 06:38:07 +00:00
}
2012-03-25 23:19:21 +00:00
else if ( area = = TRACK_AREA_PAT ) {
if ( action = = SLIDE_ACTION_SIZE ) {
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
data - > corners = marker - > pattern_corners ;
2012-03-24 06:38:07 +00:00
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
else if ( action = = SLIDE_ACTION_OFFSET ) {
2011-11-07 12:55:18 +00:00
int a ;
2012-03-25 23:19:21 +00:00
data - > pos = marker - > pos ;
data - > offset = track - > offset ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
data - > old_markers = MEM_callocN ( sizeof ( * data - > old_markers ) * track - > markersnr , " slide marekrs " ) ;
2012-03-25 23:19:21 +00:00
for ( a = 0 ; a < track - > markersnr ; a + + )
2012-06-15 16:07:33 +00:00
copy_v2_v2 ( data - > old_markers [ a ] , track - > markers [ a ] . pos ) ;
2011-11-07 12:55:18 +00:00
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
else if ( action = = SLIDE_ACTION_POS ) {
data - > corners = marker - > pattern_corners ;
data - > pos = marker - > pattern_corners [ corner ] ;
copy_v2_v2 ( data - > spos , data - > pos ) ;
}
2012-06-15 18:31:46 +00:00
else if ( action = = SLIDE_ACTION_TILT_SIZE ) {
data - > corners = marker - > pattern_corners ;
slide_marker_tilt_slider ( marker , data - > spos ) ;
}
2012-03-24 06:38:07 +00:00
}
2012-03-25 23:19:21 +00:00
else if ( area = = TRACK_AREA_SEARCH ) {
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
data - > min = marker - > search_min ;
data - > max = marker - > search_max ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
data - > mval [ 0 ] = event - > mval [ 0 ] ;
data - > mval [ 1 ] = event - > mval [ 1 ] ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
data - > width = width ;
data - > height = height ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( action = = SLIDE_ACTION_SIZE )
2014-03-31 15:31:28 +06:00
data - > lock = true ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
/* backup marker's settings */
memcpy ( data - > old_corners , marker - > pattern_corners , sizeof ( data - > old_corners ) ) ;
copy_v2_v2 ( data - > old_search_min , marker - > search_min ) ;
copy_v2_v2 ( data - > old_search_max , marker - > search_max ) ;
copy_v2_v2 ( data - > old_pos , marker - > pos ) ;
copy_v2_v2 ( data - > old_offset , track - > offset ) ;
2011-11-07 12:55:18 +00:00
return data ;
}
2012-06-15 18:31:46 +00:00
static int mouse_on_slide_zone ( SpaceClip * sc , MovieTrackingMarker * marker ,
int area , float co [ 2 ] , float slide_zone [ 2 ] ,
float padding , int width , int height )
2011-11-07 12:55:18 +00:00
{
2012-06-15 18:31:46 +00:00
const float size = 12.0f ;
2011-11-07 12:55:18 +00:00
float min [ 2 ] , max [ 2 ] ;
2012-06-15 18:31:46 +00:00
float dx , dy ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( area = = TRACK_AREA_SEARCH ) {
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
copy_v2_v2 ( min , marker - > search_min ) ;
copy_v2_v2 ( max , marker - > search_max ) ;
2012-03-24 06:38:07 +00:00
}
else {
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
BKE_tracking_marker_pattern_minmax ( marker , min , max ) ;
2011-11-07 12:55:18 +00:00
}
2012-06-15 18:31:46 +00:00
min [ 0 ] - = padding / width ;
min [ 1 ] - = padding / height ;
max [ 0 ] + = padding / width ;
max [ 1 ] + = padding / height ;
2012-03-25 23:19:21 +00:00
dx = size / width / sc - > zoom ;
dy = size / height / sc - > zoom ;
2011-11-07 12:55:18 +00:00
2012-10-23 13:28:22 +00:00
dx = min_ff ( dx , ( max [ 0 ] - min [ 0 ] ) / 6.0f ) ;
dy = min_ff ( dy , ( max [ 1 ] - min [ 1 ] ) / 6.0f ) ;
2012-06-15 18:31:46 +00:00
return IN_RANGE_INCL ( co [ 0 ] , slide_zone [ 0 ] - dx , slide_zone [ 0 ] + dx ) & &
IN_RANGE_INCL ( co [ 1 ] , slide_zone [ 1 ] - dy , slide_zone [ 1 ] + dy ) ;
}
static int mouse_on_corner ( SpaceClip * sc , MovieTrackingMarker * marker ,
int area , float co [ 2 ] , int corner , float padding ,
int width , int height )
{
float min [ 2 ] , max [ 2 ] , crn [ 2 ] ;
if ( area = = TRACK_AREA_SEARCH ) {
copy_v2_v2 ( min , marker - > search_min ) ;
copy_v2_v2 ( max , marker - > search_max ) ;
}
else {
BKE_tracking_marker_pattern_minmax ( marker , min , max ) ;
}
2011-11-07 12:55:18 +00:00
2012-06-15 18:31:46 +00:00
min [ 0 ] - = padding / width ;
min [ 1 ] - = padding / height ;
max [ 0 ] + = padding / width ;
max [ 1 ] + = padding / height ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( corner = = 0 ) {
crn [ 0 ] = marker - > pos [ 0 ] + max [ 0 ] ;
crn [ 1 ] = marker - > pos [ 1 ] + min [ 1 ] ;
2012-03-24 06:38:07 +00:00
}
else {
2012-05-07 08:53:59 +00:00
crn [ 0 ] = marker - > pos [ 0 ] + min [ 0 ] ;
crn [ 1 ] = marker - > pos [ 1 ] + max [ 1 ] ;
2011-11-07 12:55:18 +00:00
}
2012-06-15 18:31:46 +00:00
return mouse_on_slide_zone ( sc , marker , area , co , crn , padding , width , height ) ;
2011-11-07 12:55:18 +00:00
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
static int get_mouse_pattern_corner ( SpaceClip * sc , MovieTrackingMarker * marker , float co [ 2 ] , int width , int height )
{
int i , next ;
float len = FLT_MAX , dx , dy ;
for ( i = 0 ; i < 4 ; i + + ) {
2014-02-03 02:46:45 +11:00
float cur_len_sq ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
next = ( i + 1 ) % 4 ;
2014-02-03 02:46:45 +11:00
cur_len_sq = len_squared_v2v2 ( marker - > pattern_corners [ i ] , marker - > pattern_corners [ next ] ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2014-02-03 02:46:45 +11:00
len = min_ff ( cur_len_sq , len ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
2014-02-02 01:36:40 +11:00
len = sqrtf ( len ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
dx = 12.0f / width / sc - > zoom ;
dy = 12.0f / height / sc - > zoom ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-10-23 13:28:22 +00:00
dx = min_ff ( dx , len * 2.0f / 3.0f ) ;
dy = min_ff ( dy , len * width / height * 2.0f / 3.0f ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
for ( i = 0 ; i < 4 ; i + + ) {
float crn [ 2 ] ;
int inside ;
add_v2_v2v2 ( crn , marker - > pattern_corners [ i ] , marker - > pos ) ;
inside = IN_RANGE_INCL ( co [ 0 ] , crn [ 0 ] - dx , crn [ 0 ] + dx ) & &
IN_RANGE_INCL ( co [ 1 ] , crn [ 1 ] - dy , crn [ 1 ] + dy ) ;
if ( inside )
return i ;
}
return - 1 ;
}
2011-11-07 12:55:18 +00:00
static int mouse_on_offset ( SpaceClip * sc , MovieTrackingTrack * track , MovieTrackingMarker * marker ,
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
float co [ 2 ] , int width , int height )
2011-11-07 12:55:18 +00:00
{
float pos [ 2 ] , dx , dy ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
float pat_min [ 2 ] , pat_max [ 2 ] ;
BKE_tracking_marker_pattern_minmax ( marker , pat_min , pat_max ) ;
2011-11-07 12:55:18 +00:00
add_v2_v2v2 ( pos , marker - > pos , track - > offset ) ;
2012-03-25 23:19:21 +00:00
dx = 12.0f / width / sc - > zoom ;
2012-05-07 08:53:59 +00:00
dy = 12.0f / height / sc - > zoom ;
2011-11-07 12:55:18 +00:00
2012-10-23 13:28:22 +00:00
dx = min_ff ( dx , ( pat_max [ 0 ] - pat_min [ 0 ] ) / 2.0f ) ;
dy = min_ff ( dy , ( pat_max [ 1 ] - pat_min [ 1 ] ) / 2.0f ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
return co [ 0 ] > = pos [ 0 ] - dx & & co [ 0 ] < = pos [ 0 ] + dx & & co [ 1 ] > = pos [ 1 ] - dy & & co [ 1 ] < = pos [ 1 ] + dy ;
2011-11-07 12:55:18 +00:00
}
2012-06-15 18:31:46 +00:00
static int mouse_on_tilt ( SpaceClip * sc , MovieTrackingMarker * marker , float co [ 2 ] , int width , int height )
{
float slider [ 2 ] ;
slide_marker_tilt_slider ( marker , slider ) ;
return mouse_on_slide_zone ( sc , marker , TRACK_AREA_PAT , co , slider , 0.0f , width , height ) ;
}
2013-09-05 13:37:53 +00:00
static bool slide_check_corners ( float ( * corners ) [ 2 ] )
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
{
int i , next , prev ;
float cross = 0.0f ;
float p [ 2 ] = { 0.0f , 0.0f } ;
if ( ! isect_point_quad_v2 ( p , corners [ 0 ] , corners [ 1 ] , corners [ 2 ] , corners [ 3 ] ) )
2013-09-05 13:37:53 +00:00
return false ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
for ( i = 0 ; i < 4 ; i + + ) {
float v1 [ 2 ] , v2 [ 2 ] , cur_cross ;
next = ( i + 1 ) % 4 ;
prev = ( 4 + i - 1 ) % 4 ;
sub_v2_v2v2 ( v1 , corners [ i ] , corners [ prev ] ) ;
sub_v2_v2v2 ( v2 , corners [ next ] , corners [ i ] ) ;
cur_cross = cross_v2v2 ( v1 , v2 ) ;
if ( fabsf ( cur_cross ) > FLT_EPSILON ) {
if ( cross = = 0.0f ) {
cross = cur_cross ;
}
else if ( cross * cur_cross < 0.0f ) {
2013-09-05 13:37:53 +00:00
return false ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
}
}
2013-09-05 13:37:53 +00:00
return true ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
2011-11-07 12:55:18 +00:00
static void hide_cursor ( bContext * C )
{
2012-03-25 23:19:21 +00:00
wmWindow * win = CTX_wm_window ( C ) ;
2011-11-07 12:55:18 +00:00
WM_cursor_set ( win , CURSOR_NONE ) ;
}
static void show_cursor ( bContext * C )
{
2012-03-25 23:19:21 +00:00
wmWindow * win = CTX_wm_window ( C ) ;
2011-11-07 12:55:18 +00:00
WM_cursor_set ( win , CURSOR_STD ) ;
}
2013-03-13 09:03:46 +00:00
MovieTrackingTrack * tracking_marker_check_slide ( bContext * C , const wmEvent * event , int * area_r , int * action_r , int * corner_r )
2012-06-15 11:40:04 +00:00
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-07-26 22:41:40 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-15 11:40:04 +00:00
MovieTrackingTrack * track ;
int width , height ;
float co [ 2 ] ;
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-06-15 14:26:27 +00:00
int action = - 1 , area = 0 , corner = - 1 ;
2012-06-15 11:40:04 +00:00
2012-07-26 22:41:40 +00:00
ED_space_clip_get_size ( sc , & width , & height ) ;
2012-06-15 11:40:04 +00:00
if ( width = = 0 | | height = = 0 )
return NULL ;
2012-07-27 15:15:55 +00:00
ED_clip_mouse_pos ( sc , ar , event - > mval , co ) ;
2012-06-15 11:40:04 +00:00
track = tracksbase - > first ;
while ( track ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_LOCKED ) = = 0 ) {
MovieTrackingMarker * marker = BKE_tracking_marker_get ( track , framenr ) ;
2013-09-05 13:37:53 +00:00
bool ok = false ;
2012-06-15 11:40:04 +00:00
if ( ( marker - > flag & MARKER_DISABLED ) = = 0 ) {
2012-06-15 14:26:27 +00:00
if ( mouse_on_offset ( sc , track , marker , co , width , height ) ) {
area = TRACK_AREA_POINT ;
action = SLIDE_ACTION_POS ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 14:26:27 +00:00
}
2012-06-15 11:40:04 +00:00
if ( ! ok & & ( sc - > flag & SC_SHOW_MARKER_SEARCH ) ) {
2012-06-15 18:31:46 +00:00
if ( mouse_on_corner ( sc , marker , TRACK_AREA_SEARCH , co , 1 , 0.0f , width , height ) ) {
2012-06-15 14:26:27 +00:00
area = TRACK_AREA_SEARCH ;
action = SLIDE_ACTION_OFFSET ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 11:40:04 +00:00
}
2012-06-15 18:31:46 +00:00
else if ( mouse_on_corner ( sc , marker , TRACK_AREA_SEARCH , co , 0 , 0.0f , width , height ) ) {
2012-06-15 14:26:27 +00:00
area = TRACK_AREA_SEARCH ;
action = SLIDE_ACTION_SIZE ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 11:40:04 +00:00
}
}
if ( ! ok & & ( sc - > flag & SC_SHOW_MARKER_PATTERN ) ) {
2012-06-15 18:31:46 +00:00
int current_corner = get_mouse_pattern_corner ( sc , marker , co , width , height ) ;
2012-06-15 11:40:04 +00:00
2012-06-15 18:31:46 +00:00
if ( current_corner ! = - 1 ) {
area = TRACK_AREA_PAT ;
action = SLIDE_ACTION_POS ;
corner = current_corner ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 11:40:04 +00:00
}
else {
2012-06-18 14:02:59 +00:00
#if 0
/* TODO: disable for now, needs better approaches for visualization */
2012-06-15 18:31:46 +00:00
if ( mouse_on_corner ( sc , marker , TRACK_AREA_PAT , co , 1 , 12.0f , width , height ) ) {
2012-06-15 14:26:27 +00:00
area = TRACK_AREA_PAT ;
action = SLIDE_ACTION_OFFSET ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 11:40:04 +00:00
}
2012-06-15 18:31:46 +00:00
if ( ! ok & & mouse_on_corner ( sc , marker , TRACK_AREA_PAT , co , 0 , 12.0f , width , height ) ) {
2012-06-15 14:26:27 +00:00
area = TRACK_AREA_PAT ;
action = SLIDE_ACTION_SIZE ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 11:40:04 +00:00
}
2012-06-18 14:02:59 +00:00
# endif
2012-06-15 18:31:46 +00:00
if ( ! ok & & mouse_on_tilt ( sc , marker , co , width , height ) ) {
area = TRACK_AREA_PAT ;
action = SLIDE_ACTION_TILT_SIZE ;
2013-09-05 13:37:53 +00:00
ok = true ;
2012-06-15 18:31:46 +00:00
}
2012-06-15 11:40:04 +00:00
}
}
2012-06-15 14:26:27 +00:00
if ( ok ) {
if ( area_r )
* area_r = area ;
if ( action_r )
* action_r = action ;
if ( corner_r )
* corner_r = corner ;
2012-06-15 11:40:04 +00:00
return track ;
2012-06-15 14:26:27 +00:00
}
2012-06-15 11:40:04 +00:00
}
}
track = track - > next ;
}
return NULL ;
}
2013-03-13 09:03:46 +00:00
static void * slide_marker_customdata ( bContext * C , const wmEvent * event )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-07-26 22:41:40 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
int width , height ;
float co [ 2 ] ;
2012-03-25 23:19:21 +00:00
void * customdata = NULL ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-06-15 14:26:27 +00:00
int area , action , corner ;
2011-11-07 12:55:18 +00:00
2012-07-26 22:41:40 +00:00
ED_space_clip_get_size ( sc , & width , & height ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( width = = 0 | | height = = 0 )
2011-11-07 12:55:18 +00:00
return NULL ;
2012-07-27 15:15:55 +00:00
ED_clip_mouse_pos ( sc , ar , event - > mval , co ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 14:26:27 +00:00
track = tracking_marker_check_slide ( C , event , & area , & action , & corner ) ;
if ( track ) {
MovieTrackingMarker * marker = BKE_tracking_marker_get ( track , framenr ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 14:26:27 +00:00
customdata = create_slide_marker_data ( sc , track , marker , event , area , corner , action , width , height ) ;
2011-11-07 12:55:18 +00:00
}
return customdata ;
}
2013-03-13 09:03:46 +00:00
static int slide_marker_invoke ( bContext * C , wmOperator * op , const wmEvent * event )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SlideMarkerData * slidedata = slide_marker_customdata ( C , event ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( slidedata ) {
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
tracking - > act_track = slidedata - > track ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
tracking - > act_plane_track = NULL ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
op - > customdata = slidedata ;
2011-11-07 12:55:18 +00:00
hide_cursor ( C ) ;
WM_event_add_modal_handler ( C , op ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_GEOM | ND_SELECT , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_RUNNING_MODAL ;
}
return OPERATOR_PASS_THROUGH ;
}
static void cancel_mouse_slide ( SlideMarkerData * data )
{
2012-06-15 16:07:33 +00:00
MovieTrackingTrack * track = data - > track ;
MovieTrackingMarker * marker = data - > marker ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
memcpy ( marker - > pattern_corners , data - > old_corners , sizeof ( marker - > pattern_corners ) ) ;
copy_v2_v2 ( marker - > search_min , data - > old_search_min ) ;
copy_v2_v2 ( marker - > search_max , data - > old_search_max ) ;
copy_v2_v2 ( marker - > pos , data - > old_pos ) ;
copy_v2_v2 ( track - > offset , data - > old_offset ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
if ( data - > old_markers ) {
int a ;
for ( a = 0 ; a < data - > track - > markersnr ; a + + )
copy_v2_v2 ( data - > track - > markers [ a ] . pos , data - > old_markers [ a ] ) ;
2011-11-07 12:55:18 +00:00
}
}
2013-09-10 12:46:18 +00:00
static void apply_mouse_slide ( bContext * C , SlideMarkerData * data )
{
if ( data - > area = = TRACK_AREA_POINT ) {
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTrackingPlaneTrack * plane_track ;
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( & clip - > tracking ) ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = plane_track - > next )
{
if ( ( plane_track - > flag & PLANE_TRACK_AUTOKEY ) = = 0 ) {
int i ;
for ( i = 0 ; i < plane_track - > point_tracksnr ; i + + ) {
if ( plane_track - > point_tracks [ i ] = = data - > track ) {
BKE_tracking_track_plane_from_existing_motion ( plane_track , framenr ) ;
break ;
}
}
}
}
}
}
2011-11-07 12:55:18 +00:00
static void free_slide_data ( SlideMarkerData * data )
{
2012-06-15 16:07:33 +00:00
if ( data - > old_markers )
MEM_freeN ( data - > old_markers ) ;
2012-03-25 23:19:21 +00:00
2011-11-07 12:55:18 +00:00
MEM_freeN ( data ) ;
}
2013-03-13 09:03:46 +00:00
static int slide_marker_modal ( bContext * C , wmOperator * op , const wmEvent * event )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-07-26 22:41:40 +00:00
ARegion * ar = CTX_wm_region ( C ) ;
2012-03-25 23:19:21 +00:00
SlideMarkerData * data = ( SlideMarkerData * ) op - > customdata ;
2011-11-07 12:55:18 +00:00
float dx , dy , mdelta [ 2 ] ;
2012-04-28 06:31:57 +00:00
switch ( event - > type ) {
2011-11-07 12:55:18 +00:00
case LEFTCTRLKEY :
case RIGHTCTRLKEY :
case LEFTSHIFTKEY :
case RIGHTSHIFTKEY :
2012-03-25 23:19:21 +00:00
if ( data - > action = = SLIDE_ACTION_SIZE )
2012-03-24 06:38:07 +00:00
if ( ELEM ( event - > type , LEFTCTRLKEY , RIGHTCTRLKEY ) )
2012-03-25 23:19:21 +00:00
data - > lock = event - > val = = KM_RELEASE ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ELEM ( event - > type , LEFTSHIFTKEY , RIGHTSHIFTKEY ) )
2012-03-25 23:19:21 +00:00
data - > accurate = event - > val = = KM_PRESS ;
2011-11-07 12:55:18 +00:00
2013-07-21 08:16:37 +00:00
/* fall-through */
2011-11-07 12:55:18 +00:00
case MOUSEMOVE :
2012-05-07 08:53:59 +00:00
mdelta [ 0 ] = event - > mval [ 0 ] - data - > mval [ 0 ] ;
mdelta [ 1 ] = event - > mval [ 1 ] - data - > mval [ 1 ] ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
dx = mdelta [ 0 ] / data - > width / sc - > zoom ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( data - > lock )
dy = - dx / data - > height * data - > width ;
else
dy = mdelta [ 1 ] / data - > height / sc - > zoom ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( data - > accurate ) {
2012-03-25 23:19:21 +00:00
dx / = 5 ;
dy / = 5 ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
if ( data - > area = = TRACK_AREA_POINT ) {
if ( data - > action = = SLIDE_ACTION_OFFSET ) {
2012-06-15 16:07:33 +00:00
data - > offset [ 0 ] = data - > old_offset [ 0 ] + dx ;
data - > offset [ 1 ] = data - > old_offset [ 1 ] + dy ;
2012-03-24 06:38:07 +00:00
}
else {
2012-06-15 16:07:33 +00:00
data - > pos [ 0 ] = data - > old_pos [ 0 ] + dx ;
data - > pos [ 1 ] = data - > old_pos [ 1 ] + dy ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & sc - > clip - > id , 0 ) ;
2012-03-24 06:38:07 +00:00
}
2012-06-15 16:07:33 +00:00
else if ( data - > area = = TRACK_AREA_PAT ) {
2012-03-25 23:19:21 +00:00
if ( data - > action = = SLIDE_ACTION_SIZE ) {
2012-06-15 18:31:46 +00:00
float start [ 2 ] , end [ 2 ] ;
float scale ;
2012-07-26 22:41:40 +00:00
ED_clip_point_stable_pos ( sc , ar , data - > mval [ 0 ] , data - > mval [ 1 ] , & start [ 0 ] , & start [ 1 ] ) ;
2012-06-15 18:31:46 +00:00
sub_v2_v2 ( start , data - > old_pos ) ;
2014-02-02 01:36:40 +11:00
if ( len_squared_v2 ( start ) ! = 0.0f ) {
2012-06-15 18:31:46 +00:00
float mval [ 2 ] ;
if ( data - > accurate ) {
mval [ 0 ] = data - > mval [ 0 ] + ( event - > mval [ 0 ] - data - > mval [ 0 ] ) / 5.0f ;
mval [ 1 ] = data - > mval [ 1 ] + ( event - > mval [ 1 ] - data - > mval [ 1 ] ) / 5.0f ;
}
else {
mval [ 0 ] = event - > mval [ 0 ] ;
mval [ 1 ] = event - > mval [ 1 ] ;
}
2012-07-26 22:41:40 +00:00
ED_clip_point_stable_pos ( sc , ar , mval [ 0 ] , mval [ 1 ] , & end [ 0 ] , & end [ 1 ] ) ;
2012-06-15 18:31:46 +00:00
sub_v2_v2 ( end , data - > old_pos ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
scale = len_v2 ( end ) / len_v2 ( start ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 18:31:46 +00:00
if ( scale > 0.0f ) {
int a ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
for ( a = 0 ; a < 4 ; a + + ) {
mul_v2_v2fl ( data - > corners [ a ] , data - > old_corners [ a ] , scale ) ;
}
}
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 16:07:33 +00:00
BKE_tracking_marker_clamp ( data - > marker , CLAMP_PAT_DIM ) ;
2012-03-24 06:38:07 +00:00
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
else if ( data - > action = = SLIDE_ACTION_OFFSET ) {
2012-03-25 23:19:21 +00:00
float d [ 2 ] = { dx , dy } ;
2012-06-15 16:07:33 +00:00
int a ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
for ( a = 0 ; a < data - > track - > markersnr ; a + + )
add_v2_v2v2 ( data - > track - > markers [ a ] . pos , data - > old_markers [ a ] , d ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 16:07:33 +00:00
sub_v2_v2v2 ( data - > offset , data - > old_offset , d ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
else if ( data - > action = = SLIDE_ACTION_POS ) {
2012-06-15 18:31:46 +00:00
float spos [ 2 ] ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
copy_v2_v2 ( spos , data - > pos ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
data - > pos [ 0 ] = data - > spos [ 0 ] + dx ;
data - > pos [ 1 ] = data - > spos [ 1 ] + dy ;
if ( ! slide_check_corners ( data - > corners ) ) {
copy_v2_v2 ( data - > pos , spos ) ;
}
/* currently only patterns are allowed to have such combination of event and data */
BKE_tracking_marker_clamp ( data - > marker , CLAMP_PAT_DIM ) ;
}
else if ( data - > action = = SLIDE_ACTION_TILT_SIZE ) {
float start [ 2 ] , end [ 2 ] ;
float scale = 1.0f , angle = 0.0f ;
int a ;
float mval [ 2 ] ;
if ( data - > accurate ) {
mval [ 0 ] = data - > mval [ 0 ] + ( event - > mval [ 0 ] - data - > mval [ 0 ] ) / 5.0f ;
mval [ 1 ] = data - > mval [ 1 ] + ( event - > mval [ 1 ] - data - > mval [ 1 ] ) / 5.0f ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
else {
2012-06-15 18:31:46 +00:00
mval [ 0 ] = event - > mval [ 0 ] ;
mval [ 1 ] = event - > mval [ 1 ] ;
}
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
sub_v2_v2v2 ( start , data - > spos , data - > old_pos ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-07-26 22:41:40 +00:00
ED_clip_point_stable_pos ( sc , ar , mval [ 0 ] , mval [ 1 ] , & end [ 0 ] , & end [ 1 ] ) ;
2012-06-15 18:31:46 +00:00
sub_v2_v2 ( end , data - > old_pos ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2014-02-02 01:36:40 +11:00
if ( len_squared_v2 ( start ) ! = 0.0f ) {
2012-06-15 18:31:46 +00:00
scale = len_v2 ( end ) / len_v2 ( start ) ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
2012-06-15 18:31:46 +00:00
if ( scale < 0.0f ) {
scale = 0.0 ;
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
}
}
2012-06-15 18:31:46 +00:00
angle = - angle_signed_v2v2 ( start , end ) ;
for ( a = 0 ; a < 4 ; a + + ) {
float vec [ 2 ] ;
mul_v2_v2fl ( data - > corners [ a ] , data - > old_corners [ a ] , scale ) ;
copy_v2_v2 ( vec , data - > corners [ a ] ) ;
vec [ 0 ] * = data - > width ;
vec [ 1 ] * = data - > height ;
2012-11-04 07:18:29 +00:00
data - > corners [ a ] [ 0 ] = ( vec [ 0 ] * cosf ( angle ) - vec [ 1 ] * sinf ( angle ) ) / data - > width ;
data - > corners [ a ] [ 1 ] = ( vec [ 1 ] * cosf ( angle ) + vec [ 0 ] * sinf ( angle ) ) / data - > height ;
2012-06-15 18:31:46 +00:00
}
2012-06-15 11:03:23 +00:00
BKE_tracking_marker_clamp ( data - > marker , CLAMP_PAT_DIM ) ;
2012-06-15 18:31:46 +00:00
2011-11-07 12:55:18 +00:00
}
}
2012-06-15 16:07:33 +00:00
else if ( data - > area = = TRACK_AREA_SEARCH ) {
if ( data - > action = = SLIDE_ACTION_SIZE ) {
data - > min [ 0 ] = data - > old_search_min [ 0 ] - dx ;
data - > max [ 0 ] = data - > old_search_max [ 0 ] + dx ;
data - > min [ 1 ] = data - > old_search_min [ 1 ] + dy ;
data - > max [ 1 ] = data - > old_search_max [ 1 ] - dy ;
BKE_tracking_marker_clamp ( data - > marker , CLAMP_SEARCH_DIM ) ;
}
else if ( data - > area = = TRACK_AREA_SEARCH ) {
float d [ 2 ] = { dx , dy } ;
add_v2_v2v2 ( data - > min , data - > old_search_min , d ) ;
add_v2_v2v2 ( data - > max , data - > old_search_max , d ) ;
}
BKE_tracking_marker_clamp ( data - > marker , CLAMP_SEARCH_POS ) ;
}
2011-11-07 12:55:18 +00:00
Planar tracking support for motion tracking
===========================================
Major list of changes done in tomato branch:
- Add a planar tracking implementation to libmv
This adds a new planar tracking implementation to libmv. The
tracker is based on Ceres[1], the new nonlinear minimizer that
myself and Sameer released from Google as open source. Since
the motion model is more involved, the interface is
different than the RegionTracker interface used previously
in Blender.
The start of a C API in libmv-capi.{cpp,h} is also included.
- Migrate from pat_{min,max} for markers to 4 corners representation
Convert markers in the movie clip editor / 2D tracker from using
pat_min and pat_max notation to using the a more general, 4-corner
representation.
There is still considerable porting work to do; in particular
sliding from preview widget does not work correct for rotated
markers.
All other areas should be ported to new representation:
* Added support of sliding individual corners. LMB slide + Ctrl
would scale the whole pattern
* S would scale the whole marker, S-S would scale pattern only
* Added support of marker's rotation which is currently rotates
only patterns around their centers or all markers around median,
Rotation or other non-translation/scaling transformation of search
area doesn't make sense.
* Track Preview widget would display transformed pattern which
libmv actually operates with.
- "Efficient Second-order Minimization" for the planar tracker
This implements the "Efficient Second-order Minimization"
scheme, as supported by the existing translation tracker.
This increases the amount of per-iteration work, but
decreases the number of iterations required to converge and
also increases the size of the basin of attraction for the
optimization.
- Remove the use of the legacy RegionTracker API from Blender,
and replaces it with the new TrackRegion API. This also
adds several features to the planar tracker in libmv:
* Do a brute-force initialization of tracking similar to "Hybrid"
mode in the stable release, but using all floats. This is slower
but more accurate. It is still necessary to evaluate if the
performance loss is worth it. In particular, this change is
necessary to support high bit depth imagery.
* Add support for masks over the search window. This is a step
towards supporting user-defined tracker masks. The tracker masks
will make it easy for users to make a mask for e.g. a ball.
Not exposed into interface yet/
* Add Pearson product moment correlation coefficient checking (aka
"Correlation" in the UI. This causes tracking failure if the
tracked patch is not linearly related to the template.
* Add support for warping a few points in addition to the supplied
points. This is useful because the tracking code deliberately
does not expose the underlying warp representation. Instead,
warps are specified in an aparametric way via the correspondences.
- Replace the old style tracker configuration panel with the
new planar tracking panel. From a users perspective, this means:
* The old "tracking algorithm" picker is gone. There is only 1
algorithm now. We may revisit this later, but I would much
prefer to have only 1 algorithm. So far no optimization work
has been done so the speed is not there yet.
* There is now a dropdown to select the motion model. Choices:
* Translation
* Translation, rotation
* Translation, scale
* Translation, rotation, scale
* Affine
* Perspective
* The old "Hybrid" mode is gone; instead there is a toggle to
enable or disable translation-only tracker initialization. This
is the equivalent of the hyrbid mode before, but rewritten to work
with the new planar tracking modes.
* The pyramid levels setting is gone. At a future date, the planar
tracker will decide to use pyramids or not automatically. The
pyramid setting was ultimately a mistake; with the brute force
initialization it is unnecessary.
- Add light-normalized tracking
Added the ability to normalize patterns by their average value while
tracking, to make them invariant to global illumination changes.
Additional details could be found at wiki page [2]
[1] http://code.google.com/p/ceres-solver
[2] http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker
2012-06-10 15:28:19 +00:00
data - > marker - > flag & = ~ MARKER_TRACKED ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , NULL ) ;
2011-11-07 12:55:18 +00:00
break ;
case LEFTMOUSE :
2012-03-25 23:19:21 +00:00
if ( event - > val = = KM_RELEASE ) {
2013-09-10 12:46:18 +00:00
apply_mouse_slide ( C , op - > customdata ) ;
2011-11-07 12:55:18 +00:00
free_slide_data ( op - > customdata ) ;
show_cursor ( C ) ;
return OPERATOR_FINISHED ;
}
break ;
case ESCKEY :
cancel_mouse_slide ( op - > customdata ) ;
free_slide_data ( op - > customdata ) ;
show_cursor ( C ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
}
return OPERATOR_RUNNING_MODAL ;
}
void CLIP_OT_slide_marker ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Slide Marker " ;
ot - > description = " Slide marker areas " ;
ot - > idname = " CLIP_OT_slide_marker " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-06-07 16:36:19 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2012-03-22 07:26:09 +00:00
ot - > invoke = slide_marker_invoke ;
ot - > modal = slide_marker_modal ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_float_vector ( ot - > srna , " offset " , 2 , NULL , - FLT_MAX , FLT_MAX ,
2012-06-10 19:59:02 +00:00
" Offset " , " Offset in floating point units, 1.0 is the width and height of the image " , - FLT_MAX , FLT_MAX ) ;
2011-11-07 12:55:18 +00:00
}
/********************** track operator *********************/
typedef struct TrackMarkersJob {
2012-06-10 19:59:02 +00:00
struct MovieTrackingContext * context ; /* tracking context */
int sfra , efra , lastfra ; /* Start, end and recently tracked frames */
int backwards ; /* Backwards tracking flag */
MovieClip * clip ; /* Clip which is tracking */
float delay ; /* Delay in milliseconds to allow tracking at fixed FPS */
2011-11-07 12:55:18 +00:00
struct Main * main ;
struct Scene * scene ;
struct bScreen * screen ;
} TrackMarkersJob ;
2014-02-05 22:36:15 +11:00
static bool track_markers_testbreak ( void )
2011-11-07 12:55:18 +00:00
{
2012-08-08 18:37:06 +00:00
return G . is_break ;
2011-11-07 12:55:18 +00:00
}
2013-10-28 21:49:49 +00:00
static int track_count_markers ( SpaceClip * sc , MovieClip * clip , int framenr )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
int tot = 0 ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2013-10-28 21:49:49 +00:00
bool selected = sc ? TRACK_VIEW_SELECTED ( sc , track ) : TRACK_SELECTED ( track ) ;
if ( selected & & ( track - > flag & TRACK_LOCKED ) = = 0 ) {
2012-06-15 11:03:23 +00:00
MovieTrackingMarker * marker = BKE_tracking_marker_get ( track , framenr ) ;
2011-12-04 10:57:36 +00:00
2012-03-25 23:19:21 +00:00
if ( ! marker | | ( marker - > flag & MARKER_DISABLED ) = = 0 )
2011-12-04 10:57:36 +00:00
tot + + ;
}
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
return tot ;
}
2012-01-09 20:18:48 +00:00
static void clear_invisible_track_selection ( SpaceClip * sc , MovieClip * clip )
{
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
2012-01-09 20:18:48 +00:00
int hidden = 0 ;
2012-05-07 08:53:59 +00:00
if ( ( sc - > flag & SC_SHOW_MARKER_PATTERN ) = = 0 )
2012-01-09 20:18:48 +00:00
hidden | = TRACK_AREA_PAT ;
2012-05-07 08:53:59 +00:00
if ( ( sc - > flag & SC_SHOW_MARKER_SEARCH ) = = 0 )
2012-01-09 20:18:48 +00:00
hidden | = TRACK_AREA_SEARCH ;
if ( hidden ) {
MovieTrackingTrack * track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-02-26 08:14:14 +00:00
if ( ( track - > flag & TRACK_HIDDEN ) = = 0 )
2012-06-15 11:03:23 +00:00
BKE_tracking_track_flag_clear ( track , hidden , SELECT ) ;
2012-01-09 20:18:48 +00:00
track = track - > next ;
}
}
}
2013-10-28 21:49:49 +00:00
static void track_init_markers ( SpaceClip * sc , MovieClip * clip , int framenr , int * frames_limit_r )
2011-11-07 12:55:18 +00:00
{
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
int frames_limit = 0 ;
2011-11-07 12:55:18 +00:00
2013-10-28 21:49:49 +00:00
if ( sc ! = NULL ) {
clear_invisible_track_selection ( sc , clip ) ;
}
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2013-10-28 21:49:49 +00:00
bool selected = sc ? TRACK_VIEW_SELECTED ( sc , track ) : TRACK_SELECTED ( track ) ;
if ( selected ) {
2012-05-07 08:53:59 +00:00
if ( ( track - > flag & TRACK_HIDDEN ) = = 0 & & ( track - > flag & TRACK_LOCKED ) = = 0 ) {
2012-06-15 11:03:23 +00:00
BKE_tracking_marker_ensure ( track , framenr ) ;
2011-11-28 13:26:46 +00:00
2012-03-24 06:38:07 +00:00
if ( track - > frames_limit ) {
2012-03-25 23:19:21 +00:00
if ( frames_limit = = 0 )
frames_limit = track - > frames_limit ;
2011-11-28 13:26:46 +00:00
else
2012-10-27 11:18:54 +00:00
frames_limit = min_ii ( frames_limit , ( int ) track - > frames_limit ) ;
2011-11-28 13:26:46 +00:00
}
}
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2011-11-28 13:26:46 +00:00
2012-03-25 23:19:21 +00:00
* frames_limit_r = frames_limit ;
2011-11-07 12:55:18 +00:00
}
2013-09-05 13:37:53 +00:00
static bool track_markers_check_direction ( int backwards , int curfra , int efra )
2011-11-07 12:55:18 +00:00
{
2012-03-24 06:38:07 +00:00
if ( backwards ) {
2012-03-25 23:19:21 +00:00
if ( curfra < efra )
2013-09-05 13:37:53 +00:00
return false ;
2011-11-07 12:55:18 +00:00
}
else {
2012-03-25 23:19:21 +00:00
if ( curfra > efra )
2013-09-05 13:37:53 +00:00
return false ;
2011-11-07 12:55:18 +00:00
}
2013-09-05 13:37:53 +00:00
return true ;
2011-11-07 12:55:18 +00:00
}
static int track_markers_initjob ( bContext * C , TrackMarkersJob * tmj , int backwards )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
MovieTrackingSettings * settings = & clip - > tracking . settings ;
2011-11-28 13:26:46 +00:00
int frames_limit ;
2013-10-28 21:49:49 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2011-11-28 13:26:46 +00:00
2013-10-28 21:49:49 +00:00
track_init_markers ( sc , clip , framenr , & frames_limit ) ;
2011-11-07 12:55:18 +00:00
2012-06-19 14:26:29 +00:00
tmj - > sfra = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-03-25 23:19:21 +00:00
tmj - > clip = clip ;
tmj - > backwards = backwards ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( backwards )
tmj - > efra = SFRA ;
else
tmj - > efra = EFRA ;
2011-11-07 12:55:18 +00:00
/* limit frames to be tracked by user setting */
2012-03-24 06:38:07 +00:00
if ( frames_limit ) {
2012-03-25 23:19:21 +00:00
if ( backwards )
tmj - > efra = MAX2 ( tmj - > efra , tmj - > sfra - frames_limit ) ;
else
tmj - > efra = MIN2 ( tmj - > efra , tmj - > sfra + frames_limit ) ;
2011-11-07 12:55:18 +00:00
}
2012-06-06 18:58:30 +00:00
tmj - > efra = BKE_movieclip_remap_scene_to_clip_frame ( clip , tmj - > efra ) ;
2012-03-25 23:19:21 +00:00
if ( settings - > speed ! = TRACKING_SPEED_FASTEST ) {
tmj - > delay = 1.0f / scene - > r . frs_sec * 1000.0f ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( settings - > speed = = TRACKING_SPEED_HALF )
tmj - > delay * = 2 ;
else if ( settings - > speed = = TRACKING_SPEED_QUARTER )
tmj - > delay * = 4 ;
else if ( settings - > speed = = TRACKING_SPEED_DOUBLE )
tmj - > delay / = 2 ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
tmj - > context = BKE_tracking_context_new ( clip , & sc - > user , backwards , 1 ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
clip - > tracking_context = tmj - > context ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
tmj - > lastfra = tmj - > sfra ;
2011-11-07 12:55:18 +00:00
2012-03-04 04:35:12 +00:00
/* XXX: silly to store this, but this data is needed to update scene and movie-clip
2012-03-03 16:31:46 +00:00
* frame numbers when tracking is finished . This introduces better feedback for artists .
* Maybe there ' s another way to solve this problem , but can ' t think better way atm .
* Anyway , this way isn ' t more unstable as animation rendering animation
* which uses the same approach ( except storing screen ) . */
2012-03-25 23:19:21 +00:00
tmj - > scene = scene ;
tmj - > main = CTX_data_main ( C ) ;
tmj - > screen = CTX_wm_screen ( C ) ;
2011-11-07 12:55:18 +00:00
return track_markers_check_direction ( backwards , tmj - > sfra , tmj - > efra ) ;
}
static void track_markers_startjob ( void * tmv , short * stop , short * do_update , float * progress )
{
2012-03-25 23:19:21 +00:00
TrackMarkersJob * tmj = ( TrackMarkersJob * ) tmv ;
int framenr = tmj - > sfra ;
2013-02-20 11:29:43 +00:00
// double t = PIL_check_seconds_timer();
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( framenr ! = tmj - > efra ) {
2012-03-25 23:19:21 +00:00
if ( tmj - > delay > 0 ) {
2011-11-07 12:55:18 +00:00
/* tracking should happen with fixed fps. Calculate time
2012-03-03 16:31:46 +00:00
* using current timer value before tracking frame and after .
*
* Small ( and maybe unneeded optimization ) : do not calculate exec_time
* for " Fastest " tracking */
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
double start_time = PIL_check_seconds_timer ( ) , exec_time ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
if ( ! BKE_tracking_context_step ( tmj - > context ) )
2011-11-07 12:55:18 +00:00
break ;
2012-05-07 08:53:59 +00:00
exec_time = PIL_check_seconds_timer ( ) - start_time ;
2012-03-24 06:38:07 +00:00
if ( tmj - > delay > ( float ) exec_time )
2012-05-07 08:53:59 +00:00
PIL_sleep_ms ( tmj - > delay - ( float ) exec_time ) ;
2012-03-24 06:38:07 +00:00
}
2012-06-15 11:03:23 +00:00
else if ( ! BKE_tracking_context_step ( tmj - > context ) )
2012-06-10 19:59:02 +00:00
break ;
2011-11-07 12:55:18 +00:00
2014-04-01 11:34:00 +11:00
* do_update = true ;
2012-05-07 08:53:59 +00:00
* progress = ( float ) ( framenr - tmj - > sfra ) / ( tmj - > efra - tmj - > sfra ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( tmj - > backwards )
framenr - - ;
else
framenr + + ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
tmj - > lastfra = framenr ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( * stop | | track_markers_testbreak ( ) )
2011-11-07 12:55:18 +00:00
break ;
}
2013-02-20 11:29:43 +00:00
// printf("Tracking time: %lf\n", PIL_check_seconds_timer()-t);
2011-11-07 12:55:18 +00:00
}
static void track_markers_updatejob ( void * tmv )
{
2012-03-25 23:19:21 +00:00
TrackMarkersJob * tmj = ( TrackMarkersJob * ) tmv ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_context_sync ( tmj - > context ) ;
2011-11-07 12:55:18 +00:00
}
2013-09-10 12:46:18 +00:00
static void track_markers_endjob ( void * tmv )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
TrackMarkersJob * tmj = ( TrackMarkersJob * ) tmv ;
2014-04-01 18:43:49 +06:00
wmWindowManager * wm = tmj - > main - > wm . first ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
tmj - > clip - > tracking_context = NULL ;
2012-06-06 18:58:30 +00:00
tmj - > scene - > r . cfra = BKE_movieclip_remap_clip_to_scene_frame ( tmj - > clip , tmj - > lastfra ) ;
2014-04-01 18:43:49 +06:00
if ( wm ! = NULL ) {
ED_update_for_newframe ( tmj - > main , tmj - > scene , 0 ) ;
}
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_context_sync ( tmj - > context ) ;
2013-09-10 12:46:18 +00:00
BKE_tracking_context_finish ( tmj - > context ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_main_add_notifier ( NC_SCENE | ND_FRAME , tmj - > scene ) ;
2013-09-10 12:46:18 +00:00
}
2013-07-23 14:22:47 +00:00
2013-09-10 12:46:18 +00:00
static void track_markers_freejob ( void * tmv )
{
TrackMarkersJob * tmj = ( TrackMarkersJob * ) tmv ;
BKE_tracking_context_free ( tmj - > context ) ;
2013-07-23 14:22:47 +00:00
MEM_freeN ( tmj ) ;
2011-11-07 12:55:18 +00:00
}
static int track_markers_exec ( bContext * C , wmOperator * op )
{
2013-10-28 21:49:49 +00:00
SpaceClip * sc ;
MovieClip * clip ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
2011-11-07 12:55:18 +00:00
struct MovieTrackingContext * context ;
2013-10-28 21:49:49 +00:00
MovieClipUser * user , fake_user = { 0 } ;
int framenr , sfra , efra ;
2014-02-03 18:55:59 +11:00
const bool backwards = RNA_boolean_get ( op - > ptr , " backwards " ) ;
const bool sequence = RNA_boolean_get ( op - > ptr , " sequence " ) ;
2011-11-28 13:26:46 +00:00
int frames_limit ;
2011-11-07 12:55:18 +00:00
2013-10-28 21:49:49 +00:00
if ( RNA_struct_property_is_set ( op - > ptr , " clip " ) ) {
Main * bmain = CTX_data_main ( C ) ;
char clip_name [ MAX_ID_NAME - 2 ] ;
RNA_string_get ( op - > ptr , " clip " , clip_name ) ;
clip = ( MovieClip * ) BLI_findstring ( & bmain - > movieclip , clip_name , offsetof ( ID , name ) + 2 ) ;
sc = NULL ;
if ( clip = = NULL ) {
return OPERATOR_CANCELLED ;
}
2013-10-29 03:04:46 +00:00
framenr = BKE_movieclip_remap_scene_to_clip_frame ( clip , CFRA ) ;
2013-10-28 21:49:49 +00:00
fake_user . framenr = framenr ;
user = & fake_user ;
}
else {
sc = CTX_wm_space_clip ( C ) ;
if ( sc = = NULL ) {
return OPERATOR_CANCELLED ;
}
clip = ED_space_clip_get_clip ( sc ) ;
framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
user = & sc - > user ;
}
sfra = framenr ;
if ( track_count_markers ( sc , clip , framenr ) = = 0 )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2013-10-28 21:49:49 +00:00
track_init_markers ( sc , clip , framenr , & frames_limit ) ;
2011-11-28 13:26:46 +00:00
2012-03-25 23:19:21 +00:00
if ( backwards )
efra = SFRA ;
else
efra = EFRA ;
2011-11-07 12:55:18 +00:00
/* limit frames to be tracked by user setting */
2012-03-24 06:38:07 +00:00
if ( frames_limit ) {
2012-05-07 08:53:59 +00:00
if ( backwards )
efra = MAX2 ( efra , sfra - frames_limit ) ;
else
efra = MIN2 ( efra , sfra + frames_limit ) ;
2011-11-07 12:55:18 +00:00
}
2012-06-06 18:58:30 +00:00
efra = BKE_movieclip_remap_scene_to_clip_frame ( clip , efra ) ;
2012-03-24 06:38:07 +00:00
if ( ! track_markers_check_direction ( backwards , framenr , efra ) )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
/* do not disable tracks due to threshold when tracking frame-by-frame */
2013-10-28 21:49:49 +00:00
context = BKE_tracking_context_new ( clip , user , backwards , sequence ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( framenr ! = efra ) {
2012-06-15 11:03:23 +00:00
if ( ! BKE_tracking_context_step ( context ) )
2011-11-07 12:55:18 +00:00
break ;
2012-03-24 06:38:07 +00:00
if ( backwards ) framenr - - ;
2011-11-07 12:55:18 +00:00
else framenr + + ;
2012-03-24 06:38:07 +00:00
if ( ! sequence )
2011-11-07 12:55:18 +00:00
break ;
}
2012-06-15 11:03:23 +00:00
BKE_tracking_context_sync ( context ) ;
2013-09-10 12:46:18 +00:00
BKE_tracking_context_finish ( context ) ;
2011-11-07 12:55:18 +00:00
BKE_tracking_context_free ( context ) ;
/* update scene current frame to the lastes tracked frame */
2012-06-06 18:58:30 +00:00
scene - > r . cfra = BKE_movieclip_remap_clip_to_scene_frame ( clip , framenr ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_SCENE | ND_FRAME , scene ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
2013-03-13 09:03:46 +00:00
static int track_markers_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2011-11-07 12:55:18 +00:00
{
TrackMarkersJob * tmj ;
2012-03-25 23:19:21 +00:00
ScrArea * sa = CTX_wm_area ( C ) ;
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2013-10-28 21:49:49 +00:00
MovieClip * clip ;
2012-08-15 10:03:29 +00:00
wmJob * wm_job ;
2013-10-28 21:49:49 +00:00
bool backwards = RNA_boolean_get ( op - > ptr , " backwards " ) ;
bool sequence = RNA_boolean_get ( op - > ptr , " sequence " ) ;
int framenr ;
if ( sc = = NULL ) {
2013-10-30 11:33:11 +00:00
/* TODO(sergey): Support clip for invoke as well. */
2013-10-28 21:49:49 +00:00
BKE_report ( op - > reports , RPT_ERROR ,
2013-11-04 18:58:22 +00:00
" Invoking this operator only supported from Clip Editor space " ) ;
2013-10-28 21:49:49 +00:00
return OPERATOR_CANCELLED ;
}
clip = ED_space_clip_get_clip ( sc ) ;
framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-08-15 09:42:06 +00:00
if ( WM_jobs_test ( CTX_wm_manager ( C ) , CTX_wm_area ( C ) , WM_JOB_TYPE_ANY ) ) {
2011-12-05 18:57:17 +00:00
/* only one tracking is allowed at a time */
return OPERATOR_CANCELLED ;
}
2012-03-24 06:38:07 +00:00
if ( clip - > tracking_context )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2013-10-28 21:49:49 +00:00
if ( track_count_markers ( sc , clip , framenr ) = = 0 )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2012-03-24 06:38:07 +00:00
if ( ! sequence )
2011-11-07 12:55:18 +00:00
return track_markers_exec ( C , op ) ;
2012-03-25 23:19:21 +00:00
tmj = MEM_callocN ( sizeof ( TrackMarkersJob ) , " TrackMarkersJob data " ) ;
2012-03-24 06:38:07 +00:00
if ( ! track_markers_initjob ( C , tmj , backwards ) ) {
2011-11-07 12:55:18 +00:00
track_markers_freejob ( tmj ) ;
return OPERATOR_CANCELLED ;
}
/* setup job */
2012-08-15 10:03:29 +00:00
wm_job = WM_jobs_get ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) , sa , " Track Markers " ,
WM_JOB_PROGRESS , WM_JOB_TYPE_CLIP_TRACK_MARKERS ) ;
WM_jobs_customdata_set ( wm_job , tmj , track_markers_freejob ) ;
2011-11-07 12:55:18 +00:00
/* if there's delay set in tracking job, tracking should happen
2012-03-08 04:12:11 +00:00
* with fixed FPS . To deal with editor refresh we have to synchronize
2012-03-03 16:31:46 +00:00
* tracks from job and tracks in clip . Do this in timer callback
* to prevent threading conflicts . */
2012-05-07 08:53:59 +00:00
if ( tmj - > delay > 0 )
2012-08-15 10:03:29 +00:00
WM_jobs_timer ( wm_job , tmj - > delay / 1000.0f , NC_MOVIECLIP | NA_EVALUATED , 0 ) ;
2012-05-07 08:53:59 +00:00
else
2012-08-15 10:03:29 +00:00
WM_jobs_timer ( wm_job , 0.2 , NC_MOVIECLIP | NA_EVALUATED , 0 ) ;
2011-11-07 12:55:18 +00:00
2013-09-10 12:46:18 +00:00
WM_jobs_callbacks ( wm_job , track_markers_startjob , NULL , track_markers_updatejob , track_markers_endjob ) ;
2011-11-07 12:55:18 +00:00
2014-03-20 15:52:00 +06:00
G . is_break = false ;
2011-11-07 12:55:18 +00:00
2012-08-15 10:03:29 +00:00
WM_jobs_start ( CTX_wm_manager ( C ) , wm_job ) ;
2011-11-07 12:55:18 +00:00
WM_cursor_wait ( 0 ) ;
/* add modal handler for ESC */
WM_event_add_modal_handler ( C , op ) ;
return OPERATOR_RUNNING_MODAL ;
}
2013-03-13 09:03:46 +00:00
static int track_markers_modal ( bContext * C , wmOperator * UNUSED ( op ) , const wmEvent * event )
2011-11-07 12:55:18 +00:00
{
2011-11-28 13:49:42 +00:00
/* no running tracking, remove handler and pass through */
2012-08-15 09:42:06 +00:00
if ( 0 = = WM_jobs_test ( CTX_wm_manager ( C ) , CTX_wm_area ( C ) , WM_JOB_TYPE_ANY ) )
2012-05-07 08:53:59 +00:00
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH ;
2011-11-07 12:55:18 +00:00
/* running tracking */
switch ( event - > type ) {
case ESCKEY :
return OPERATOR_RUNNING_MODAL ;
}
return OPERATOR_PASS_THROUGH ;
}
void CLIP_OT_track_markers ( wmOperatorType * ot )
{
2013-10-28 21:49:49 +00:00
PropertyRNA * prop ;
2011-11-07 12:55:18 +00:00
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Track Markers " ;
ot - > description = " Track selected markers " ;
ot - > idname = " CLIP_OT_track_markers " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = track_markers_exec ;
ot - > invoke = track_markers_invoke ;
ot - > modal = track_markers_modal ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-03-22 07:26:09 +00:00
ot - > flag = OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_boolean ( ot - > srna , " backwards " , 0 , " Backwards " , " Do backwards tracking " ) ;
RNA_def_boolean ( ot - > srna , " sequence " , 0 , " Track Sequence " , " Track marker during image sequence rather than single image " ) ;
2014-01-16 21:43:22 +11:00
prop = RNA_def_string ( ot - > srna , " clip " , NULL , MAX_NAME , " Movie Clip " , " Movie Clip to be tracked " ) ;
2013-10-28 21:49:49 +00:00
RNA_def_property_flag ( prop , PROP_SKIP_SAVE ) ;
2011-11-07 12:55:18 +00:00
}
2013-05-12 16:04:14 +00:00
/********************** refine track position operator *********************/
static int refine_marker_exec ( bContext * C , wmOperator * op )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTracking * tracking = & clip - > tracking ;
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
MovieTrackingTrack * track ;
bool backwards = RNA_boolean_get ( op - > ptr , " backwards " ) ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
for ( track = tracksbase - > first ; track ; track = track - > next ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
MovieTrackingMarker * marker = BKE_tracking_marker_get ( track , framenr ) ;
BKE_tracking_refine_marker ( clip , track , marker , backwards ) ;
}
}
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
return OPERATOR_FINISHED ;
}
void CLIP_OT_refine_markers ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Refine Markers " ;
ot - > description = " Refine selected markers positions "
" by running the tracker from track's reference to current frame " ;
ot - > idname = " CLIP_OT_refine_markers " ;
/* api callbacks */
ot - > exec = refine_marker_exec ;
ot - > poll = ED_space_clip_tracking_poll ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
RNA_def_boolean ( ot - > srna , " backwards " , 0 , " Backwards " , " Do backwards tracking " ) ;
}
2011-11-07 12:55:18 +00:00
/********************** solve camera operator *********************/
2011-11-28 13:49:42 +00:00
typedef struct {
Scene * scene ;
MovieClip * clip ;
MovieClipUser user ;
ReportList * reports ;
char stats_message [ 256 ] ;
struct MovieReconstructContext * context ;
} SolveCameraJob ;
static int solve_camera_initjob ( bContext * C , SolveCameraJob * scj , wmOperator * op , char * error_msg , int max_error )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * object = BKE_tracking_object_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
int width , height ;
Assorted camera tracker improvements
- Add support for refining the camera's intrinsic parameters
during a solve. Currently, refining supports only the following
combinations of intrinsic parameters:
f
f, cx, cy
f, cx, cy, k1, k2
f, k1
f, k1, k2
This is not the same as autocalibration, since the user must
still make a reasonable initial guess about the focal length and
other parameters, whereas true autocalibration would eliminate
the need for the user specify intrinsic parameters at all.
However, the solver works well with only rough guesses for the
focal length, so perhaps full autocalibation is not that
important.
Adding support for the last two combinations, (f, k1) and (f,
k1, k2) required changes to the library libmv depends on for
bundle adjustment, SSBA. These changes should get ported
upstream not just to libmv but to SSBA as well.
- Improved the region of convergence for bundle adjustment by
increasing the number of Levenberg-Marquardt iterations from 50
to 500. This way, the solver is able to crawl out of the bad
local minima it gets stuck in when changing from, for example,
bundling k1 and k2 to just k1 and resetting k2 to 0.
- Add several new region tracker implementations. A region tracker
is a libmv concept, which refers to tracking a template image
pattern through frames. The impact to end users is that tracking
should "just work better". I am reserving a more detailed
writeup, and maybe a paper, for later.
- Other libmv tweaks, such as detecting that a tracker is headed
outside of the image bounds.
This includes several changes made directly to the libmv extern
code rather expecting to get those changes through normal libmv
channels, because I, the libmv BDFL, decided it was faster to work
on libmv directly in Blender, then later reverse-port the libmv
changes from Blender back into libmv trunk. The interesting part
is that I added a full Levenberg-Marquardt loop to the region
tracking code, which should lead to a more stable solutions. I
also added a hacky implementation of "Efficient Second-Order
Minimization" for tracking, which works nicely. A more detailed
quantitative evaluation will follow.
Original patch by Keir, cleaned a bit by myself.
2011-11-14 06:41:23 +00:00
2012-06-15 11:03:23 +00:00
if ( ! BKE_tracking_reconstruction_check ( tracking , object , error_msg , max_error ) )
2011-11-28 13:49:42 +00:00
return 0 ;
2011-11-07 12:55:18 +00:00
/* could fail if footage uses images with different sizes */
2011-11-08 06:11:23 +00:00
BKE_movieclip_get_size ( clip , & sc - > user , & width , & height ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
scj - > clip = clip ;
scj - > scene = scene ;
scj - > reports = op - > reports ;
scj - > user = sc - > user ;
2011-11-28 13:49:42 +00:00
2013-10-26 13:22:38 +00:00
scj - > context = BKE_tracking_reconstruction_context_new ( clip , object ,
2012-10-09 10:33:18 +00:00
object - > keyframe1 , object - > keyframe2 , width , height ) ;
2011-11-28 13:49:42 +00:00
2012-03-25 23:19:21 +00:00
tracking - > stats = MEM_callocN ( sizeof ( MovieTrackingStats ) , " solve camera stats " ) ;
2011-11-28 13:49:42 +00:00
return 1 ;
}
static void solve_camera_updatejob ( void * scv )
{
2012-03-25 23:19:21 +00:00
SolveCameraJob * scj = ( SolveCameraJob * ) scv ;
MovieTracking * tracking = & scj - > clip - > tracking ;
2011-11-28 13:49:42 +00:00
BLI_strncpy ( tracking - > stats - > message , scj - > stats_message , sizeof ( tracking - > stats - > message ) ) ;
}
static void solve_camera_startjob ( void * scv , short * stop , short * do_update , float * progress )
{
2012-03-25 23:19:21 +00:00
SolveCameraJob * scj = ( SolveCameraJob * ) scv ;
2011-11-28 13:49:42 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_reconstruction_solve ( scj - > context , stop , do_update , progress ,
2012-06-10 19:59:02 +00:00
scj - > stats_message , sizeof ( scj - > stats_message ) ) ;
2011-11-28 13:49:42 +00:00
}
static void solve_camera_freejob ( void * scv )
{
2012-03-25 23:19:21 +00:00
SolveCameraJob * scj = ( SolveCameraJob * ) scv ;
MovieTracking * tracking = & scj - > clip - > tracking ;
Scene * scene = scj - > scene ;
MovieClip * clip = scj - > clip ;
2011-11-28 13:49:42 +00:00
int solved ;
2012-03-24 06:38:07 +00:00
if ( ! scj - > context ) {
2011-11-28 13:49:42 +00:00
/* job weren't fully initialized due to some error */
MEM_freeN ( scj ) ;
return ;
}
2012-06-15 11:03:23 +00:00
solved = BKE_tracking_reconstruction_finish ( scj - > context , tracking ) ;
2012-03-24 06:38:07 +00:00
if ( ! solved )
2012-10-26 17:32:50 +00:00
BKE_report ( scj - > reports , RPT_WARNING , " Some data failed to reconstruct (see console for details) " ) ;
2011-11-07 12:55:18 +00:00
else
2012-10-16 07:53:10 +00:00
BKE_reportf ( scj - > reports , RPT_INFO , " Average re-projection error: %.3f " , tracking - > reconstruction . error ) ;
2011-11-07 12:55:18 +00:00
2011-11-28 13:49:42 +00:00
/* set currently solved clip as active for scene */
2012-03-24 06:38:07 +00:00
if ( scene - > clip )
2011-11-08 06:11:23 +00:00
id_us_min ( & clip - > id ) ;
2012-03-25 23:19:21 +00:00
scene - > clip = clip ;
2011-11-07 12:55:18 +00:00
id_us_plus ( & clip - > id ) ;
2011-11-28 13:49:42 +00:00
/* set blender camera focal length so result would look fine there */
2012-11-27 15:10:22 +00:00
if ( scene - > camera & & scene - > camera - > data & & GS ( ( ( ID * ) scene - > camera - > data ) - > name ) = = ID_CA ) {
2012-06-10 19:59:02 +00:00
Camera * camera = ( Camera * ) scene - > camera - > data ;
2011-11-28 13:49:42 +00:00
int width , height ;
BKE_movieclip_get_size ( clip , & scj - > user , & width , & height ) ;
2011-11-07 12:55:18 +00:00
BKE_tracking_camera_to_blender ( tracking , scene , camera , width , height ) ;
2011-11-28 13:49:42 +00:00
WM_main_add_notifier ( NC_OBJECT , camera ) ;
2011-11-07 12:55:18 +00:00
}
2011-11-28 13:49:42 +00:00
MEM_freeN ( tracking - > stats ) ;
2012-03-25 23:19:21 +00:00
tracking - > stats = NULL ;
2011-11-28 13:49:42 +00:00
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_main_add_notifier ( NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_main_add_notifier ( NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-11-07 12:55:18 +00:00
/* update active clip displayed in scene buttons */
2011-11-28 13:49:42 +00:00
WM_main_add_notifier ( NC_SCENE , scene ) ;
BKE_tracking_reconstruction_context_free ( scj - > context ) ;
MEM_freeN ( scj ) ;
}
static int solve_camera_exec ( bContext * C , wmOperator * op )
{
SolveCameraJob * scj ;
2012-03-25 23:19:21 +00:00
char error_msg [ 256 ] = " \0 " ;
2011-11-28 13:49:42 +00:00
2012-03-25 23:19:21 +00:00
scj = MEM_callocN ( sizeof ( SolveCameraJob ) , " SolveCameraJob data " ) ;
2012-03-24 06:38:07 +00:00
if ( ! solve_camera_initjob ( C , scj , op , error_msg , sizeof ( error_msg ) ) ) {
if ( error_msg [ 0 ] )
2011-11-28 13:49:42 +00:00
BKE_report ( op - > reports , RPT_ERROR , error_msg ) ;
solve_camera_freejob ( scj ) ;
return OPERATOR_CANCELLED ;
}
solve_camera_startjob ( scj , NULL , NULL , NULL ) ;
solve_camera_freejob ( scj ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
2013-03-13 09:03:46 +00:00
static int solve_camera_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2011-11-28 13:49:42 +00:00
{
SolveCameraJob * scj ;
2012-03-25 23:19:21 +00:00
ScrArea * sa = CTX_wm_area ( C ) ;
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingReconstruction * reconstruction = BKE_tracking_get_active_reconstruction ( tracking ) ;
2012-08-15 10:03:29 +00:00
wmJob * wm_job ;
2012-03-25 23:19:21 +00:00
char error_msg [ 256 ] = " \0 " ;
2011-11-28 13:49:42 +00:00
2012-08-15 09:42:06 +00:00
if ( WM_jobs_test ( CTX_wm_manager ( C ) , CTX_wm_area ( C ) , WM_JOB_TYPE_ANY ) ) {
2011-12-05 18:57:17 +00:00
/* only one solve is allowed at a time */
return OPERATOR_CANCELLED ;
}
2012-03-25 23:19:21 +00:00
scj = MEM_callocN ( sizeof ( SolveCameraJob ) , " SolveCameraJob data " ) ;
2012-03-24 06:38:07 +00:00
if ( ! solve_camera_initjob ( C , scj , op , error_msg , sizeof ( error_msg ) ) ) {
if ( error_msg [ 0 ] )
2011-11-28 13:49:42 +00:00
BKE_report ( op - > reports , RPT_ERROR , error_msg ) ;
solve_camera_freejob ( scj ) ;
return OPERATOR_CANCELLED ;
}
BLI_strncpy ( tracking - > stats - > message , " Solving camera | Preparing solve " , sizeof ( tracking - > stats - > message ) ) ;
/* hide reconstruction statistics from previous solve */
2012-03-25 23:19:21 +00:00
reconstruction - > flag & = ~ TRACKING_RECONSTRUCTED ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
2011-11-28 13:49:42 +00:00
/* setup job */
2012-08-15 10:03:29 +00:00
wm_job = WM_jobs_get ( CTX_wm_manager ( C ) , CTX_wm_window ( C ) , sa , " Solve Camera " ,
WM_JOB_PROGRESS , WM_JOB_TYPE_CLIP_SOLVE_CAMERA ) ;
WM_jobs_customdata_set ( wm_job , scj , solve_camera_freejob ) ;
WM_jobs_timer ( wm_job , 0.1 , NC_MOVIECLIP | NA_EVALUATED , 0 ) ;
WM_jobs_callbacks ( wm_job , solve_camera_startjob , NULL , solve_camera_updatejob , NULL ) ;
2011-11-28 13:49:42 +00:00
2014-03-20 15:52:00 +06:00
G . is_break = false ;
2011-11-28 13:49:42 +00:00
2012-08-15 10:03:29 +00:00
WM_jobs_start ( CTX_wm_manager ( C ) , wm_job ) ;
2011-11-28 13:49:42 +00:00
WM_cursor_wait ( 0 ) ;
/* add modal handler for ESC */
WM_event_add_modal_handler ( C , op ) ;
return OPERATOR_RUNNING_MODAL ;
}
2013-03-13 09:03:46 +00:00
static int solve_camera_modal ( bContext * C , wmOperator * UNUSED ( op ) , const wmEvent * event )
2011-11-28 13:49:42 +00:00
{
/* no running solver, remove handler and pass through */
2012-08-15 09:42:06 +00:00
if ( 0 = = WM_jobs_test ( CTX_wm_manager ( C ) , CTX_wm_area ( C ) , WM_JOB_TYPE_ANY ) )
2012-05-07 08:53:59 +00:00
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH ;
2011-11-28 13:49:42 +00:00
/* running tracking */
switch ( event - > type ) {
case ESCKEY :
return OPERATOR_RUNNING_MODAL ;
}
return OPERATOR_PASS_THROUGH ;
}
2011-11-07 12:55:18 +00:00
void CLIP_OT_solve_camera ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Solve Camera " ;
ot - > description = " Solve camera motion from tracks " ;
ot - > idname = " CLIP_OT_solve_camera " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = solve_camera_exec ;
ot - > invoke = solve_camera_invoke ;
ot - > modal = solve_camera_modal ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** clear solution operator *********************/
static int clear_solution_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
MovieTrackingReconstruction * reconstruction = BKE_tracking_get_active_reconstruction ( tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
track - > flag & = ~ TRACK_HAS_BUNDLE ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( reconstruction - > cameras )
2011-12-05 18:57:17 +00:00
MEM_freeN ( reconstruction - > cameras ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
reconstruction - > cameras = NULL ;
reconstruction - > camnr = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
reconstruction - > flag & = ~ TRACKING_RECONSTRUCTED ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_SPACE | ND_SPACE_VIEW3D , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_clear_solution ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Clear Solution " ;
ot - > description = " Clear all calculated data " ;
ot - > idname = " CLIP_OT_clear_solution " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = clear_solution_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** clear track operator *********************/
static int clear_track_path_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-24 18:00:14 +00:00
MovieTracking * tracking = & clip - > tracking ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-06-24 18:00:14 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
int action = RNA_enum_get ( op - > ptr , " action " ) ;
2014-02-03 18:55:59 +11:00
const bool clear_active = RNA_boolean_get ( op - > ptr , " clear_active " ) ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-03-08 16:27:53 +00:00
if ( clear_active ) {
2012-06-24 18:00:14 +00:00
track = BKE_tracking_track_get_active ( tracking ) ;
2013-07-26 04:36:53 +00:00
if ( track ) {
BKE_tracking_track_path_clear ( track , framenr , action ) ;
}
2012-03-08 16:27:53 +00:00
}
else {
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) )
2012-06-15 11:03:23 +00:00
BKE_tracking_track_path_clear ( track , framenr , action ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2012-03-08 16:27:53 +00:00
}
2011-11-07 12:55:18 +00:00
}
2012-06-24 18:00:14 +00:00
BKE_tracking_dopesheet_tag_update ( tracking ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_clear_track_path ( wmOperatorType * ot )
{
static EnumPropertyItem clear_path_actions [ ] = {
2012-06-10 19:59:02 +00:00
{ TRACK_CLEAR_UPTO , " UPTO " , 0 , " Clear up-to " , " Clear path up to current frame " } ,
{ TRACK_CLEAR_REMAINED , " REMAINED " , 0 , " Clear remained " , " Clear path at remaining frames (after current) " } ,
{ TRACK_CLEAR_ALL , " ALL " , 0 , " Clear all " , " Clear the whole path " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Clear Track Path " ;
ot - > description = " Clear tracks after/before current position or clear the whole track " ;
ot - > idname = " CLIP_OT_clear_track_path " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = clear_track_path_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* proeprties */
RNA_def_enum ( ot - > srna , " action " , clear_path_actions , TRACK_CLEAR_REMAINED , " Action " , " Clear action to execute " ) ;
2012-03-08 16:27:53 +00:00
RNA_def_boolean ( ot - > srna , " clear_active " , 0 , " Clear Active " , " Clear active track only instead of all selected tracks " ) ;
2011-11-07 12:55:18 +00:00
}
/********************** disable markers operator *********************/
static int disable_markers_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first ;
int action = RNA_enum_get ( op - > ptr , " action " ) ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-05-07 08:53:59 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_LOCKED ) = = 0 ) {
2012-06-15 11:03:23 +00:00
MovieTrackingMarker * marker = BKE_tracking_marker_ensure ( track , framenr ) ;
2012-03-25 23:19:21 +00:00
if ( action = = 0 )
marker - > flag | = MARKER_DISABLED ;
else if ( action = = 1 )
marker - > flag & = ~ MARKER_DISABLED ;
else marker - > flag ^ = MARKER_DISABLED ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_disable_markers ( wmOperatorType * ot )
{
static EnumPropertyItem actions_items [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " DISABLE " , 0 , " Disable " , " Disable selected markers " } ,
{ 1 , " ENABLE " , 0 , " Enable " , " Enable selected markers " } ,
{ 2 , " TOGGLE " , 0 , " Toggle " , " Toggle disabled flag for selected markers " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Disable Markers " ;
ot - > description = " Disable/enable selected markers " ;
ot - > idname = " CLIP_OT_disable_markers " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = disable_markers_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_enum ( ot - > srna , " action " , actions_items , 0 , " Action " , " Disable action to execute " ) ;
}
/********************** set origin operator *********************/
2011-12-21 14:51:01 +00:00
static Object * get_camera_with_movieclip ( Scene * scene , MovieClip * clip )
{
2012-03-25 23:19:21 +00:00
Object * camera = scene - > camera ;
2011-12-21 14:51:01 +00:00
Base * base ;
2013-09-09 11:37:37 +00:00
if ( camera & & BKE_object_movieclip_get ( scene , camera , false ) = = clip )
2011-12-21 14:51:01 +00:00
return camera ;
2012-03-25 23:19:21 +00:00
base = scene - > base . first ;
2012-03-24 06:38:07 +00:00
while ( base ) {
if ( base - > object - > type = = OB_CAMERA ) {
2013-09-09 11:37:37 +00:00
if ( BKE_object_movieclip_get ( scene , base - > object , false ) = = clip ) {
2012-03-25 23:19:21 +00:00
camera = base - > object ;
2011-12-21 14:51:01 +00:00
break ;
}
}
2012-03-25 23:19:21 +00:00
base = base - > next ;
2011-12-21 14:51:01 +00:00
}
return camera ;
}
static Object * get_orientation_object ( bContext * C )
{
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2012-03-25 23:19:21 +00:00
Object * object = NULL ;
2011-12-21 14:51:01 +00:00
2012-03-25 23:19:21 +00:00
if ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) {
object = get_camera_with_movieclip ( scene , clip ) ;
2011-12-21 14:51:01 +00:00
}
else {
2012-03-25 23:19:21 +00:00
object = OBACT ;
2011-12-21 14:51:01 +00:00
}
2012-03-24 06:38:07 +00:00
if ( object & & object - > parent )
2012-03-25 23:19:21 +00:00
object = object - > parent ;
2011-12-21 14:51:01 +00:00
return object ;
}
2011-12-18 18:31:02 +00:00
static int set_orientation_poll ( bContext * C )
{
2012-06-07 16:36:19 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-03-25 23:19:21 +00:00
2012-06-08 08:24:08 +00:00
if ( sc ) {
Scene * scene = CTX_data_scene ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-08 08:24:08 +00:00
2012-06-10 09:04:49 +00:00
if ( clip ) {
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2012-06-10 09:04:49 +00:00
if ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) {
2014-04-01 11:34:00 +11:00
return true ;
2012-06-10 09:04:49 +00:00
}
else {
return OBACT ! = NULL ;
}
2012-06-08 08:24:08 +00:00
}
2011-12-18 18:31:02 +00:00
}
2014-04-01 11:34:00 +11:00
return false ;
2011-12-18 18:31:02 +00:00
}
2011-11-07 12:55:18 +00:00
static int count_selected_bundles ( bContext * C )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( & clip - > tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
int tot = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_HAS_BUNDLE ) )
2011-11-07 12:55:18 +00:00
tot + + ;
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
return tot ;
}
2011-12-15 16:09:57 +00:00
static void object_solver_inverted_matrix ( Scene * scene , Object * ob , float invmat [ 4 ] [ 4 ] )
{
bConstraint * con ;
2013-09-05 13:37:53 +00:00
bool found = false ;
2011-12-15 16:09:57 +00:00
2012-03-25 23:19:21 +00:00
for ( con = ob - > constraints . first ; con ; con = con - > next ) {
2014-04-11 11:47:07 +10:00
bConstraintTypeInfo * cti = BKE_constraint_typeinfo_get ( con ) ;
2011-12-15 16:09:57 +00:00
2012-03-24 06:38:07 +00:00
if ( ! cti )
2011-12-15 16:09:57 +00:00
continue ;
2012-03-25 23:19:21 +00:00
if ( cti - > type = = CONSTRAINT_TYPE_OBJECTSOLVER ) {
bObjectSolverConstraint * data = ( bObjectSolverConstraint * ) con - > data ;
2011-12-15 16:09:57 +00:00
2012-03-24 06:38:07 +00:00
if ( ! found ) {
2012-03-25 23:19:21 +00:00
Object * cam = data - > camera ? data - > camera : scene - > camera ;
2011-12-21 14:51:01 +00:00
2012-05-05 14:03:12 +00:00
BKE_object_where_is_calc_mat4 ( scene , cam , invmat ) ;
2011-12-21 14:51:01 +00:00
}
2013-05-26 18:36:25 +00:00
mul_m4_m4m4 ( invmat , invmat , data - > invmat ) ;
2011-12-21 14:51:01 +00:00
2013-09-05 13:37:53 +00:00
found = true ;
2011-12-15 16:09:57 +00:00
}
}
2012-03-24 06:38:07 +00:00
if ( found )
2011-12-21 14:51:01 +00:00
invert_m4 ( invmat ) ;
else
unit_m4 ( invmat ) ;
}
static Object * object_solver_camera ( Scene * scene , Object * ob )
{
bConstraint * con ;
2012-03-25 23:19:21 +00:00
for ( con = ob - > constraints . first ; con ; con = con - > next ) {
2014-04-11 11:47:07 +10:00
bConstraintTypeInfo * cti = BKE_constraint_typeinfo_get ( con ) ;
2011-12-21 14:51:01 +00:00
2012-03-24 06:38:07 +00:00
if ( ! cti )
2011-12-21 14:51:01 +00:00
continue ;
2012-03-25 23:19:21 +00:00
if ( cti - > type = = CONSTRAINT_TYPE_OBJECTSOLVER ) {
bObjectSolverConstraint * data = ( bObjectSolverConstraint * ) con - > data ;
2011-12-21 14:51:01 +00:00
return data - > camera ? data - > camera : scene - > camera ;
}
}
return NULL ;
2011-12-15 16:09:57 +00:00
}
2011-11-07 12:55:18 +00:00
static int set_origin_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2011-12-05 18:57:17 +00:00
MovieTrackingObject * tracking_object ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
2011-12-05 18:57:17 +00:00
Object * object ;
2012-03-25 23:19:21 +00:00
Object * camera = get_camera_with_movieclip ( scene , clip ) ;
2011-12-05 18:57:17 +00:00
ListBase * tracksbase ;
2011-12-15 16:09:57 +00:00
float mat [ 4 ] [ 4 ] , vec [ 3 ] , median [ 3 ] ;
2012-03-25 23:19:21 +00:00
int selected_count = count_selected_bundles ( C ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( selected_count = = 0 ) {
2012-06-15 14:11:23 +00:00
BKE_report ( op - > reports , RPT_ERROR ,
" At least one track with bundle should be selected to define origin position " ) ;
2011-12-05 18:57:17 +00:00
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
}
2012-03-25 23:19:21 +00:00
object = get_orientation_object ( C ) ;
2012-03-24 06:38:07 +00:00
if ( ! object ) {
2011-12-21 14:51:01 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No object to apply orientation on " ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
}
2012-06-15 11:03:23 +00:00
tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
tracksbase = BKE_tracking_object_get_tracks ( tracking , tracking_object ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2011-12-15 16:09:57 +00:00
zero_v3 ( median ) ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_HAS_BUNDLE ) ) {
2011-12-15 16:09:57 +00:00
add_v3_v3 ( median , track - > bundle_pos ) ;
}
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
mul_v3_fl ( median , 1.0f / selected_count ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_get_camera_object_matrix ( scene , camera , mat ) ;
2011-11-07 12:55:18 +00:00
2011-12-15 16:09:57 +00:00
mul_v3_m4v3 ( vec , mat , median ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) {
2011-12-05 18:57:17 +00:00
sub_v3_v3 ( object - > loc , vec ) ;
2011-12-15 16:09:57 +00:00
}
else {
object_solver_inverted_matrix ( scene , object , mat ) ;
mul_v3_m4v3 ( vec , mat , vec ) ;
2011-12-05 18:57:17 +00:00
copy_v3_v3 ( object - > loc , vec ) ;
2011-12-15 16:09:57 +00:00
}
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2011-12-05 18:57:17 +00:00
DAG_id_tag_update ( & object - > id , OB_RECALC_OB ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_set_origin ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Origin " ;
2014-02-12 15:32:06 +01:00
ot - > description = " Set active marker as origin by moving camera (or its parent if present) in 3D space " ;
2012-03-22 07:26:09 +00:00
ot - > idname = " CLIP_OT_set_origin " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_origin_exec ;
ot - > poll = set_orientation_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-12-15 16:09:57 +00:00
/* properties */
RNA_def_boolean ( ot - > srna , " use_median " , 0 , " Use Median " , " Set origin to median point of selected bundles " ) ;
2011-11-07 12:55:18 +00:00
}
/********************** set floor operator *********************/
2011-12-21 14:51:01 +00:00
static void set_axis ( Scene * scene , Object * ob , MovieClip * clip , MovieTrackingObject * tracking_object ,
2012-06-10 19:59:02 +00:00
MovieTrackingTrack * track , char axis )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
Object * camera = get_camera_with_movieclip ( scene , clip ) ;
2014-02-03 18:55:59 +11:00
const bool is_camera = ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) ! = 0 ;
2013-09-05 13:37:53 +00:00
bool flip = false ;
2011-12-05 18:57:17 +00:00
float mat [ 4 ] [ 4 ] , vec [ 3 ] , obmat [ 4 ] [ 4 ] , dvec [ 3 ] ;
2012-05-05 14:03:12 +00:00
BKE_object_to_mat4 ( ob , obmat ) ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_get_camera_object_matrix ( scene , camera , mat ) ;
2011-11-07 12:55:18 +00:00
mul_v3_m4v3 ( vec , mat , track - > bundle_pos ) ;
2011-12-05 18:57:17 +00:00
copy_v3_v3 ( dvec , vec ) ;
2012-03-24 06:38:07 +00:00
if ( ! is_camera ) {
2011-12-05 18:57:17 +00:00
float imat [ 4 ] [ 4 ] ;
2011-12-15 16:09:57 +00:00
object_solver_inverted_matrix ( scene , ob , imat ) ;
mul_v3_m4v3 ( vec , imat , vec ) ;
2011-12-05 18:57:17 +00:00
invert_m4_m4 ( imat , obmat ) ;
mul_v3_m4v3 ( dvec , imat , vec ) ;
sub_v3_v3 ( vec , obmat [ 3 ] ) ;
}
2011-11-07 12:55:18 +00:00
2014-02-02 01:36:40 +11:00
if ( len_squared_v2 ( vec ) < ( 1e-3 f * 1e-3 f ) )
2011-11-07 12:55:18 +00:00
return ;
unit_m4 ( mat ) ;
2012-03-25 23:19:21 +00:00
if ( axis = = ' X ' ) {
if ( fabsf ( dvec [ 1 ] ) < 1e-3 f ) {
2013-09-05 13:37:53 +00:00
flip = true ;
2011-12-05 18:57:17 +00:00
2012-03-25 23:19:21 +00:00
mat [ 0 ] [ 0 ] = - 1.0f ; mat [ 0 ] [ 1 ] = 0.0f ; mat [ 0 ] [ 2 ] = 0.0f ;
mat [ 1 ] [ 0 ] = 0.0f ; mat [ 1 ] [ 1 ] = - 1.0f ; mat [ 1 ] [ 2 ] = 0.0f ;
mat [ 2 ] [ 0 ] = 0.0f ; mat [ 2 ] [ 1 ] = 0.0f ; mat [ 2 ] [ 2 ] = 1.0f ;
2012-03-24 06:38:07 +00:00
}
else {
2011-11-07 12:55:18 +00:00
copy_v3_v3 ( mat [ 0 ] , vec ) ;
2011-12-05 18:57:17 +00:00
2012-03-25 23:19:21 +00:00
if ( is_camera | | fabsf ( vec [ 2 ] ) < 1e-3 f ) {
mat [ 0 ] [ 2 ] = 0.0f ;
mat [ 2 ] [ 0 ] = 0.0f ; mat [ 2 ] [ 1 ] = 0.0f ; mat [ 2 ] [ 2 ] = 1.0f ;
2011-12-05 18:57:17 +00:00
cross_v3_v3v3 ( mat [ 1 ] , mat [ 2 ] , mat [ 0 ] ) ;
}
else {
2012-03-25 23:19:21 +00:00
vec [ 2 ] = 0.0f ;
2011-12-05 18:57:17 +00:00
cross_v3_v3v3 ( mat [ 1 ] , mat [ 0 ] , vec ) ;
cross_v3_v3v3 ( mat [ 2 ] , mat [ 0 ] , mat [ 1 ] ) ;
}
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
}
else {
2012-03-25 23:19:21 +00:00
if ( fabsf ( dvec [ 0 ] ) < 1e-3 f ) {
2013-09-05 13:37:53 +00:00
flip = true ;
2011-12-05 18:57:17 +00:00
2012-03-25 23:19:21 +00:00
mat [ 0 ] [ 0 ] = - 1.0f ; mat [ 0 ] [ 1 ] = 0.0f ; mat [ 0 ] [ 2 ] = 0.0f ;
mat [ 1 ] [ 0 ] = 0.0f ; mat [ 1 ] [ 1 ] = - 1.0f ; mat [ 1 ] [ 2 ] = 0.0f ;
mat [ 2 ] [ 0 ] = 0.0f ; mat [ 2 ] [ 1 ] = 0.0f ; mat [ 2 ] [ 2 ] = 1.0f ;
2012-03-24 06:38:07 +00:00
}
else {
2011-11-07 12:55:18 +00:00
copy_v3_v3 ( mat [ 1 ] , vec ) ;
2011-12-05 18:57:17 +00:00
2012-05-07 08:53:59 +00:00
if ( is_camera | | fabsf ( vec [ 2 ] ) < 1e-3 f ) {
2012-03-25 23:19:21 +00:00
mat [ 1 ] [ 2 ] = 0.0f ;
mat [ 2 ] [ 0 ] = 0.0f ; mat [ 2 ] [ 1 ] = 0.0f ; mat [ 2 ] [ 2 ] = 1.0f ;
2011-12-05 18:57:17 +00:00
cross_v3_v3v3 ( mat [ 0 ] , mat [ 1 ] , mat [ 2 ] ) ;
}
else {
2012-03-25 23:19:21 +00:00
vec [ 2 ] = 0.0f ;
2011-12-05 18:57:17 +00:00
cross_v3_v3v3 ( mat [ 0 ] , vec , mat [ 1 ] ) ;
cross_v3_v3v3 ( mat [ 2 ] , mat [ 0 ] , mat [ 1 ] ) ;
}
2011-11-07 12:55:18 +00:00
}
}
normalize_v3 ( mat [ 0 ] ) ;
normalize_v3 ( mat [ 1 ] ) ;
normalize_v3 ( mat [ 2 ] ) ;
2012-03-24 06:38:07 +00:00
if ( is_camera ) {
2011-12-05 18:57:17 +00:00
invert_m4 ( mat ) ;
2013-05-26 18:36:25 +00:00
mul_m4_m4m4 ( mat , mat , obmat ) ;
2011-12-05 18:57:17 +00:00
}
else {
2012-03-24 06:38:07 +00:00
if ( ! flip ) {
2011-12-15 16:09:57 +00:00
float lmat [ 4 ] [ 4 ] , ilmat [ 4 ] [ 4 ] , rmat [ 3 ] [ 3 ] ;
2011-12-05 18:57:17 +00:00
2014-03-20 15:52:00 +06:00
BKE_object_rot_to_mat3 ( ob , rmat , true ) ;
2011-12-15 16:09:57 +00:00
invert_m3 ( rmat ) ;
mul_m4_m4m3 ( mat , mat , rmat ) ;
2011-12-05 18:57:17 +00:00
2011-12-15 16:09:57 +00:00
unit_m4 ( lmat ) ;
copy_v3_v3 ( lmat [ 3 ] , obmat [ 3 ] ) ;
invert_m4_m4 ( ilmat , lmat ) ;
2011-12-05 18:57:17 +00:00
2011-12-15 16:09:57 +00:00
mul_serie_m4 ( mat , lmat , mat , ilmat , obmat , NULL , NULL , NULL , NULL ) ;
}
else {
2013-05-26 18:36:25 +00:00
mul_m4_m4m4 ( mat , obmat , mat ) ;
2011-12-15 16:09:57 +00:00
}
2011-12-05 18:57:17 +00:00
}
2011-11-07 12:55:18 +00:00
2012-05-05 14:03:12 +00:00
BKE_object_apply_mat4 ( ob , mat , 0 , 0 ) ;
2011-11-07 12:55:18 +00:00
}
2012-03-06 12:27:42 +00:00
static int set_plane_exec ( bContext * C , wmOperator * op )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
MovieTracking * tracking = & clip - > tracking ;
2011-12-05 18:57:17 +00:00
MovieTrackingObject * tracking_object ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track , * axis_track = NULL , * act_track ;
2011-12-05 18:57:17 +00:00
ListBase * tracksbase ;
Object * object ;
2012-03-25 23:19:21 +00:00
Object * camera = get_camera_with_movieclip ( scene , clip ) ;
int tot = 0 ;
float vec [ 3 ] [ 3 ] , mat [ 4 ] [ 4 ] , obmat [ 4 ] [ 4 ] , newmat [ 4 ] [ 4 ] , orig [ 3 ] = { 0.0f , 0.0f , 0.0f } ;
int plane = RNA_enum_get ( op - > ptr , " plane " ) ;
float rot [ 4 ] [ 4 ] = { { 0.0f , 0.0f , - 1.0f , 0.0f } ,
{ 0.0f , 1.0f , 0.0f , 0.0f } ,
{ 1.0f , 0.0f , 0.0f , 0.0f } ,
2012-06-10 19:59:02 +00:00
{ 0.0f , 0.0f , 0.0f , 1.0f } } ; /* 90 degrees Y-axis rotation matrix */
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
if ( count_selected_bundles ( C ) ! = 3 ) {
2011-11-07 12:55:18 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Three tracks with bundles are needed to orient the floor " ) ;
2011-12-05 18:57:17 +00:00
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
}
2012-06-15 11:03:23 +00:00
tracking_object = BKE_tracking_object_get_active ( tracking ) ;
tracksbase = BKE_tracking_object_get_tracks ( tracking , tracking_object ) ;
act_track = BKE_tracking_track_get_active ( tracking ) ;
2011-12-05 18:57:17 +00:00
2012-03-25 23:19:21 +00:00
object = get_orientation_object ( C ) ;
2012-03-24 06:38:07 +00:00
if ( ! object ) {
2011-12-21 14:51:01 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No object to apply orientation on " ) ;
2011-12-05 18:57:17 +00:00
2011-12-21 14:51:01 +00:00
return OPERATOR_CANCELLED ;
}
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_get_camera_object_matrix ( scene , camera , mat ) ;
2011-11-07 12:55:18 +00:00
/* get 3 bundles to use as reference */
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-05-07 08:53:59 +00:00
while ( track & & tot < 3 ) {
2012-03-25 23:19:21 +00:00
if ( track - > flag & TRACK_HAS_BUNDLE & & TRACK_VIEW_SELECTED ( sc , track ) ) {
2011-11-07 12:55:18 +00:00
mul_v3_m4v3 ( vec [ tot ] , mat , track - > bundle_pos ) ;
2012-03-25 23:19:21 +00:00
if ( tot = = 0 | | track = = act_track )
2011-11-07 12:55:18 +00:00
copy_v3_v3 ( orig , vec [ tot ] ) ;
else
2012-03-25 23:19:21 +00:00
axis_track = track ;
2011-11-07 12:55:18 +00:00
tot + + ;
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
sub_v3_v3 ( vec [ 1 ] , vec [ 0 ] ) ;
sub_v3_v3 ( vec [ 2 ] , vec [ 0 ] ) ;
/* construct ortho-normal basis */
unit_m4 ( mat ) ;
2012-03-06 12:27:42 +00:00
if ( plane = = 0 ) { /* floor */
cross_v3_v3v3 ( mat [ 0 ] , vec [ 1 ] , vec [ 2 ] ) ;
copy_v3_v3 ( mat [ 1 ] , vec [ 1 ] ) ;
cross_v3_v3v3 ( mat [ 2 ] , mat [ 0 ] , mat [ 1 ] ) ;
}
else if ( plane = = 1 ) { /* wall */
cross_v3_v3v3 ( mat [ 2 ] , vec [ 1 ] , vec [ 2 ] ) ;
copy_v3_v3 ( mat [ 1 ] , vec [ 1 ] ) ;
cross_v3_v3v3 ( mat [ 0 ] , mat [ 1 ] , mat [ 2 ] ) ;
}
2011-11-07 12:55:18 +00:00
normalize_v3 ( mat [ 0 ] ) ;
normalize_v3 ( mat [ 1 ] ) ;
normalize_v3 ( mat [ 2 ] ) ;
/* move to origin point */
2012-03-25 23:19:21 +00:00
mat [ 3 ] [ 0 ] = orig [ 0 ] ;
mat [ 3 ] [ 1 ] = orig [ 1 ] ;
mat [ 3 ] [ 2 ] = orig [ 2 ] ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) {
2011-12-05 18:57:17 +00:00
invert_m4 ( mat ) ;
2011-11-07 12:55:18 +00:00
2012-05-05 14:03:12 +00:00
BKE_object_to_mat4 ( object , obmat ) ;
2013-05-26 18:36:25 +00:00
mul_m4_m4m4 ( mat , mat , obmat ) ;
mul_m4_m4m4 ( newmat , rot , mat ) ;
2012-05-05 14:03:12 +00:00
BKE_object_apply_mat4 ( object , newmat , 0 , 0 ) ;
2011-12-05 18:57:17 +00:00
/* make camera have positive z-coordinate */
2012-05-07 08:53:59 +00:00
if ( object - > loc [ 2 ] < 0 ) {
2011-12-30 18:06:02 +00:00
invert_m4 ( rot ) ;
2013-05-26 18:36:25 +00:00
mul_m4_m4m4 ( newmat , rot , mat ) ;
2012-05-05 14:03:12 +00:00
BKE_object_apply_mat4 ( object , newmat , 0 , 0 ) ;
2011-12-05 18:57:17 +00:00
}
}
else {
2012-05-05 14:03:12 +00:00
BKE_object_apply_mat4 ( object , mat , 0 , 0 ) ;
2011-11-07 12:55:18 +00:00
}
2012-05-05 14:03:12 +00:00
BKE_object_where_is_calc ( scene , object ) ;
2011-12-21 14:51:01 +00:00
set_axis ( scene , object , clip , tracking_object , axis_track , ' X ' ) ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2011-12-05 18:57:17 +00:00
DAG_id_tag_update ( & object - > id , OB_RECALC_OB ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
2012-03-06 12:27:42 +00:00
void CLIP_OT_set_plane ( wmOperatorType * ot )
2011-11-07 12:55:18 +00:00
{
2012-03-06 12:27:42 +00:00
static EnumPropertyItem plane_items [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " FLOOR " , 0 , " Floor " , " Set floor plane " } ,
{ 1 , " WALL " , 0 , " Wall " , " Set wall plane " } ,
{ 0 , NULL , 0 , NULL , NULL }
2012-03-06 12:27:42 +00:00
} ;
2011-11-07 12:55:18 +00:00
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Plane " ;
2014-02-12 15:32:06 +01:00
ot - > description = " Set plane based on 3 selected bundles by moving camera (or its parent if present) in 3D space " ;
2012-03-22 07:26:09 +00:00
ot - > idname = " CLIP_OT_set_plane " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_plane_exec ;
ot - > poll = set_orientation_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2012-03-06 12:27:42 +00:00
/* properties */
2012-04-14 15:44:31 +00:00
RNA_def_enum ( ot - > srna , " plane " , plane_items , 0 , " Plane " , " Plane to be used for orientation " ) ;
2011-11-07 12:55:18 +00:00
}
/********************** set axis operator *********************/
static int set_axis_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
2011-12-05 18:57:17 +00:00
Object * object ;
ListBase * tracksbase ;
2012-03-25 23:19:21 +00:00
int axis = RNA_enum_get ( op - > ptr , " axis " ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
if ( count_selected_bundles ( C ) ! = 1 ) {
2011-11-07 12:55:18 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Single track with bundle should be selected to define axis " ) ;
return OPERATOR_CANCELLED ;
}
2012-03-25 23:19:21 +00:00
object = get_orientation_object ( C ) ;
2012-03-24 06:38:07 +00:00
if ( ! object ) {
2011-12-21 14:51:01 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No object to apply orientation on " ) ;
2011-11-07 12:55:18 +00:00
2011-12-21 14:51:01 +00:00
return OPERATOR_CANCELLED ;
}
2011-12-05 18:57:17 +00:00
2012-06-15 11:03:23 +00:00
tracksbase = BKE_tracking_object_get_tracks ( tracking , tracking_object ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2013-09-23 08:04:55 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_HAS_BUNDLE ) )
2011-11-07 12:55:18 +00:00
break ;
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
set_axis ( scene , object , clip , tracking_object , track , axis = = 0 ? ' X ' : ' Y ' ) ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2011-12-05 18:57:17 +00:00
DAG_id_tag_update ( & object - > id , OB_RECALC_OB ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_set_axis ( wmOperatorType * ot )
{
static EnumPropertyItem axis_actions [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " X " , 0 , " X " , " Align bundle align X axis " } ,
{ 1 , " Y " , 0 , " Y " , " Align bundle align Y axis " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Axis " ;
2014-02-12 15:32:06 +01:00
ot - > description = " Set direction of scene axis rotating camera (or its parent if present) and assume selected track lies on real axis, joining it with the origin " ;
2012-03-22 07:26:09 +00:00
ot - > idname = " CLIP_OT_set_axis " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_axis_exec ;
ot - > poll = set_orientation_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_enum ( ot - > srna , " axis " , axis_actions , 0 , " Axis " , " Axis to use to align bundle along " ) ;
}
/********************** set scale operator *********************/
2013-05-09 16:38:55 +00:00
static int do_set_scale ( bContext * C , wmOperator * op , bool scale_solution , bool apply_scale )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
Object * object = NULL ;
Object * camera = get_camera_with_movieclip ( scene , clip ) ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
int tot = 0 ;
2011-11-07 12:55:18 +00:00
float vec [ 2 ] [ 3 ] , mat [ 4 ] [ 4 ] , scale ;
2012-03-25 23:19:21 +00:00
float dist = RNA_float_get ( op - > ptr , " distance " ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( count_selected_bundles ( C ) ! = 2 ) {
2011-12-19 15:12:33 +00:00
BKE_report ( op - > reports , RPT_ERROR , " Two tracks with bundles should be selected to set scale " ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
}
2013-05-09 16:38:55 +00:00
if ( ! scale_solution & & ! apply_scale ) {
2013-05-09 16:38:50 +00:00
object = get_orientation_object ( C ) ;
if ( ! object ) {
BKE_report ( op - > reports , RPT_ERROR , " No object to apply orientation on " ) ;
2011-12-18 18:31:02 +00:00
2013-05-09 16:38:50 +00:00
return OPERATOR_CANCELLED ;
}
2011-12-21 14:51:01 +00:00
}
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_get_camera_object_matrix ( scene , camera , mat ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
2011-11-07 12:55:18 +00:00
mul_v3_m4v3 ( vec [ tot ] , mat , track - > bundle_pos ) ;
tot + + ;
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
sub_v3_v3 ( vec [ 0 ] , vec [ 1 ] ) ;
2012-05-07 08:53:59 +00:00
if ( len_v3 ( vec [ 0 ] ) > 1e-5 f ) {
2012-03-25 23:19:21 +00:00
scale = dist / len_v3 ( vec [ 0 ] ) ;
2011-11-07 12:55:18 +00:00
2013-05-09 16:38:55 +00:00
if ( apply_scale ) {
/* Apply scale on reconstructed scene itself */
MovieTrackingReconstruction * reconstruction = BKE_tracking_get_active_reconstruction ( tracking ) ;
MovieReconstructedCamera * reconstructed_cameras ;
int i ;
2011-12-21 14:51:01 +00:00
2013-05-09 16:38:55 +00:00
for ( track = tracksbase - > first ; track ; track = track - > next ) {
mul_v3_fl ( track - > bundle_pos , scale ) ;
}
2011-12-18 18:31:02 +00:00
2013-05-09 16:38:55 +00:00
reconstructed_cameras = reconstruction - > cameras ;
for ( i = 0 ; i < reconstruction - > camnr ; i + + ) {
mul_v3_fl ( reconstructed_cameras [ i ] . mat [ 3 ] , scale ) ;
2011-12-18 18:31:02 +00:00
}
2013-05-09 16:38:55 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
2011-12-18 18:31:02 +00:00
}
2011-12-19 15:12:33 +00:00
else {
2013-05-09 16:38:55 +00:00
if ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) {
mul_v3_fl ( object - > size , scale ) ;
mul_v3_fl ( object - > loc , scale ) ;
}
else if ( ! scale_solution ) {
Object * solver_camera = object_solver_camera ( scene , object ) ;
object - > size [ 0 ] = object - > size [ 1 ] = object - > size [ 2 ] = 1.0f / scale ;
2011-11-07 12:55:18 +00:00
2013-05-09 16:38:55 +00:00
if ( solver_camera ) {
object - > size [ 0 ] / = solver_camera - > size [ 0 ] ;
object - > size [ 1 ] / = solver_camera - > size [ 1 ] ;
object - > size [ 2 ] / = solver_camera - > size [ 2 ] ;
}
}
else {
tracking_object - > scale = scale ;
}
2011-12-19 15:12:33 +00:00
2013-05-09 16:38:55 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2011-11-07 12:55:18 +00:00
2013-05-09 16:38:55 +00:00
if ( object )
DAG_id_tag_update ( & object - > id , OB_RECALC_OB ) ;
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
WM_event_add_notifier ( C , NC_OBJECT | ND_TRANSFORM , NULL ) ;
}
2011-11-07 12:55:18 +00:00
}
return OPERATOR_FINISHED ;
}
2011-12-19 15:12:33 +00:00
static int set_scale_exec ( bContext * C , wmOperator * op )
{
2013-05-09 16:38:55 +00:00
return do_set_scale ( C , op , false , false ) ;
2011-12-19 15:12:33 +00:00
}
2013-03-13 09:03:46 +00:00
static int set_scale_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " distance " ) )
2011-11-07 12:55:18 +00:00
RNA_float_set ( op - > ptr , " distance " , clip - > tracking . settings . dist ) ;
return set_scale_exec ( C , op ) ;
}
void CLIP_OT_set_scale ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Scale " ;
2014-02-12 15:32:06 +01:00
ot - > description = " Set scale of scene by scaling camera (or its parent if present) " ;
2012-03-22 07:26:09 +00:00
ot - > idname = " CLIP_OT_set_scale " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_scale_exec ;
ot - > invoke = set_scale_invoke ;
ot - > poll = set_orientation_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_float ( ot - > srna , " distance " , 0.0f , - FLT_MAX , FLT_MAX ,
2012-06-10 19:59:02 +00:00
" Distance " , " Distance between selected tracks " , - 100.0f , 100.0f ) ;
2011-11-07 12:55:18 +00:00
}
2011-12-19 15:12:33 +00:00
/********************** set solution scale operator *********************/
static int set_solution_scale_poll ( bContext * C )
{
2012-06-07 16:36:19 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2011-12-19 15:12:33 +00:00
2012-06-08 08:24:08 +00:00
if ( sc ) {
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-06-08 08:24:08 +00:00
2012-06-10 09:04:49 +00:00
if ( clip ) {
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
2012-06-10 09:04:49 +00:00
return ( tracking_object - > flag & TRACKING_OBJECT_CAMERA ) = = 0 ;
}
2012-06-08 08:24:08 +00:00
}
2014-04-01 11:34:00 +11:00
return false ;
2011-12-19 15:12:33 +00:00
}
static int set_solution_scale_exec ( bContext * C , wmOperator * op )
{
2013-05-09 16:38:55 +00:00
return do_set_scale ( C , op , true , false ) ;
2011-12-19 15:12:33 +00:00
}
2013-03-13 09:03:46 +00:00
static int set_solution_scale_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2011-12-19 15:12:33 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-12-19 15:12:33 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " distance " ) )
2011-12-19 15:12:33 +00:00
RNA_float_set ( op - > ptr , " distance " , clip - > tracking . settings . object_distance ) ;
return set_solution_scale_exec ( C , op ) ;
}
void CLIP_OT_set_solution_scale ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Solution Scale " ;
ot - > description = " Set object solution scale using distance between two selected tracks " ;
ot - > idname = " CLIP_OT_set_solution_scale " ;
2011-12-19 15:12:33 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_solution_scale_exec ;
ot - > invoke = set_solution_scale_invoke ;
ot - > poll = set_solution_scale_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_float ( ot - > srna , " distance " , 0.0f , - FLT_MAX , FLT_MAX ,
2012-06-10 19:59:02 +00:00
" Distance " , " Distance between selected tracks " , - 100.0f , 100.0f ) ;
2011-11-07 12:55:18 +00:00
}
2013-05-09 16:38:55 +00:00
/********************** apply solution scale operator *********************/
static int apply_solution_scale_poll ( bContext * C )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
if ( sc ) {
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
if ( clip ) {
MovieTracking * tracking = & clip - > tracking ;
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( tracking ) ;
return tracking_object - > flag & TRACKING_OBJECT_CAMERA ;
}
}
2014-04-01 11:34:00 +11:00
return false ;
2013-05-09 16:38:55 +00:00
}
static int apply_solution_scale_exec ( bContext * C , wmOperator * op )
{
return do_set_scale ( C , op , false , true ) ;
}
static int apply_solution_scale_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
if ( ! RNA_struct_property_is_set ( op - > ptr , " distance " ) )
RNA_float_set ( op - > ptr , " distance " , clip - > tracking . settings . dist ) ;
return apply_solution_scale_exec ( C , op ) ;
}
void CLIP_OT_apply_solution_scale ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Apply Solution Scale " ;
ot - > description = " Apply scale on solution itself to make distance between selected tracks equals to desired " ;
ot - > idname = " CLIP_OT_apply_solution_scale " ;
/* api callbacks */
ot - > exec = apply_solution_scale_exec ;
ot - > invoke = apply_solution_scale_invoke ;
ot - > poll = apply_solution_scale_poll ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
RNA_def_float ( ot - > srna , " distance " , 0.0f , - FLT_MAX , FLT_MAX ,
" Distance " , " Distance between selected tracks " , - 100.0f , 100.0f ) ;
}
2011-11-07 12:55:18 +00:00
/********************** set principal center operator *********************/
static int set_center_principal_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
int width , height ;
BKE_movieclip_get_size ( clip , & sc - > user , & width , & height ) ;
2012-03-25 23:19:21 +00:00
if ( width = = 0 | | height = = 0 )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2012-05-07 08:53:59 +00:00
clip - > tracking . camera . principal [ 0 ] = ( ( float ) width ) / 2.0f ;
clip - > tracking . camera . principal [ 1 ] = ( ( float ) height ) / 2.0f ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_set_center_principal ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Principal to Center " ;
ot - > description = " Set optical center to center of footage " ;
ot - > idname = " CLIP_OT_set_center_principal " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = set_center_principal_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** hide tracks operator *********************/
static int hide_tracks_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2014-03-06 20:07:14 +06:00
MovieTrackingPlaneTrack * plane_track ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2014-03-06 20:07:14 +06:00
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
2012-06-15 11:03:23 +00:00
MovieTrackingTrack * act_track = BKE_tracking_track_get_active ( tracking ) ;
2014-03-06 20:07:14 +06:00
MovieTrackingPlaneTrack * act_plane_track = BKE_tracking_plane_track_get_active ( & clip - > tracking ) ;
2011-11-07 12:55:18 +00:00
int unselected ;
2012-03-25 23:19:21 +00:00
unselected = RNA_boolean_get ( op - > ptr , " unselected " ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( unselected = = 0 & & TRACK_VIEW_SELECTED ( sc , track ) ) {
track - > flag | = TRACK_HIDDEN ;
2012-03-24 06:38:07 +00:00
}
2012-03-25 23:19:21 +00:00
else if ( unselected = = 1 & & ! TRACK_VIEW_SELECTED ( sc , track ) ) {
track - > flag | = TRACK_HIDDEN ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
if ( act_track & & act_track - > flag & TRACK_HIDDEN )
clip - > tracking . act_track = NULL ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( unselected = = 0 ) {
2011-11-07 12:55:18 +00:00
/* no selection on screen now, unlock view so it can be scrolled nice again */
2012-03-25 23:19:21 +00:00
sc - > flag & = ~ SC_LOCK_SELECTION ;
2011-11-07 12:55:18 +00:00
}
2014-03-06 20:07:14 +06:00
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = plane_track - > next )
{
if ( unselected = = 0 & & plane_track - > flag & SELECT ) {
plane_track - > flag | = PLANE_TRACK_HIDDEN ;
}
else if ( unselected = = 1 & & ( plane_track - > flag & SELECT ) = = 0 ) {
plane_track - > flag | = PLANE_TRACK_HIDDEN ;
}
}
if ( act_plane_track & & act_plane_track - > flag & TRACK_HIDDEN ) {
clip - > tracking . act_plane_track = NULL ;
}
2012-05-03 23:15:01 +00:00
BKE_tracking_dopesheet_tag_update ( tracking ) ;
2012-04-30 16:19:20 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_hide_tracks ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Hide Tracks " ;
ot - > description = " Hide selected tracks " ;
ot - > idname = " CLIP_OT_hide_tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = hide_tracks_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_boolean ( ot - > srna , " unselected " , 0 , " Unselected " , " Hide unselected tracks " ) ;
}
/********************** hide tracks clear operator *********************/
static int hide_tracks_clear_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-05-03 23:15:01 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2014-03-06 20:07:14 +06:00
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2014-03-06 20:07:14 +06:00
MovieTrackingPlaneTrack * plane_track ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
track - > flag & = ~ TRACK_HIDDEN ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2014-03-06 20:07:14 +06:00
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = plane_track - > next )
{
plane_track - > flag & = ~ PLANE_TRACK_HIDDEN ;
}
2012-05-03 23:15:01 +00:00
BKE_tracking_dopesheet_tag_update ( tracking ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_hide_tracks_clear ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Hide Tracks Clear " ;
ot - > description = " Clear hide selected tracks " ;
ot - > idname = " CLIP_OT_hide_tracks_clear " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = hide_tracks_clear_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** detect features operator *********************/
static bGPDlayer * detect_get_layer ( MovieClip * clip )
{
bGPDlayer * layer ;
2012-03-24 06:38:07 +00:00
if ( ! clip - > gpd )
2011-11-07 12:55:18 +00:00
return NULL ;
2012-03-25 23:19:21 +00:00
layer = clip - > gpd - > layers . first ;
2012-03-24 06:38:07 +00:00
while ( layer ) {
2012-03-25 23:19:21 +00:00
if ( layer - > flag & GP_LAYER_ACTIVE )
2011-11-07 12:55:18 +00:00
return layer ;
2012-03-25 23:19:21 +00:00
layer = layer - > next ;
2011-11-07 12:55:18 +00:00
}
return NULL ;
}
static int detect_features_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
int clip_flag = clip - > flag & MCLIP_TIMECODE_FLAGS ;
ImBuf * ibuf = BKE_movieclip_get_ibuf_flag ( clip , & sc - > user , clip_flag , MOVIECLIP_CACHE_SKIP ) ;
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first ;
int placement = RNA_enum_get ( op - > ptr , " placement " ) ;
int margin = RNA_int_get ( op - > ptr , " margin " ) ;
int min_distance = RNA_int_get ( op - > ptr , " min_distance " ) ;
2013-10-08 19:53:59 +06:00
float threshold = RNA_float_get ( op - > ptr , " threshold " ) ;
2012-03-25 23:19:21 +00:00
int place_outside_layer = 0 ;
2012-06-19 14:26:29 +00:00
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-03-25 23:19:21 +00:00
bGPDlayer * layer = NULL ;
2012-06-07 16:36:19 +00:00
if ( ! ibuf ) {
BKE_report ( op - > reports , RPT_ERROR , " Feature detection requires valid clip frame " ) ;
return OPERATOR_CANCELLED ;
}
2012-03-25 23:19:21 +00:00
if ( placement ! = 0 ) {
layer = detect_get_layer ( clip ) ;
place_outside_layer = placement = = 2 ;
2011-11-07 12:55:18 +00:00
}
/* deselect existing tracks */
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
track - > flag & = ~ SELECT ;
track - > pat_flag & = ~ SELECT ;
track - > search_flag & = ~ SELECT ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2013-10-08 19:53:59 +06:00
BKE_tracking_detect_harris ( tracking , tracksbase , ibuf , framenr , margin ,
threshold / 100000.0f , min_distance , layer , place_outside_layer ) ;
2011-11-07 12:55:18 +00:00
IMB_freeImBuf ( ibuf ) ;
2012-06-24 18:00:14 +00:00
BKE_tracking_dopesheet_tag_update ( tracking ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_detect_features ( wmOperatorType * ot )
{
static EnumPropertyItem placement_items [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " FRAME " , 0 , " Whole Frame " , " Place markers across the whole frame " } ,
{ 1 , " INSIDE_GPENCIL " , 0 , " Inside grease pencil " , " Place markers only inside areas outlined with grease pencil " } ,
{ 2 , " OUTSIDE_GPENCIL " , 0 , " Outside grease pencil " , " Place markers only outside areas outlined with grease pencil " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Detect Features " ;
ot - > description = " Automatically detect features and place markers to track " ;
ot - > idname = " CLIP_OT_detect_features " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = detect_features_exec ;
2012-06-07 16:36:19 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_enum ( ot - > srna , " placement " , placement_items , 0 , " Placement " , " Placement for detected features " ) ;
2013-10-08 19:53:59 +06:00
RNA_def_int ( ot - > srna , " margin " , 16 , 0 , INT_MAX , " Margin " , " Only features further than margin pixels from the image edges are considered " , 0 , 300 ) ;
RNA_def_float ( ot - > srna , " threshold " , 1.0f , 0.0001f , FLT_MAX , " Threshold " , " Threshold level to consider feature good enough for tracking " , 0.0001f , FLT_MAX ) ;
RNA_def_int ( ot - > srna , " min_distance " , 120 , 0 , INT_MAX , " Distance " , " Minimal distance accepted between two features " , 0 , 300 ) ;
2011-11-07 12:55:18 +00:00
}
/********************** frame jump operator *********************/
static int frame_jump_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
Scene * scene = CTX_data_scene ( C ) ;
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
int pos = RNA_enum_get ( op - > ptr , " position " ) ;
2011-11-07 12:55:18 +00:00
int delta ;
2012-06-10 19:59:02 +00:00
if ( pos < = 1 ) { /* jump to path */
2012-06-15 11:03:23 +00:00
track = BKE_tracking_track_get_active ( & clip - > tracking ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! track )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2012-03-25 23:19:21 +00:00
delta = pos = = 1 ? 1 : - 1 ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
while ( sc - > user . framenr + delta > = SFRA & & sc - > user . framenr + delta < = EFRA ) {
2012-06-06 18:58:30 +00:00
int framenr = BKE_movieclip_remap_scene_to_clip_frame ( clip , sc - > user . framenr + delta ) ;
2012-06-15 11:03:23 +00:00
MovieTrackingMarker * marker = BKE_tracking_marker_get_exact ( track , framenr ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( ! marker | | marker - > flag & MARKER_DISABLED )
2011-11-07 12:55:18 +00:00
break ;
2012-03-25 23:19:21 +00:00
sc - > user . framenr + = delta ;
2011-11-07 12:55:18 +00:00
}
}
2012-06-10 19:59:02 +00:00
else { /* to to failed frame */
2012-03-25 23:19:21 +00:00
if ( clip - > tracking . reconstruction . flag & TRACKING_RECONSTRUCTED ) {
2012-06-19 14:26:29 +00:00
int a = ED_space_clip_get_clip_frame_number ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * object = BKE_tracking_object_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
delta = pos = = 3 ? 1 : - 1 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
a + = delta ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
while ( a + delta > = SFRA & & a + delta < = EFRA ) {
2011-12-05 18:57:17 +00:00
MovieReconstructedCamera * cam ;
2012-06-15 11:03:23 +00:00
cam = BKE_tracking_camera_get_reconstructed ( tracking , object , a ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! cam ) {
2012-06-06 18:58:30 +00:00
sc - > user . framenr = BKE_movieclip_remap_clip_to_scene_frame ( clip , a ) ;
2011-11-07 12:55:18 +00:00
break ;
}
2012-03-25 23:19:21 +00:00
a + = delta ;
2011-11-07 12:55:18 +00:00
}
}
}
2012-03-25 23:19:21 +00:00
if ( CFRA ! = sc - > user . framenr ) {
CFRA = sc - > user . framenr ;
2011-11-07 12:55:18 +00:00
sound_seek_scene ( CTX_data_main ( C ) , CTX_data_scene ( C ) ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_SCENE | ND_FRAME , scene ) ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , NULL ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_frame_jump ( wmOperatorType * ot )
{
static EnumPropertyItem position_items [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " PATHSTART " , 0 , " Path Start " , " Jump to start of current path " } ,
{ 1 , " PATHEND " , 0 , " Path End " , " Jump to end of current path " } ,
{ 2 , " FAILEDPREV " , 0 , " Previous Failed " , " Jump to previous failed frame " } ,
{ 2 , " FAILNEXT " , 0 , " Next Failed " , " Jump to next failed frame " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Jump to Frame " ;
ot - > description = " Jump to special frame " ;
ot - > idname = " CLIP_OT_frame_jump " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = frame_jump_exec ;
2013-04-04 16:05:02 +00:00
ot - > poll = ED_space_clip_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
2012-03-17 14:27:46 +00:00
RNA_def_enum ( ot - > srna , " position " , position_items , 0 , " Position " , " Position to jump to " ) ;
2011-11-07 12:55:18 +00:00
}
/********************** join tracks operator *********************/
static int join_tracks_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * act_track , * track , * next ;
2012-06-15 11:03:23 +00:00
act_track = BKE_tracking_track_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! act_track ) {
2011-11-07 12:55:18 +00:00
BKE_report ( op - > reports , RPT_ERROR , " No active track to join to " ) ;
return OPERATOR_CANCELLED ;
}
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
next = track - > next ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & track ! = act_track ) {
2012-10-15 10:43:10 +00:00
BKE_tracking_tracks_join ( tracking , act_track , track ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( tracking - > stabilization . rot_track = = track )
2012-03-25 23:19:21 +00:00
tracking - > stabilization . rot_track = act_track ;
2012-03-09 10:01:29 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_track_free ( track ) ;
2011-12-05 18:57:17 +00:00
BLI_freelinkN ( tracksbase , track ) ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = next ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_join_tracks ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Join Tracks " ;
ot - > description = " Join selected tracks " ;
ot - > idname = " CLIP_OT_join_tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = join_tracks_exec ;
2012-06-07 16:36:19 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** lock tracks operator *********************/
static int lock_tracks_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2012-03-25 23:19:21 +00:00
MovieTrackingTrack * track = tracksbase - > first ;
int action = RNA_enum_get ( op - > ptr , " action " ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
while ( track ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
2012-03-25 23:19:21 +00:00
if ( action = = 0 )
track - > flag | = TRACK_LOCKED ;
else if ( action = = 1 )
track - > flag & = ~ TRACK_LOCKED ;
else track - > flag ^ = TRACK_LOCKED ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EVALUATED , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_lock_tracks ( wmOperatorType * ot )
{
static EnumPropertyItem actions_items [ ] = {
2012-06-10 19:59:02 +00:00
{ 0 , " LOCK " , 0 , " Lock " , " Lock selected tracks " } ,
{ 1 , " UNLOCK " , 0 , " Unlock " , " Unlock selected tracks " } ,
{ 2 , " TOGGLE " , 0 , " Toggle " , " Toggle locked flag for selected tracks " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Lock Tracks " ;
ot - > description = " Lock/unlock selected tracks " ;
ot - > idname = " CLIP_OT_lock_tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = lock_tracks_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
RNA_def_enum ( ot - > srna , " action " , actions_items , 0 , " Action " , " Lock action to execute " ) ;
}
2012-07-26 09:50:27 +00:00
/********************** set keyframe operator *********************/
static int set_solver_keyframe_exec ( bContext * C , wmOperator * op )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTracking * tracking = & clip - > tracking ;
2012-10-09 10:33:18 +00:00
MovieTrackingObject * object = BKE_tracking_object_get_active ( tracking ) ;
2012-07-26 09:50:27 +00:00
int keyframe = RNA_enum_get ( op - > ptr , " keyframe " ) ;
int framenr = BKE_movieclip_remap_scene_to_clip_frame ( clip , sc - > user . framenr ) ;
if ( keyframe = = 0 )
2012-10-09 10:33:18 +00:00
object - > keyframe1 = framenr ;
2012-07-26 09:50:27 +00:00
else
2012-10-09 10:33:18 +00:00
object - > keyframe2 = framenr ;
2012-07-26 09:50:27 +00:00
2012-07-27 13:49:26 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , clip ) ;
2012-07-26 09:50:27 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_set_solver_keyframe ( wmOperatorType * ot )
{
static EnumPropertyItem keyframe_items [ ] = {
{ 0 , " KEYFRAME_A " , 0 , " Keyframe A " , " " } ,
{ 1 , " KEYFRAME_B " , 0 , " Keyframe B " , " " } ,
{ 0 , NULL , 0 , NULL , NULL }
} ;
/* identifiers */
2012-07-26 10:06:08 +00:00
ot - > name = " Set Solver Keyframe " ;
2012-07-26 09:50:27 +00:00
ot - > description = " Set keyframe used by solver " ;
ot - > idname = " CLIP_OT_set_solver_keyframe " ;
/* api callbacks */
ot - > exec = set_solver_keyframe_exec ;
ot - > poll = ED_space_clip_tracking_poll ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
/* properties */
2013-02-28 15:31:20 +00:00
RNA_def_enum ( ot - > srna , " keyframe " , keyframe_items , 0 , " Keyframe " , " Keyframe to set " ) ;
2012-07-26 09:50:27 +00:00
}
2011-11-07 12:55:18 +00:00
/********************** track copy color operator *********************/
static int track_copy_color_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
MovieTrackingTrack * track , * act_track = BKE_tracking_track_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! act_track )
2011-11-07 12:55:18 +00:00
return OPERATOR_CANCELLED ;
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & track ! = act_track ) {
track - > flag & = ~ TRACK_CUSTOMCOLOR ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( act_track - > flag & TRACK_CUSTOMCOLOR ) {
2011-11-07 12:55:18 +00:00
copy_v3_v3 ( track - > color , act_track - > color ) ;
2012-03-25 23:19:21 +00:00
track - > flag | = TRACK_CUSTOMCOLOR ;
2011-11-07 12:55:18 +00:00
}
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_track_copy_color ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Copy Color " ;
ot - > description = " Copy color to all selected tracks " ;
ot - > idname = " CLIP_OT_track_copy_color " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = track_copy_color_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** add 2d stabilization tracks operator *********************/
2012-11-07 11:41:08 +00:00
static int stabilize_2d_poll ( bContext * C )
{
if ( ED_space_clip_tracking_poll ( C ) ) {
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTrackingObject * tracking_object = BKE_tracking_object_get_active ( & clip - > tracking ) ;
return tracking_object - > flag & TRACKING_OBJECT_CAMERA ;
}
2014-04-01 11:34:00 +11:00
return false ;
2012-11-07 11:41:08 +00:00
}
2011-11-07 12:55:18 +00:00
static int stabilize_2d_add_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
MovieTrackingStabilization * stab = & tracking - > stabilization ;
int update = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-05-07 08:53:59 +00:00
if ( TRACK_VIEW_SELECTED ( sc , track ) & & ( track - > flag & TRACK_USE_2D_STAB ) = = 0 ) {
2012-03-25 23:19:21 +00:00
track - > flag | = TRACK_USE_2D_STAB ;
2011-11-07 12:55:18 +00:00
stab - > tot_track + + ;
2012-03-25 23:19:21 +00:00
update = 1 ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( update ) {
2012-03-25 23:19:21 +00:00
stab - > ok = 0 ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , clip ) ;
2011-11-07 12:55:18 +00:00
}
return OPERATOR_FINISHED ;
}
void CLIP_OT_stabilize_2d_add ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Add Stabilization Tracks " ;
ot - > description = " Add selected tracks to 2D stabilization tool " ;
ot - > idname = " CLIP_OT_stabilize_2d_add " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = stabilize_2d_add_exec ;
2012-11-07 11:41:08 +00:00
ot - > poll = stabilize_2d_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** remove 2d stabilization tracks operator *********************/
static int stabilize_2d_remove_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
MovieTrackingStabilization * stab = & tracking - > stabilization ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
int a = 0 , update = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( track - > flag & TRACK_USE_2D_STAB ) {
if ( a = = stab - > act_track ) {
track - > flag & = ~ TRACK_USE_2D_STAB ;
2011-11-07 12:55:18 +00:00
stab - > act_track - - ;
stab - > tot_track - - ;
2012-05-07 08:53:59 +00:00
if ( stab - > act_track < 0 )
2012-03-25 23:19:21 +00:00
stab - > act_track = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
update = 1 ;
2011-11-07 12:55:18 +00:00
break ;
}
a + + ;
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( update ) {
2012-03-25 23:19:21 +00:00
stab - > ok = 0 ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , clip ) ;
2011-11-07 12:55:18 +00:00
}
return OPERATOR_FINISHED ;
}
void CLIP_OT_stabilize_2d_remove ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Remove Stabilization Track " ;
ot - > description = " Remove selected track from stabilization " ;
ot - > idname = " CLIP_OT_stabilize_2d_remove " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = stabilize_2d_remove_exec ;
2012-11-07 11:41:08 +00:00
ot - > poll = stabilize_2d_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** select 2d stabilization tracks operator *********************/
static int stabilize_2d_select_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
2011-11-07 12:55:18 +00:00
MovieTrackingTrack * track ;
2012-03-25 23:19:21 +00:00
int update = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
if ( track - > flag & TRACK_USE_2D_STAB ) {
2012-06-15 11:03:23 +00:00
BKE_tracking_track_flag_set ( track , TRACK_AREA_ALL , SELECT ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
update = 1 ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
track = track - > next ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( update )
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_SELECT , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_stabilize_2d_select ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Select Stabilization Tracks " ;
2014-02-12 15:32:06 +01:00
ot - > description = " Select tracks which are used for stabilization " ;
2012-03-22 07:26:09 +00:00
ot - > idname = " CLIP_OT_stabilize_2d_select " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = stabilize_2d_select_exec ;
2012-11-07 11:41:08 +00:00
ot - > poll = stabilize_2d_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** set 2d stabilization rotation track operator *********************/
static int stabilize_2d_set_rotation_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingTrack * act_track = BKE_tracking_track_get_active ( tracking ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( act_track ) {
2012-03-25 23:19:21 +00:00
MovieTrackingStabilization * stab = & tracking - > stabilization ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
stab - > rot_track = act_track ;
stab - > ok = 0 ;
2011-11-07 12:55:18 +00:00
DAG_id_tag_update ( & clip - > id , 0 ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_DISPLAY , clip ) ;
2011-11-07 12:55:18 +00:00
}
return OPERATOR_FINISHED ;
}
void CLIP_OT_stabilize_2d_set_rotation ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Set Rotation Track " ;
ot - > description = " Use active track to compensate rotation when doing 2D stabilization " ;
ot - > idname = " CLIP_OT_stabilize_2d_set_rotation " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = stabilize_2d_set_rotation_exec ;
2012-11-07 11:41:08 +00:00
ot - > poll = stabilize_2d_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
}
/********************** clean tracks operator *********************/
2014-04-11 11:25:41 +10:00
static bool is_track_clean ( MovieTrackingTrack * track , int frames , int del )
2011-11-07 12:55:18 +00:00
{
2014-04-11 11:25:41 +10:00
bool ok = true ;
int a , prev = - 1 , count = 0 ;
2012-03-25 23:19:21 +00:00
MovieTrackingMarker * markers = track - > markers , * new_markers = NULL ;
int start_disabled = 0 ;
int markersnr = track - > markersnr ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( del )
2012-06-10 19:59:02 +00:00
new_markers = MEM_callocN ( markersnr * sizeof ( MovieTrackingMarker ) , " track cleaned markers " ) ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
for ( a = 0 ; a < markersnr ; a + + ) {
2012-03-25 23:19:21 +00:00
int end = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( prev = = - 1 ) {
2012-05-07 08:53:59 +00:00
if ( ( markers [ a ] . flag & MARKER_DISABLED ) = = 0 )
2012-03-25 23:19:21 +00:00
prev = a ;
2011-11-07 12:55:18 +00:00
else
2012-03-25 23:19:21 +00:00
start_disabled = 1 ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( prev > = 0 ) {
2012-05-07 08:53:59 +00:00
end = a = = markersnr - 1 ;
end | = ( a < markersnr - 1 ) & & ( markers [ a ] . framenr ! = markers [ a + 1 ] . framenr - 1 | |
markers [ a ] . flag & MARKER_DISABLED ) ;
2011-11-07 12:55:18 +00:00
}
2012-03-24 06:38:07 +00:00
if ( end ) {
2012-03-25 23:19:21 +00:00
int segok = 1 , len = 0 ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
if ( a ! = prev & & markers [ a ] . framenr ! = markers [ a - 1 ] . framenr + 1 )
len = a - prev ;
2012-03-25 23:19:21 +00:00
else if ( markers [ a ] . flag & MARKER_DISABLED )
2012-05-07 08:53:59 +00:00
len = a - prev ;
else len = a - prev + 1 ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( frames ) {
if ( len < frames ) {
2012-03-25 23:19:21 +00:00
segok = 0 ;
ok = 0 ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! del )
2011-11-07 12:55:18 +00:00
break ;
}
}
2012-03-24 06:38:07 +00:00
if ( del ) {
if ( segok ) {
2012-03-25 23:19:21 +00:00
int t = len ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( markers [ a ] . flag & MARKER_DISABLED )
2011-11-07 12:55:18 +00:00
t + + ;
/* place disabled marker in front of current segment */
2012-03-24 06:38:07 +00:00
if ( start_disabled ) {
2012-05-07 08:53:59 +00:00
memcpy ( new_markers + count , markers + prev , sizeof ( MovieTrackingMarker ) ) ;
2011-11-07 12:55:18 +00:00
new_markers [ count ] . framenr - - ;
2012-03-25 23:19:21 +00:00
new_markers [ count ] . flag | = MARKER_DISABLED ;
2011-11-07 12:55:18 +00:00
count + + ;
2012-03-25 23:19:21 +00:00
start_disabled = 0 ;
2011-11-07 12:55:18 +00:00
}
2012-05-07 08:53:59 +00:00
memcpy ( new_markers + count , markers + prev , t * sizeof ( MovieTrackingMarker ) ) ;
2012-03-25 23:19:21 +00:00
count + = t ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
else if ( markers [ a ] . flag & MARKER_DISABLED ) {
2011-11-07 12:55:18 +00:00
/* current segment which would be deleted was finished by disabled marker,
2012-03-03 16:31:46 +00:00
* so next segment should be started from disabled marker */
2012-03-25 23:19:21 +00:00
start_disabled = 1 ;
2011-11-07 12:55:18 +00:00
}
}
2012-03-25 23:19:21 +00:00
prev = - 1 ;
2011-11-07 12:55:18 +00:00
}
}
2012-03-24 06:38:07 +00:00
if ( del ) {
2011-11-07 12:55:18 +00:00
MEM_freeN ( track - > markers ) ;
2012-03-24 06:38:07 +00:00
if ( count ) {
2012-03-25 23:19:21 +00:00
track - > markers = new_markers ;
2011-11-07 12:55:18 +00:00
}
else {
2012-03-25 23:19:21 +00:00
track - > markers = NULL ;
2011-11-07 12:55:18 +00:00
MEM_freeN ( new_markers ) ;
}
2012-03-25 23:19:21 +00:00
track - > markersnr = count ;
2011-11-07 12:55:18 +00:00
}
return ok ;
}
static int clean_tracks_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
ListBase * tracksbase = BKE_tracking_get_active_tracks ( tracking ) ;
MovieTrackingTrack * track , * next , * act_track = BKE_tracking_track_get_active ( tracking ) ;
2012-03-25 23:19:21 +00:00
int frames = RNA_int_get ( op - > ptr , " frames " ) ;
int action = RNA_enum_get ( op - > ptr , " action " ) ;
float error = RNA_float_get ( op - > ptr , " error " ) ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
if ( error & & action = = TRACKING_CLEAN_DELETE_SEGMENT )
action = TRACKING_CLEAN_DELETE_TRACK ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
track = tracksbase - > first ;
2012-03-24 06:38:07 +00:00
while ( track ) {
2012-03-25 23:19:21 +00:00
next = track - > next ;
2011-11-07 12:55:18 +00:00
2012-05-07 08:53:59 +00:00
if ( ( track - > flag & TRACK_HIDDEN ) = = 0 & & ( track - > flag & TRACK_LOCKED ) = = 0 ) {
2013-03-17 10:26:23 +00:00
bool ok ;
2011-11-07 12:55:18 +00:00
2012-03-25 23:19:21 +00:00
ok = ( is_track_clean ( track , frames , action = = TRACKING_CLEAN_DELETE_SEGMENT ) ) & &
2012-06-10 19:59:02 +00:00
( error = = 0.0f | | ( track - > flag & TRACK_HAS_BUNDLE ) = = 0 | | track - > error < error ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! ok ) {
2012-03-25 23:19:21 +00:00
if ( action = = TRACKING_CLEAN_SELECT ) {
2012-06-15 11:03:23 +00:00
BKE_tracking_track_flag_set ( track , TRACK_AREA_ALL , SELECT ) ;
2011-11-07 12:55:18 +00:00
}
2012-03-25 23:19:21 +00:00
else if ( action = = TRACKING_CLEAN_DELETE_TRACK ) {
if ( track = = act_track )
clip - > tracking . act_track = NULL ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_track_free ( track ) ;
2011-12-05 18:57:17 +00:00
BLI_freelinkN ( tracksbase , track ) ;
2012-03-25 23:19:21 +00:00
track = NULL ;
2011-11-07 12:55:18 +00:00
}
/* happens when all tracking segments are not long enough */
2012-03-25 23:19:21 +00:00
if ( track & & track - > markersnr = = 0 ) {
if ( track = = act_track )
clip - > tracking . act_track = NULL ;
2011-11-07 12:55:18 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_track_free ( track ) ;
2011-12-05 18:57:17 +00:00
BLI_freelinkN ( tracksbase , track ) ;
2011-11-07 12:55:18 +00:00
}
}
}
2012-03-25 23:19:21 +00:00
track = next ;
2011-11-07 12:55:18 +00:00
}
2013-07-28 07:11:00 +00:00
BKE_tracking_dopesheet_tag_update ( tracking ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | ND_SELECT , clip ) ;
2011-11-07 12:55:18 +00:00
return OPERATOR_FINISHED ;
}
2013-03-13 09:03:46 +00:00
static int clean_tracks_invoke ( bContext * C , wmOperator * op , const wmEvent * UNUSED ( event ) )
2011-11-07 12:55:18 +00:00
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2011-11-07 12:55:18 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " frames " ) )
2011-11-07 12:55:18 +00:00
RNA_int_set ( op - > ptr , " frames " , clip - > tracking . settings . clean_frames ) ;
2012-02-02 19:37:50 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " error " ) )
2011-11-07 12:55:18 +00:00
RNA_float_set ( op - > ptr , " error " , clip - > tracking . settings . clean_error ) ;
2012-02-02 19:37:50 +00:00
2012-03-24 06:38:07 +00:00
if ( ! RNA_struct_property_is_set ( op - > ptr , " action " ) )
2011-11-07 12:55:18 +00:00
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 [ ] = {
2012-06-10 19:59:02 +00:00
{ TRACKING_CLEAN_SELECT , " SELECT " , 0 , " Select " , " Select unclean tracks " } ,
{ TRACKING_CLEAN_DELETE_TRACK , " DELETE_TRACK " , 0 , " Delete Track " , " Delete unclean tracks " } ,
{ TRACKING_CLEAN_DELETE_SEGMENT , " DELETE_SEGMENTS " , 0 , " Delete Segments " , " Delete unclean segments of tracks " } ,
{ 0 , NULL , 0 , NULL , NULL }
2011-11-07 12:55:18 +00:00
} ;
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Clean Tracks " ;
ot - > description = " Clean tracks with high error values or few frames " ;
ot - > idname = " CLIP_OT_clean_tracks " ;
2011-11-07 12:55:18 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = clean_tracks_exec ;
ot - > invoke = clean_tracks_invoke ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-11-07 12:55:18 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-11-07 12:55:18 +00:00
/* properties */
2012-04-14 15:44:31 +00:00
RNA_def_int ( ot - > srna , " frames " , 0 , 0 , INT_MAX , " Tracked Frames " ,
" Effect on tracks which are tracked less than specified amount of frames " , 0 , INT_MAX ) ;
RNA_def_float ( ot - > srna , " error " , 0.0f , 0.0f , FLT_MAX , " Reprojection Error " ,
" Effect on tracks which have got larger re-projection error " , 0.0f , 100.0f ) ;
2011-11-07 12:55:18 +00:00
RNA_def_enum ( ot - > srna , " action " , actions_items , 0 , " Action " , " Cleanup action to execute " ) ;
}
2011-12-05 18:57:17 +00:00
/********************** add tracking object *********************/
static int tracking_object_new_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2011-12-05 18:57:17 +00:00
2012-06-15 11:03:23 +00:00
BKE_tracking_object_add ( tracking , " Object " ) ;
2011-12-05 18:57:17 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-12-05 18:57:17 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_tracking_object_new ( wmOperatorType * ot )
{
/* identifiers */
2012-03-22 07:26:09 +00:00
ot - > name = " Add Tracking Object " ;
ot - > description = " Add new object for tracking " ;
ot - > idname = " CLIP_OT_tracking_object_new " ;
2011-12-05 18:57:17 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = tracking_object_new_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-12-05 18:57:17 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-12-05 18:57:17 +00:00
}
/********************** remove tracking object *********************/
static int tracking_object_remove_exec ( bContext * C , wmOperator * op )
{
2012-03-25 23:19:21 +00:00
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-03-25 23:19:21 +00:00
MovieTracking * tracking = & clip - > tracking ;
2011-12-05 18:57:17 +00:00
MovieTrackingObject * object ;
2012-06-15 11:03:23 +00:00
object = BKE_tracking_object_get_active ( tracking ) ;
2011-12-05 18:57:17 +00:00
2012-03-25 23:19:21 +00:00
if ( object - > flag & TRACKING_OBJECT_CAMERA ) {
2012-10-26 17:32:50 +00:00
BKE_report ( op - > reports , RPT_WARNING , " Object used for camera tracking cannot be deleted " ) ;
2011-12-05 18:57:17 +00:00
return OPERATOR_CANCELLED ;
}
2012-06-15 11:03:23 +00:00
BKE_tracking_object_delete ( tracking , object ) ;
2011-12-05 18:57:17 +00:00
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2011-12-05 18:57:17 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_tracking_object_remove ( wmOperatorType * ot )
{
/* identifiers */
2012-06-24 13:52:20 +00:00
ot - > name = " Remove Tracking Object " ;
2012-03-22 07:26:09 +00:00
ot - > description = " Remove object for tracking " ;
ot - > idname = " CLIP_OT_tracking_object_remove " ;
2011-12-05 18:57:17 +00:00
/* api callbacks */
2012-03-22 07:26:09 +00:00
ot - > exec = tracking_object_remove_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2011-12-05 18:57:17 +00:00
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2011-12-05 18:57:17 +00:00
}
2012-01-09 20:18:48 +00:00
/********************** copy tracks to clipboard operator *********************/
static int copy_tracks_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-01-09 20:18:48 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * object = BKE_tracking_object_get_active ( tracking ) ;
2012-01-09 20:18:48 +00:00
clear_invisible_track_selection ( sc , clip ) ;
BKE_tracking_clipboard_copy_tracks ( tracking , object ) ;
return OPERATOR_FINISHED ;
}
void CLIP_OT_copy_tracks ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Copy Tracks " ;
ot - > description = " Copy selected tracks to clipboard " ;
ot - > idname = " CLIP_OT_copy_tracks " ;
/* api callbacks */
ot - > exec = copy_tracks_exec ;
2012-04-29 12:32:26 +00:00
ot - > poll = ED_space_clip_tracking_poll ;
2012-01-09 20:18:48 +00:00
/* flags */
2012-03-22 07:26:09 +00:00
ot - > flag = OPTYPE_REGISTER ;
2012-01-09 20:18:48 +00:00
}
/********************** paste tracks from clipboard operator *********************/
static int paste_tracks_poll ( bContext * C )
{
2012-04-29 12:32:26 +00:00
if ( ED_space_clip_tracking_poll ( C ) ) {
2012-01-09 20:18:48 +00:00
return BKE_tracking_clipboard_has_tracks ( ) ;
}
return 0 ;
}
static int paste_tracks_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
2012-06-19 14:26:29 +00:00
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
2012-01-09 20:18:48 +00:00
MovieTracking * tracking = & clip - > tracking ;
2012-06-15 11:03:23 +00:00
MovieTrackingObject * object = BKE_tracking_object_get_active ( tracking ) ;
2012-01-09 20:18:48 +00:00
BKE_tracking_clipboard_paste_tracks ( tracking , object ) ;
2012-05-07 08:53:59 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2012-01-09 20:18:48 +00:00
return OPERATOR_FINISHED ;
}
void CLIP_OT_paste_tracks ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Paste Tracks " ;
ot - > description = " Paste tracks from clipboard " ;
ot - > idname = " CLIP_OT_paste_tracks " ;
/* api callbacks */
ot - > exec = paste_tracks_exec ;
ot - > poll = paste_tracks_poll ;
/* flags */
2012-05-07 08:53:59 +00:00
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
2012-01-09 20:18:48 +00:00
}
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
/********************** Create plane track operator *********************/
static int create_plane_track_tracks_exec ( bContext * C , wmOperator * op )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTracking * tracking = & clip - > tracking ;
MovieTrackingPlaneTrack * plane_track ;
ListBase * tracks_base = BKE_tracking_get_active_tracks ( tracking ) ;
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
plane_track = BKE_tracking_plane_track_add ( tracking , plane_tracks_base , tracks_base , framenr ) ;
if ( plane_track = = NULL ) {
BKE_report ( op - > reports , RPT_ERROR , " Need at least 4 selected point tracks to create a plane " ) ;
return OPERATOR_CANCELLED ;
}
else {
BKE_tracking_tracks_deselect_all ( tracks_base ) ;
plane_track - > flag | = SELECT ;
clip - > tracking . act_track = NULL ;
clip - > tracking . act_plane_track = plane_track ;
/* Copute homoraphies and apply them on marker's corner, so we've got
* quite nice motion from the very beginning .
*/
BKE_tracking_track_plane_from_existing_motion ( plane_track , framenr ) ;
}
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
return OPERATOR_FINISHED ;
}
void CLIP_OT_create_plane_track ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Create Plane Track " ;
ot - > description = " Create new plane track out of selected point tracks " ;
ot - > idname = " CLIP_OT_create_plane_track " ;
/* api callbacks */
ot - > exec = create_plane_track_tracks_exec ;
ot - > poll = ED_space_clip_tracking_poll ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
}
/********************** Slide plane marker corner operator *********************/
typedef struct SlidePlaneMarkerData {
2014-02-18 19:07:50 +06:00
int event_type ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
MovieTrackingPlaneTrack * plane_track ;
MovieTrackingPlaneMarker * plane_marker ;
int width , height ;
int corner_index ;
float * corner ;
int previous_mval [ 2 ] ;
float previous_corner [ 2 ] ;
float old_corner [ 2 ] ;
bool accurate ;
} SlidePlaneMarkerData ;
static bool mouse_on_plane_slide_zone ( SpaceClip * sc , float co [ 2 ] , float slide_zone [ 2 ] , int width , int height )
{
const float size = 12.0f ;
float dx , dy ;
dx = size / width / sc - > zoom ;
dy = size / height / sc - > zoom ;
return IN_RANGE_INCL ( co [ 0 ] , slide_zone [ 0 ] - dx , slide_zone [ 0 ] + dx ) & &
IN_RANGE_INCL ( co [ 1 ] , slide_zone [ 1 ] - dy , slide_zone [ 1 ] + dy ) ;
}
static MovieTrackingPlaneTrack * tracking_plane_marker_check_slide ( bContext * C , const wmEvent * event , int * corner_r )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTrackingPlaneTrack * plane_track ;
int width , height ;
float co [ 2 ] ;
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( & clip - > tracking ) ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
ED_space_clip_get_size ( sc , & width , & height ) ;
if ( width = = 0 | | height = = 0 ) {
return NULL ;
}
ED_clip_mouse_pos ( sc , ar , event - > mval , co ) ;
for ( plane_track = plane_tracks_base - > first ;
plane_track ;
plane_track = plane_track - > next )
{
2014-03-06 20:07:14 +06:00
if ( PLANE_TRACK_VIEW_SELECTED ( plane_track ) ) {
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
MovieTrackingPlaneMarker * plane_marker = BKE_tracking_plane_marker_get ( plane_track , framenr ) ;
bool ok = false ;
int i ;
for ( i = 0 ; i < 4 ; i + + ) {
if ( mouse_on_plane_slide_zone ( sc , co , plane_marker - > corners [ i ] , width , height ) ) {
if ( corner_r ) {
* corner_r = i ;
}
ok = true ;
break ;
}
}
if ( ok ) {
return plane_track ;
}
}
}
return NULL ;
}
static void * slide_plane_marker_customdata ( bContext * C , const wmEvent * event )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
ARegion * ar = CTX_wm_region ( C ) ;
MovieTrackingPlaneTrack * plane_track ;
int width , height ;
float co [ 2 ] ;
SlidePlaneMarkerData * customdata = NULL ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
int corner ;
ED_space_clip_get_size ( sc , & width , & height ) ;
if ( width = = 0 | | height = = 0 ) {
return NULL ;
}
ED_clip_mouse_pos ( sc , ar , event - > mval , co ) ;
plane_track = tracking_plane_marker_check_slide ( C , event , & corner ) ;
if ( plane_track ) {
MovieTrackingPlaneMarker * plane_marker ;
customdata = MEM_callocN ( sizeof ( SlidePlaneMarkerData ) , " slide plane marker data " ) ;
2014-02-18 19:07:50 +06:00
customdata - > event_type = event - > type ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
plane_marker = BKE_tracking_plane_marker_ensure ( plane_track , framenr ) ;
customdata - > plane_track = plane_track ;
customdata - > plane_marker = plane_marker ;
customdata - > width = width ;
customdata - > height = height ;
customdata - > previous_mval [ 0 ] = event - > mval [ 0 ] ;
customdata - > previous_mval [ 1 ] = event - > mval [ 1 ] ;
customdata - > corner_index = corner ;
customdata - > corner = plane_marker - > corners [ corner ] ;
copy_v2_v2 ( customdata - > previous_corner , customdata - > corner ) ;
copy_v2_v2 ( customdata - > old_corner , customdata - > corner ) ;
}
return customdata ;
}
static int slide_plane_marker_invoke ( bContext * C , wmOperator * op , const wmEvent * event )
{
SlidePlaneMarkerData * slidedata = slide_plane_marker_customdata ( C , event ) ;
if ( slidedata ) {
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTracking * tracking = & clip - > tracking ;
tracking - > act_plane_track = slidedata - > plane_track ;
tracking - > act_track = NULL ;
op - > customdata = slidedata ;
hide_cursor ( C ) ;
WM_event_add_modal_handler ( C , op ) ;
WM_event_add_notifier ( C , NC_GEOM | ND_SELECT , NULL ) ;
return OPERATOR_RUNNING_MODAL ;
}
return OPERATOR_PASS_THROUGH ;
}
static void cancel_mouse_slide_plane_marker ( SlidePlaneMarkerData * data )
{
copy_v2_v2 ( data - > corner , data - > old_corner ) ;
}
static void free_slide_plane_marker_data ( SlidePlaneMarkerData * data )
{
MEM_freeN ( data ) ;
}
static void slide_plane_marker_update_homographies ( SpaceClip * sc , SlidePlaneMarkerData * data )
{
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
BKE_tracking_track_plane_from_existing_motion ( data - > plane_track , framenr ) ;
}
static int slide_plane_marker_modal ( bContext * C , wmOperator * op , const wmEvent * event )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
SlidePlaneMarkerData * data = ( SlidePlaneMarkerData * ) op - > customdata ;
float dx , dy , mdelta [ 2 ] ;
int next_corner_index , prev_corner_index , diag_corner_index ;
2014-04-27 00:22:49 +10:00
const float * next_corner , * prev_corner , * diag_corner ;
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
float next_edge [ 2 ] , prev_edge [ 2 ] , next_diag_edge [ 2 ] , prev_diag_edge [ 2 ] ;
switch ( event - > type ) {
case LEFTCTRLKEY :
case RIGHTCTRLKEY :
case LEFTSHIFTKEY :
case RIGHTSHIFTKEY :
if ( ELEM ( event - > type , LEFTSHIFTKEY , RIGHTSHIFTKEY ) )
data - > accurate = event - > val = = KM_PRESS ;
/* fall-through */
case MOUSEMOVE :
mdelta [ 0 ] = event - > mval [ 0 ] - data - > previous_mval [ 0 ] ;
mdelta [ 1 ] = event - > mval [ 1 ] - data - > previous_mval [ 1 ] ;
dx = mdelta [ 0 ] / data - > width / sc - > zoom ;
dy = mdelta [ 1 ] / data - > height / sc - > zoom ;
if ( data - > accurate ) {
dx / = 5.0f ;
dy / = 5.0f ;
}
data - > corner [ 0 ] = data - > previous_corner [ 0 ] + dx ;
data - > corner [ 1 ] = data - > previous_corner [ 1 ] + dy ;
/*
prev_edge
( Corner 3 , current ) < - - - - - - - - - - - - - - - - - - - - - - - ( Corner 2 , previous )
| ^
| |
| |
| |
next_edge | | next_diag_edge
| |
| |
| |
v |
( Corner 0 , next ) - - - - - - - - - - - - - - - - - - - - - - - > ( Corner 1 , diagonal )
prev_diag_edge
*/
next_corner_index = ( data - > corner_index + 1 ) % 4 ;
prev_corner_index = ( data - > corner_index + 3 ) % 4 ;
diag_corner_index = ( data - > corner_index + 2 ) % 4 ;
next_corner = data - > plane_marker - > corners [ next_corner_index ] ;
prev_corner = data - > plane_marker - > corners [ prev_corner_index ] ;
diag_corner = data - > plane_marker - > corners [ diag_corner_index ] ;
sub_v2_v2v2 ( next_edge , next_corner , data - > corner ) ;
sub_v2_v2v2 ( prev_edge , data - > corner , prev_corner ) ;
sub_v2_v2v2 ( next_diag_edge , prev_corner , diag_corner ) ;
sub_v2_v2v2 ( prev_diag_edge , diag_corner , next_corner ) ;
if ( cross_v2v2 ( prev_edge , next_edge ) < 0.0f ) {
closest_to_line_v2 ( data - > corner , data - > corner , prev_corner , next_corner ) ;
}
if ( cross_v2v2 ( next_diag_edge , prev_edge ) < 0.0f ) {
closest_to_line_v2 ( data - > corner , data - > corner , prev_corner , diag_corner ) ;
}
if ( cross_v2v2 ( next_edge , prev_diag_edge ) < 0.0f ) {
closest_to_line_v2 ( data - > corner , data - > corner , next_corner , diag_corner ) ;
}
data - > previous_mval [ 0 ] = event - > mval [ 0 ] ;
data - > previous_mval [ 1 ] = event - > mval [ 1 ] ;
copy_v2_v2 ( data - > previous_corner , data - > corner ) ;
DAG_id_tag_update ( & sc - > clip - > id , 0 ) ;
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , NULL ) ;
break ;
case LEFTMOUSE :
2014-02-18 19:07:50 +06:00
case RIGHTMOUSE :
if ( event - > type = = data - > event_type & & event - > val = = KM_RELEASE ) {
Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
tracks which belongs to the same track (minimum amount of
point tracks is 4, maximum is not actually limited).
When new plane track is added, it's getting "tracked"
across all point tracks, which makes it stick to the same
plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
in a way it covers feature one might to mask/replace.
General transform tools (G, R, S) or sliding corners with
a mouse could be sued for this. Plane corner which
corresponds to left bottom image corner has got X/Y axis
on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
for the frames sequence between current frame and next
and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
(Marker Delete) operator. However, currently manual
re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
the plane.
- Node outputs:
* Input image warped into the plane.
* Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
makes this point deforming in a way as if it belongs
to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
2013-08-16 09:46:30 +00:00
/* Marker is now keyframed. */
data - > plane_marker - > flag & = ~ PLANE_MARKER_TRACKED ;
slide_plane_marker_update_homographies ( sc , data ) ;
free_slide_plane_marker_data ( op - > customdata ) ;
show_cursor ( C ) ;
DAG_id_tag_update ( & sc - > clip - > id , 0 ) ;
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
return OPERATOR_FINISHED ;
}
break ;
case ESCKEY :
cancel_mouse_slide_plane_marker ( op - > customdata ) ;
free_slide_plane_marker_data ( op - > customdata ) ;
show_cursor ( C ) ;
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
return OPERATOR_CANCELLED ;
}
return OPERATOR_RUNNING_MODAL ;
}
void CLIP_OT_slide_plane_marker ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Slide Plane Marker " ;
ot - > description = " Slide plane marker areas " ;
ot - > idname = " CLIP_OT_slide_plane_marker " ;
/* api callbacks */
ot - > poll = ED_space_clip_tracking_poll ;
ot - > invoke = slide_plane_marker_invoke ;
ot - > modal = slide_plane_marker_modal ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING ;
}
2013-09-09 11:55:52 +00:00
/********************** Insert track keyframe operator *********************/
static void keyframe_set_flag ( bContext * C , bool set )
{
SpaceClip * sc = CTX_wm_space_clip ( C ) ;
MovieClip * clip = ED_space_clip_get_clip ( sc ) ;
MovieTracking * tracking = & clip - > tracking ;
ListBase * tracks_base = BKE_tracking_get_active_tracks ( tracking ) ;
ListBase * plane_tracks_base = BKE_tracking_get_active_plane_tracks ( tracking ) ;
MovieTrackingTrack * track ;
MovieTrackingPlaneTrack * plane_track ;
int framenr = ED_space_clip_get_clip_frame_number ( sc ) ;
for ( track = tracks_base - > first ; track ; track = track - > next ) {
if ( TRACK_VIEW_SELECTED ( sc , track ) ) {
2013-09-17 08:58:12 +00:00
if ( set ) {
MovieTrackingMarker * marker = BKE_tracking_marker_ensure ( track , framenr ) ;
marker - > flag & = ~ MARKER_TRACKED ;
}
else {
MovieTrackingMarker * marker = BKE_tracking_marker_get_exact ( track , framenr ) ;
if ( marker ) {
2013-09-09 11:55:52 +00:00
marker - > flag | = MARKER_TRACKED ;
}
}
}
}
for ( plane_track = plane_tracks_base - > first ; plane_track ; plane_track = plane_track - > next ) {
2014-03-06 20:07:14 +06:00
if ( PLANE_TRACK_VIEW_SELECTED ( plane_track ) ) {
2013-09-17 08:58:12 +00:00
if ( set ) {
MovieTrackingPlaneMarker * plane_marker = BKE_tracking_plane_marker_ensure ( plane_track , framenr ) ;
if ( plane_marker - > flag & PLANE_MARKER_TRACKED ) {
plane_marker - > flag & = ~ PLANE_MARKER_TRACKED ;
BKE_tracking_track_plane_from_existing_motion ( plane_track , plane_marker - > framenr ) ;
2013-09-09 11:55:52 +00:00
}
2013-09-17 08:58:12 +00:00
}
else {
MovieTrackingPlaneMarker * plane_marker = BKE_tracking_plane_marker_get_exact ( plane_track , framenr ) ;
if ( plane_marker ) {
2013-09-17 08:54:10 +00:00
if ( ( plane_marker - > flag & PLANE_MARKER_TRACKED ) = = 0 ) {
plane_marker - > flag | = PLANE_MARKER_TRACKED ;
BKE_tracking_retrack_plane_from_existing_motion_at_segment ( plane_track , plane_marker - > framenr ) ;
}
2013-09-09 11:55:52 +00:00
}
}
}
}
2013-09-17 08:54:10 +00:00
WM_event_add_notifier ( C , NC_MOVIECLIP | NA_EDITED , clip ) ;
2013-09-09 11:55:52 +00:00
}
static int keyframe_insert_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
keyframe_set_flag ( C , true ) ;
return OPERATOR_FINISHED ;
}
void CLIP_OT_keyframe_insert ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Insert keyframe " ;
ot - > description = " Insert a keyframe to selected tracks at current frame " ;
ot - > idname = " CLIP_OT_keyframe_insert " ;
/* api callbacks */
ot - > poll = ED_space_clip_tracking_poll ;
ot - > exec = keyframe_insert_exec ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
}
/********************** Delete track keyframe operator *********************/
static int keyframe_delete_exec ( bContext * C , wmOperator * UNUSED ( op ) )
{
keyframe_set_flag ( C , false ) ;
return OPERATOR_FINISHED ;
}
void CLIP_OT_keyframe_delete ( wmOperatorType * ot )
{
/* identifiers */
ot - > name = " Delete keyframe " ;
ot - > description = " Delete a keyframe from selected tracks at current frame " ;
ot - > idname = " CLIP_OT_keyframe_delete " ;
/* api callbacks */
ot - > poll = ED_space_clip_tracking_poll ;
ot - > exec = keyframe_delete_exec ;
/* flags */
ot - > flag = OPTYPE_REGISTER | OPTYPE_UNDO ;
}