2011-11-07 12:55:18 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spclip
|
2011-11-07 12:55:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_blenlib.h"
|
2016-01-27 16:20:17 +01:00
|
|
|
#include "BLI_ghash.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "BLI_math.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_movieclip.h"
|
|
|
|
|
#include "BKE_report.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_tracking.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "ED_clip.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_screen.h"
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-05-30 11:37:53 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
#include "clip_intern.h"
|
|
|
|
|
#include "tracking_ops_intern.h"
|
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
|
|
|
|
2016-01-15 14:02:26 +05: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);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2012-07-26 22:41:40 +00:00
|
|
|
|
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];
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_mouse_pos(sc, region, event->mval, co);
|
2013-05-21 14:44:50 +00:00
|
|
|
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 *********************/
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
static int add_marker_at_click_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
2013-05-22 06:06:22 +00:00
|
|
|
{
|
2019-06-11 22:25:01 +02:00
|
|
|
ED_workspace_status_text(C, TIP_("Use LMB click to define location where place the marker"));
|
2013-05-22 06:06:22 +00:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Add modal handler for ESC. */
|
2013-05-30 11:37:53 +00:00
|
|
|
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
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
static int add_marker_at_click_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
|
2013-05-30 11:37:53 +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: {
|
2016-01-15 13:48:24 +05:00
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2016-01-15 13:48:24 +05:00
|
|
|
float pos[2];
|
|
|
|
|
|
2018-06-26 17:19:25 +02:00
|
|
|
ED_workspace_status_text(C, NULL);
|
2013-05-30 11:37:53 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc,
|
|
|
|
|
region,
|
|
|
|
|
event->x - region->winrct.xmin,
|
|
|
|
|
event->y - region->winrct.ymin,
|
|
|
|
|
&pos[0],
|
|
|
|
|
&pos[1]);
|
2013-05-30 11:37:53 +00:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (!add_marker(C, pos[0], pos[1])) {
|
2013-05-30 11:37:53 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2013-05-30 11:37:53 +00:00
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
|
|
|
|
return OPERATOR_FINISHED;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2013-05-30 11:37:53 +00:00
|
|
|
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_ESCKEY:
|
2018-06-26 17:19:25 +02:00
|
|
|
ED_workspace_status_text(C, NULL);
|
2013-05-31 22:35:25 +00:00
|
|
|
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;
|
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. */
|
2016-01-15 13:48:24 +05:00
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
|
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first, *next_plane_track;
|
|
|
|
|
plane_track != NULL;
|
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_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)) {
|
2017-12-19 12:58:42 +01:00
|
|
|
clip_delete_plane_track(C, clip, 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
|
|
|
}
|
|
|
|
|
}
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Remove selected point tracks (they'll also be removed from planes which
|
|
|
|
|
* uses them).
|
|
|
|
|
*/
|
|
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
|
|
|
|
|
track = next_track) {
|
|
|
|
|
next_track = track->next;
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-11-26 00:38:50 +01:00
|
|
|
}
|
2016-01-15 13:48:24 +05: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;
|
2016-01-15 13:48:24 +05: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);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
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);
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
const 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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
|
|
|
|
|
track = next_track) {
|
|
|
|
|
next_track = track->next;
|
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);
|
2016-01-15 13:48:24 +05:00
|
|
|
if (marker != NULL) {
|
2012-05-07 08:53:59 +00:00
|
|
|
has_selection |= track->markersnr > 1;
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
|
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first, *plane_track_next;
|
|
|
|
|
plane_track != NULL;
|
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_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)) {
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get_exact(plane_track,
|
|
|
|
|
framenr);
|
|
|
|
|
if (plane_marker != NULL) {
|
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
|
|
|
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;
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!has_selection) {
|
2016-01-15 13:48:24 +05: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (!changed) {
|
2013-11-26 00:38:50 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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 *********************/
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
enum {
|
|
|
|
|
SLIDE_ACTION_POS = 0,
|
|
|
|
|
SLIDE_ACTION_SIZE,
|
|
|
|
|
SLIDE_ACTION_OFFSET,
|
|
|
|
|
SLIDE_ACTION_TILT_SIZE,
|
|
|
|
|
};
|
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
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Data to restore on cancel. */
|
2012-06-15 16:07:33 +00:00
|
|
|
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;
|
|
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static void slide_marker_tilt_slider(const MovieTrackingMarker *marker, float r_slider[2])
|
2012-06-15 18:31:46 +00:00
|
|
|
{
|
2016-01-15 12:23:24 +05:00
|
|
|
add_v2_v2v2(r_slider, marker->pattern_corners[1], marker->pattern_corners[2]);
|
|
|
|
|
add_v2_v2(r_slider, marker->pos);
|
2012-06-15 18:31:46 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
static SlideMarkerData *create_slide_marker_data(SpaceClip *sc,
|
|
|
|
|
MovieTrackingTrack *track,
|
|
|
|
|
MovieTrackingMarker *marker,
|
|
|
|
|
const wmEvent *event,
|
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
marker = BKE_tracking_marker_ensure(track, framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
data->area = area;
|
|
|
|
|
data->action = action;
|
|
|
|
|
data->track = track;
|
|
|
|
|
data->marker = marker;
|
2019-04-17 06:17:24 +02: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) {
|
2012-03-25 23:19:21 +00:00
|
|
|
data->pos = marker->pos;
|
|
|
|
|
data->offset = track->offset;
|
2016-01-15 13:48:24 +05:00
|
|
|
data->old_markers = MEM_callocN(sizeof(*data->old_markers) * track->markersnr,
|
|
|
|
|
"slide marekrs");
|
|
|
|
|
for (int 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);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
data->mval[0] = event->mval[0];
|
|
|
|
|
data->mval[1] = event->mval[1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
data->width = width;
|
|
|
|
|
data->height = height;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (action == SLIDE_ACTION_SIZE) {
|
2014-03-31 15:31:28 +06:00
|
|
|
data->lock = true;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Backup marker's settings. */
|
2012-06-15 16:07:33 +00:00
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return data;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static float mouse_to_slide_zone_distance_squared(const float co[2],
|
|
|
|
|
const float slide_zone[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2019-09-14 08:10:50 +10:00
|
|
|
const float pixel_co[2] = {co[0] * width, co[1] * height},
|
|
|
|
|
pixel_slide_zone[2] = {slide_zone[0] * width, slide_zone[1] * height};
|
2020-03-06 17:18:10 +01:00
|
|
|
return square_f(pixel_co[0] - pixel_slide_zone[0]) + square_f(pixel_co[1] - pixel_slide_zone[1]);
|
2012-06-15 18:31:46 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static float mouse_to_search_corner_distance_squared(
|
|
|
|
|
const MovieTrackingMarker *marker, const float co[2], int corner, int width, int height)
|
2012-06-15 18:31:46 +00:00
|
|
|
{
|
2016-01-15 12:23:24 +05:00
|
|
|
float side_zone[2];
|
2012-03-25 23:19:21 +00:00
|
|
|
if (corner == 0) {
|
2016-01-15 12:23:24 +05:00
|
|
|
side_zone[0] = marker->pos[0] + marker->search_max[0];
|
|
|
|
|
side_zone[1] = marker->pos[1] + marker->search_min[1];
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2016-01-15 12:23:24 +05:00
|
|
|
side_zone[0] = marker->pos[0] + marker->search_min[0];
|
|
|
|
|
side_zone[1] = marker->pos[1] + marker->search_max[1];
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2016-01-15 12:23:24 +05:00
|
|
|
return mouse_to_slide_zone_distance_squared(co, side_zone, width, height);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static float mouse_to_closest_pattern_corner_distance_squared(
|
|
|
|
|
const MovieTrackingMarker *marker, const float co[2], int width, int height, int *r_corner)
|
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
|
|
|
{
|
2016-01-15 12:23:24 +05:00
|
|
|
float min_distance_squared = FLT_MAX;
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
float corner_co[2];
|
|
|
|
|
add_v2_v2v2(corner_co, marker->pattern_corners[i], marker->pos);
|
|
|
|
|
float distance_squared = mouse_to_slide_zone_distance_squared(co, corner_co, width, height);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
|
|
|
|
min_distance_squared = distance_squared;
|
|
|
|
|
*r_corner = i;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 12:23:24 +05:00
|
|
|
}
|
|
|
|
|
return min_distance_squared;
|
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
|
|
|
}
|
|
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static float mouse_to_offset_distance_squared(const MovieTrackingTrack *track,
|
|
|
|
|
const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2016-01-15 12:23:24 +05:00
|
|
|
float pos[2];
|
2011-11-07 12:55:18 +00:00
|
|
|
add_v2_v2v2(pos, marker->pos, track->offset);
|
2016-01-15 12:23:24 +05:00
|
|
|
return mouse_to_slide_zone_distance_squared(co, pos, width, height);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
static int mouse_to_tilt_distance_squared(const MovieTrackingMarker *marker,
|
|
|
|
|
const float co[2],
|
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2012-06-15 18:31:46 +00:00
|
|
|
{
|
|
|
|
|
float slider[2];
|
|
|
|
|
slide_marker_tilt_slider(marker, slider);
|
2016-01-15 12:23:24 +05:00
|
|
|
return mouse_to_slide_zone_distance_squared(co, slider, width, height);
|
2012-06-15 18:31:46 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
float cross = 0.0f;
|
2020-08-07 22:36:11 +10:00
|
|
|
const float p[2] = {0.0f, 0.0f};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) {
|
2013-09-05 13:37:53 +00:00
|
|
|
return false;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 18:41:07 +02:00
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
float v1[2], v2[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 18:41:07 +02:00
|
|
|
int next = (i + 1) % 4;
|
|
|
|
|
int prev = (4 + i - 1) % 4;
|
2019-04-17 06:17:24 +02: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
|
|
|
sub_v2_v2v2(v1, corners[i], corners[prev]);
|
|
|
|
|
sub_v2_v2v2(v2, corners[next], corners[i]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-09 18:41:07 +02:00
|
|
|
float cur_cross = cross_v2v2(v1, v2);
|
2019-04-17 06:17:24 +02: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
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
MovieTrackingTrack *tracking_marker_check_slide(
|
2020-03-25 17:58:58 +11:00
|
|
|
bContext *C, const wmEvent *event, int *r_area, int *r_action, int *r_corner)
|
2012-06-15 11:40:04 +00:00
|
|
|
{
|
2016-01-15 12:23:24 +05:00
|
|
|
const float distance_clip_squared = 12.0f * 12.0f;
|
2012-06-15 11:40:04 +00:00
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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);
|
2016-01-15 12:23:24 +05:00
|
|
|
float global_min_distance_squared = FLT_MAX;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* Sliding zone designator which is the closest to the mouse
|
|
|
|
|
* across all the tracks.
|
|
|
|
|
*/
|
|
|
|
|
int min_action = -1, min_area = 0, min_corner = -1;
|
|
|
|
|
MovieTrackingTrack *min_track = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-26 22:41:40 +00:00
|
|
|
ED_space_clip_get_size(sc, &width, &height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:19:45 +10:00
|
|
|
if (width == 0 || height == 0) {
|
2012-06-15 11:40:04 +00:00
|
|
|
return NULL;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_mouse_pos(sc, region, event->mval, co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
track = tracksbase->first;
|
|
|
|
|
while (track) {
|
|
|
|
|
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
|
2016-01-15 12:23:24 +05:00
|
|
|
const MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
|
|
|
|
/* Sliding zone designator which is the closest to the mouse for
|
|
|
|
|
* the current tracks.
|
|
|
|
|
*/
|
|
|
|
|
float min_distance_squared = FLT_MAX;
|
|
|
|
|
int action = -1, area = 0, corner = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
if ((marker->flag & MARKER_DISABLED) == 0) {
|
2016-01-15 12:23:24 +05:00
|
|
|
float distance_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* We start checking with whether the mouse is close enough
|
|
|
|
|
* to the pattern offset area.
|
|
|
|
|
*/
|
|
|
|
|
distance_squared = mouse_to_offset_distance_squared(track, marker, co, width, height);
|
|
|
|
|
area = TRACK_AREA_POINT;
|
|
|
|
|
action = SLIDE_ACTION_POS;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* NOTE: All checks here are assuming there's no maximum distance
|
|
|
|
|
* limit, so checks are quite simple here.
|
|
|
|
|
* Actual distance clipping happens later once all the sliding
|
|
|
|
|
* zones are checked.
|
|
|
|
|
*/
|
|
|
|
|
min_distance_squared = distance_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* If search area is visible, check how close to its sliding
|
|
|
|
|
* zones mouse is.
|
|
|
|
|
*/
|
|
|
|
|
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
|
|
|
|
|
distance_squared = mouse_to_search_corner_distance_squared(marker, co, 1, width, height);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
2012-06-15 14:26:27 +00:00
|
|
|
area = TRACK_AREA_SEARCH;
|
|
|
|
|
action = SLIDE_ACTION_OFFSET;
|
2016-01-15 12:23:24 +05:00
|
|
|
min_distance_squared = distance_squared;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
distance_squared = mouse_to_search_corner_distance_squared(marker, co, 0, width, height);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
2012-06-15 14:26:27 +00:00
|
|
|
area = TRACK_AREA_SEARCH;
|
|
|
|
|
action = SLIDE_ACTION_SIZE;
|
2016-01-15 12:23:24 +05:00
|
|
|
min_distance_squared = distance_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* If pattern area is visible, check which corner is closest to
|
|
|
|
|
* the mouse.
|
|
|
|
|
*/
|
|
|
|
|
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
|
2018-05-02 10:32:01 +02:00
|
|
|
int current_corner = -1;
|
2016-01-15 12:23:24 +05:00
|
|
|
distance_squared = mouse_to_closest_pattern_corner_distance_squared(
|
|
|
|
|
marker, co, width, height, ¤t_corner);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
2012-06-15 18:31:46 +00:00
|
|
|
area = TRACK_AREA_PAT;
|
|
|
|
|
action = SLIDE_ACTION_POS;
|
|
|
|
|
corner = current_corner;
|
2016-01-15 12:23:24 +05:00
|
|
|
min_distance_squared = distance_squared;
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
/* Here we also check whether the mouse is actually closer to
|
|
|
|
|
* the widget which controls scale and tilt.
|
|
|
|
|
*/
|
|
|
|
|
distance_squared = mouse_to_tilt_distance_squared(marker, co, width, height);
|
|
|
|
|
if (distance_squared < min_distance_squared) {
|
|
|
|
|
area = TRACK_AREA_PAT;
|
|
|
|
|
action = SLIDE_ACTION_TILT_SIZE;
|
|
|
|
|
min_distance_squared = distance_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 12:23:24 +05:00
|
|
|
if (min_distance_squared < global_min_distance_squared) {
|
|
|
|
|
min_area = area;
|
|
|
|
|
min_action = action;
|
|
|
|
|
min_corner = corner;
|
|
|
|
|
min_track = track;
|
|
|
|
|
global_min_distance_squared = min_distance_squared;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-06-15 14:26:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 11:40:04 +00:00
|
|
|
track = track->next;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 15:37:46 +05:00
|
|
|
if (global_min_distance_squared < distance_clip_squared / sc->zoom) {
|
2020-03-25 17:58:58 +11:00
|
|
|
if (r_area) {
|
|
|
|
|
*r_area = min_area;
|
2016-01-15 12:23:24 +05:00
|
|
|
}
|
2020-03-25 17:58:58 +11:00
|
|
|
if (r_action) {
|
|
|
|
|
*r_action = min_action;
|
2016-01-15 12:23:24 +05:00
|
|
|
}
|
2020-03-25 17:58:58 +11:00
|
|
|
if (r_corner) {
|
|
|
|
|
*r_corner = min_corner;
|
2016-01-15 12:23:24 +05:00
|
|
|
}
|
|
|
|
|
return min_track;
|
|
|
|
|
}
|
2012-06-15 11:40:04 +00:00
|
|
|
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);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2012-07-26 22:41:40 +00:00
|
|
|
|
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
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (width == 0 || height == 0) {
|
2011-11-07 12:55:18 +00:00
|
|
|
return NULL;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_mouse_pos(sc, region, 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);
|
2016-01-15 13:48:24 +05:00
|
|
|
if (track != NULL) {
|
2012-06-15 14:26:27 +00:00
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
|
2016-01-15 13:48:24 +05: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);
|
2016-01-15 13:48:24 +05:00
|
|
|
if (slidedata != NULL) {
|
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
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
clip_tracking_hide_cursor(C);
|
2011-11-07 12:55:18 +00:00
|
|
|
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
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
memcpy(marker->pattern_corners, data->old_corners, sizeof(marker->pattern_corners));
|
2012-06-15 16:07:33 +00:00
|
|
|
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
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (data->old_markers != NULL) {
|
|
|
|
|
for (int a = 0; a < data->track->markersnr; a++) {
|
2012-06-15 16:07:33 +00:00
|
|
|
copy_v2_v2(data->track->markers[a].pos, data->old_markers[a]);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
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);
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
2013-09-10 12:46:18 +00:00
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
|
2013-09-10 12:46:18 +00:00
|
|
|
plane_track = plane_track->next) {
|
|
|
|
|
if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) {
|
2016-01-15 13:48:24 +05:00
|
|
|
if (BKE_tracking_plane_track_has_point_track(plane_track, data->track)) {
|
|
|
|
|
BKE_tracking_track_plane_from_existing_motion(plane_track, framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-09-10 12:46:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
static void free_slide_data(SlideMarkerData *data)
|
|
|
|
|
{
|
2016-01-15 13:48:24 +05:00
|
|
|
if (data->old_markers != NULL) {
|
2012-06-15 16:07:33 +00:00
|
|
|
MEM_freeN(data->old_markers);
|
2016-01-15 13:48:24 +05: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);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (event->type) {
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_LEFTCTRLKEY:
|
|
|
|
|
case EVT_RIGHTCTRLKEY:
|
|
|
|
|
case EVT_LEFTSHIFTKEY:
|
|
|
|
|
case EVT_RIGHTSHIFTKEY:
|
2016-01-15 13:48:24 +05:00
|
|
|
if (data->action == SLIDE_ACTION_SIZE) {
|
2020-03-18 10:38:37 -06:00
|
|
|
if (ELEM(event->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) {
|
2012-03-25 23:19:21 +00:00
|
|
|
data->lock = event->val == KM_RELEASE;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-18 10:38:37 -06:00
|
|
|
if (ELEM(event->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY)) {
|
2012-03-25 23:19:21 +00:00
|
|
|
data->accurate = event->val == KM_PRESS;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2017-05-20 14:01:03 +10:00
|
|
|
ATTR_FALLTHROUGH;
|
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];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
dx = mdelta[0] / data->width / sc->zoom;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (data->lock) {
|
2012-03-25 23:19:21 +00:00
|
|
|
dy = -dx / data->height * data->width;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:19:21 +00:00
|
|
|
dy = mdelta[1] / data->height / sc->zoom;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (data->accurate) {
|
2016-01-15 13:48:24 +05:00
|
|
|
dx /= 5.0f;
|
|
|
|
|
dy /= 5.0f;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc, region, data->mval[0], data->mval[1], &start[0], &start[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
sub_v2_v2(start, data->old_pos);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
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];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc, region, mval[0], mval[1], &end[0], &end[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
sub_v2_v2(end, data->old_pos);
|
|
|
|
|
scale = len_v2(end) / len_v2(start);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
if (scale > 0.0f) {
|
2016-01-15 13:48:24 +05:00
|
|
|
for (int a = 0; a < 4; a++) {
|
|
|
|
|
mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
|
2012-06-15 18:31:46 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float d[2] = {dx, dy};
|
2016-01-15 13:48:24 +05:00
|
|
|
for (int a = 0; a < data->track->markersnr; a++) {
|
|
|
|
|
add_v2_v2v2(data->track->markers[a].pos, data->old_markers[a], d);
|
|
|
|
|
}
|
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];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
copy_v2_v2(spos, data->pos);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
data->pos[0] = data->spos[0] + dx;
|
|
|
|
|
data->pos[1] = data->spos[1] + dy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
if (!slide_check_corners(data->corners)) {
|
|
|
|
|
copy_v2_v2(data->pos, spos);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Currently only patterns are allowed to have such
|
|
|
|
|
* combination of event and data.
|
|
|
|
|
*/
|
2012-06-15 18:31:46 +00:00
|
|
|
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;
|
|
|
|
|
float mval[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
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];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-15 18:31:46 +00:00
|
|
|
sub_v2_v2v2(start, data->spos, data->old_pos);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_clip_point_stable_pos(sc, region, mval[0], mval[1], &end[0], &end[1]);
|
2012-06-15 18:31:46 +00:00
|
|
|
sub_v2_v2(end, data->old_pos);
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (len_squared_v2(start) != 0.0f) {
|
|
|
|
|
scale = len_v2(end) / len_v2(start);
|
2012-06-15 18:31:46 +00:00
|
|
|
|
|
|
|
|
if (scale < 0.0f) {
|
|
|
|
|
scale = 0.0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2012-06-15 18:31:46 +00:00
|
|
|
|
|
|
|
|
angle = -angle_signed_v2v2(start, end);
|
|
|
|
|
|
2012-11-04 07:18:29 +00:00
|
|
|
for (int a = 0; a < 4; a++) {
|
|
|
|
|
float vec[2];
|
2012-06-15 18:31:46 +00:00
|
|
|
|
2012-06-15 11:03:23 +00:00
|
|
|
mul_v2_v2fl(data->corners[a], data->old_corners[a], scale);
|
2012-06-15 18:31:46 +00:00
|
|
|
|
2012-06-15 16:07:33 +00:00
|
|
|
copy_v2_v2(vec, data->corners[a]);
|
|
|
|
|
vec[0] *= data->width;
|
|
|
|
|
vec[1] *= data->height;
|
|
|
|
|
|
|
|
|
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-06-15 16:07:33 +00:00
|
|
|
|
|
|
|
|
BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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;
|
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
|
|
|
BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_DIM);
|
2019-04-17 06:17:24 +02: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->area == TRACK_AREA_SEARCH) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float d[2] = {dx, dy};
|
2012-06-15 16:07:33 +00:00
|
|
|
add_v2_v2v2(data->min, data->old_search_min, d);
|
|
|
|
|
add_v2_v2v2(data->max, data->old_search_max, d);
|
2019-04-17 06:17:24 +02: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
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_POS);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
data->marker->flag &= ~MARKER_TRACKED;
|
|
|
|
|
|
2013-09-10 12:46:18 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
break;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
case LEFTMOUSE:
|
|
|
|
|
if (event->val == KM_RELEASE) {
|
|
|
|
|
apply_mouse_slide(C, op->customdata);
|
|
|
|
|
free_slide_data(op->customdata);
|
|
|
|
|
|
|
|
|
|
clip_tracking_show_cursor(C);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
2020-03-18 10:38:37 -06:00
|
|
|
case EVT_ESCKEY:
|
2016-01-15 14:02:26 +05:00
|
|
|
cancel_mouse_slide(op->customdata);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
free_slide_data(op->customdata);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
clip_tracking_show_cursor(C);
|
|
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
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 */
|
2019-05-29 00:48:48 +10:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR_XY | OPTYPE_BLOCKING;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
RNA_def_float_vector(ot->srna,
|
|
|
|
|
"offset",
|
|
|
|
|
2,
|
|
|
|
|
NULL,
|
|
|
|
|
-FLT_MAX,
|
|
|
|
|
FLT_MAX,
|
2016-01-15 13:48:24 +05:00
|
|
|
"Offset",
|
2020-12-24 13:11:22 -06:00
|
|
|
"Offset in floating-point units, 1.0 is the width and height of the image",
|
2016-01-15 13:48:24 +05:00
|
|
|
-FLT_MAX,
|
|
|
|
|
FLT_MAX);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/********************** clear track operator *********************/
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
static int clear_track_path_exec(bContext *C, wmOperator *op)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2016-01-15 14:02:26 +05:00
|
|
|
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);
|
|
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
|
|
|
|
const bool clear_active = RNA_boolean_get(op->ptr, "clear_active");
|
|
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
if (clear_active) {
|
|
|
|
|
MovieTrackingTrack *track = BKE_tracking_track_get_active(tracking);
|
|
|
|
|
if (track != NULL) {
|
|
|
|
|
BKE_tracking_track_path_clear(track, framenr, action);
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 14:02:26 +05:00
|
|
|
else {
|
2016-01-15 13:48:24 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
2016-01-15 14:02:26 +05:00
|
|
|
if (TRACK_VIEW_SELECTED(sc, track)) {
|
|
|
|
|
BKE_tracking_track_path_clear(track, framenr, action);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2012-01-09 20:18:48 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
BKE_tracking_dopesheet_tag_update(tracking);
|
|
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
return OPERATOR_FINISHED;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
void CLIP_OT_clear_track_path(wmOperatorType *ot)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem clear_path_actions[] = {
|
2020-10-24 11:42:17 -07:00
|
|
|
{TRACK_CLEAR_UPTO, "UPTO", 0, "Clear Up To", "Clear path up to current frame"},
|
2016-01-15 14:02:26 +05:00
|
|
|
{TRACK_CLEAR_REMAINED,
|
|
|
|
|
"REMAINED",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Clear Remained",
|
2016-01-15 14:02:26 +05:00
|
|
|
"Clear path at remaining frames (after current)"},
|
2020-10-24 11:42:17 -07:00
|
|
|
{TRACK_CLEAR_ALL, "ALL", 0, "Clear All", "Clear the whole path"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2016-01-15 14:02:26 +05:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* identifiers */
|
|
|
|
|
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";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = clear_track_path_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* properties */
|
|
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"action",
|
|
|
|
|
clear_path_actions,
|
|
|
|
|
TRACK_CLEAR_REMAINED,
|
|
|
|
|
"Action",
|
|
|
|
|
"Clear action to execute");
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/********************** disable markers operator *********************/
|
|
|
|
|
|
2016-01-27 14:27:37 +01:00
|
|
|
enum {
|
|
|
|
|
MARKER_OP_DISABLE = 0,
|
|
|
|
|
MARKER_OP_ENABLE = 1,
|
|
|
|
|
MARKER_OP_TOGGLE = 2,
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
static int disable_markers_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);
|
2016-01-15 14:02:26 +05:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
2013-10-28 21:49:49 +00:00
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
|
|
|
|
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
|
|
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
|
2016-01-27 14:27:37 +01:00
|
|
|
switch (action) {
|
|
|
|
|
case MARKER_OP_DISABLE:
|
|
|
|
|
marker->flag |= MARKER_DISABLED;
|
|
|
|
|
break;
|
|
|
|
|
case MARKER_OP_ENABLE:
|
|
|
|
|
marker->flag &= ~MARKER_DISABLED;
|
|
|
|
|
break;
|
|
|
|
|
case MARKER_OP_TOGGLE:
|
|
|
|
|
marker->flag ^= MARKER_DISABLED;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 14:02:26 +05:00
|
|
|
}
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
void CLIP_OT_disable_markers(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem actions_items[] = {
|
2016-01-27 14:27:37 +01:00
|
|
|
{MARKER_OP_DISABLE, "DISABLE", 0, "Disable", "Disable selected markers"},
|
|
|
|
|
{MARKER_OP_ENABLE, "ENABLE", 0, "Enable", "Enable selected markers"},
|
|
|
|
|
{MARKER_OP_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle disabled flag for selected markers"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2016-01-15 14:02:26 +05:00
|
|
|
};
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Disable Markers";
|
|
|
|
|
ot->description = "Disable/enable selected markers";
|
|
|
|
|
ot->idname = "CLIP_OT_disable_markers";
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = disable_markers_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* properties */
|
|
|
|
|
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute");
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/********************** set principal center operator *********************/
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
|
|
|
|
int width, height;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
if (width == 0 || height == 0) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05: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
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
return OPERATOR_FINISHED;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
void CLIP_OT_set_center_principal(wmOperatorType *ot)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2016-01-15 14:02:26 +05:00
|
|
|
/* identifiers */
|
|
|
|
|
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
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = set_center_principal_exec;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2013-09-10 12:46:18 +00:00
|
|
|
}
|
2013-07-23 14:22:47 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/********************** hide tracks operator *********************/
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
static int hide_tracks_exec(bContext *C, wmOperator *op)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2016-01-15 14:02:26 +05:00
|
|
|
SpaceClip *sc = CTX_wm_space_clip(C);
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(sc);
|
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
int unselected;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
unselected = RNA_boolean_get(op->ptr, "unselected");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* Hide point tracks. */
|
|
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
|
|
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
|
|
|
|
if (unselected == 0 && TRACK_VIEW_SELECTED(sc, track)) {
|
|
|
|
|
track->flag |= TRACK_HIDDEN;
|
|
|
|
|
}
|
|
|
|
|
else if (unselected == 1 && !TRACK_VIEW_SELECTED(sc, track)) {
|
|
|
|
|
track->flag |= TRACK_HIDDEN;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 14:02:26 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
if (act_track != NULL && act_track->flag & TRACK_HIDDEN) {
|
|
|
|
|
clip->tracking.act_track = NULL;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/* Hide place tracks. */
|
|
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
|
|
|
|
MovieTrackingPlaneTrack *act_plane_track = BKE_tracking_plane_track_get_active(tracking);
|
|
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
|
|
|
|
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 14:02:26 +05:00
|
|
|
}
|
|
|
|
|
if (act_plane_track != NULL && act_plane_track->flag & TRACK_HIDDEN) {
|
|
|
|
|
clip->tracking.act_plane_track = NULL;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
if (unselected == 0) {
|
|
|
|
|
/* No selection on screen now, unlock view so it can be
|
|
|
|
|
* scrolled nice again.
|
|
|
|
|
*/
|
|
|
|
|
sc->flag &= ~SC_LOCK_SELECTION;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
BKE_tracking_dopesheet_tag_update(tracking);
|
|
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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;
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Unhide point tracks. */
|
|
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
2012-03-25 23:19:21 +00:00
|
|
|
track->flag &= ~TRACK_HIDDEN;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Unhide plane tracks. */
|
|
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
2016-01-16 13:01:10 +11:00
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
|
2014-03-06 20:07:14 +06:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** frame jump operator *********************/
|
|
|
|
|
|
2019-05-07 17:07:04 +02:00
|
|
|
static bool frame_jump_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
return space_clip != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
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);
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTracking *tracking = &clip->tracking;
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-10 19:59:02 +00:00
|
|
|
if (pos <= 1) { /* jump to path */
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingTrack *track = BKE_tracking_track_get_active(tracking);
|
|
|
|
|
if (track == NULL) {
|
2011-11-07 12:55:18 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
delta = pos == 1 ? 1 : -1;
|
2016-01-15 13:48:24 +05:00
|
|
|
while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) {
|
|
|
|
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr + delta);
|
|
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (marker == NULL || marker->flag & MARKER_DISABLED) {
|
2011-11-07 12:55:18 +00:00
|
|
|
break;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
sc->user.framenr += delta;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-02-04 01:23:48 +01:00
|
|
|
else { /* to failed frame */
|
2016-01-15 13:48:24 +05:00
|
|
|
if (tracking->reconstruction.flag & TRACKING_RECONSTRUCTED) {
|
|
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2012-06-15 11:03:23 +00:00
|
|
|
MovieTrackingObject *object = BKE_tracking_object_get_active(tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
delta = pos == 3 ? 1 : -1;
|
2016-01-15 13:48:24 +05:00
|
|
|
framenr += delta;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
while (framenr + delta >= SFRA && framenr + delta <= EFRA) {
|
|
|
|
|
MovieReconstructedCamera *cam = BKE_tracking_camera_get_reconstructed(
|
|
|
|
|
tracking, object, framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (cam == NULL) {
|
|
|
|
|
sc->user.framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, framenr);
|
2011-11-07 12:55:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
framenr += delta;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
if (CFRA != sc->user.framenr) {
|
|
|
|
|
CFRA = sc->user.framenr;
|
2019-06-04 16:52:48 +02:00
|
|
|
DEG_id_tag_update(&scene->id, ID_RECALC_AUDIO_SEEK);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_frame_jump(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem position_items[] = {
|
2016-01-15 13:48:24 +05: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"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{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;
|
2019-05-07 17:07:04 +02:00
|
|
|
ot->poll = frame_jump_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 */
|
2016-01-15 13:48:24 +05: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;
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
MovieTrackingStabilization *stab = &tracking->stabilization;
|
2012-06-15 11:03:23 +00:00
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
2016-01-27 16:20:17 +01:00
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
bool update_stabilization = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
|
|
|
|
|
if (act_track == NULL) {
|
2011-11-07 12:55:18 +00:00
|
|
|
BKE_report(op->reports, RPT_ERROR, "No active track to join to");
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-27 16:20:17 +01:00
|
|
|
GSet *point_tracks = BLI_gset_ptr_new(__func__);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
|
|
|
|
|
track = next_track) {
|
|
|
|
|
next_track = track->next;
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
if (track->flag & TRACK_USE_2D_STAB) {
|
|
|
|
|
update_stabilization = true;
|
|
|
|
|
if ((act_track->flag & TRACK_USE_2D_STAB) == 0) {
|
|
|
|
|
act_track->flag |= TRACK_USE_2D_STAB;
|
2017-03-02 00:16:36 +11:00
|
|
|
}
|
|
|
|
|
else {
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
stab->tot_track--;
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(0 <= stab->tot_track);
|
|
|
|
|
}
|
|
|
|
|
if (track->flag & TRACK_USE_2D_STAB_ROT) {
|
|
|
|
|
update_stabilization = true;
|
|
|
|
|
if ((act_track->flag & TRACK_USE_2D_STAB_ROT) == 0) {
|
|
|
|
|
act_track->flag |= TRACK_USE_2D_STAB_ROT;
|
2017-03-02 00:16:36 +11:00
|
|
|
}
|
|
|
|
|
else {
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
stab->tot_rot_track--;
|
|
|
|
|
}
|
|
|
|
|
BLI_assert(0 <= stab->tot_rot_track);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-27 16:20:17 +01:00
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
|
|
|
|
|
plane_track = plane_track->next) {
|
|
|
|
|
if (BKE_tracking_plane_track_has_point_track(plane_track, track)) {
|
|
|
|
|
BKE_tracking_plane_track_replace_point_track(plane_track, track, act_track);
|
|
|
|
|
if ((plane_track->flag & PLANE_TRACK_AUTOKEY) == 0) {
|
|
|
|
|
BLI_gset_insert(point_tracks, plane_track);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2016-01-27 16:20:17 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Rework 2D stabilizator
See this page for motivation and description of concepts:
https://github.com/Ichthyostega/blender/wiki
See this video for UI explanation and demonstration of usage
http://vimeo.com/blenderHack/stabilizerdemo
This proposal attempts to improve usability of Blender's image stabilization
feature for real-world footage esp. with moving and panning camera. It builds
upon the feature tracking to get a measurement of 2D image movement.
- Use a weighted average of movement contributions (instead of a median).
- Allow for rotation compensation and zoom (image scale) compensation.
- Allow to pick a different set of tracks for translation and for
rotation/zoom.
- Treat translation / rotation / zoom contributions systematically in a
similar way.
- Improve handling of partial tracking data with gaps and varying
start / end points.
- Have a user definable anchor frame and interpolate / extrapolate data to
avoid jumping back to "neutral" position when no tracking data is available.
- Support for travelling and panning shots by including an //intended//
position/rotation/zoom ("target position"). The idea is for these parameters
to be //animated// by the user, in order to supply an smooth, intended
camera movement. This way, we can keep the image content roughly in frame
even when moving completely away from the initial view.
A known shortcoming is that the pivot point for rotation compensation is set to
the translation compensated image center. This can produce spurious rotation on
travelling shots, which needs to be compensated manually (by animating the
target rotation parameter). There are several possible ways to address that
problem, yet all of them are considered beyond the scope of this improvement
proposal for now.
Own modifications:
- Restrict line length, it's really handy for split-view editing
- In motion tracking we prefer fully human-readable comments, meaning we
don't use doxygen with it's weird markup and comments are supposed to
start with capital and end with a full stop,
- Add explicit comparison of pointer to NULL.
Reviewers: sergey
Subscribers: kusi, kdawg, forest-house, mardy, Samoth, plasmasolutions, willolis, sebastian_k, hype, enetheru, sunboy, jta, leon_cheung
Maniphest Tasks: T49036
Differential Revision: https://developer.blender.org/D583
2016-08-16 10:32:55 +02:00
|
|
|
if (update_stabilization) {
|
|
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-27 16:20:17 +01:00
|
|
|
GSetIterator gs_iter;
|
|
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
|
|
|
|
GSET_ITER (gs_iter, point_tracks) {
|
|
|
|
|
MovieTrackingPlaneTrack *plane_track = BLI_gsetIterator_getKey(&gs_iter);
|
|
|
|
|
BKE_tracking_track_plane_from_existing_motion(plane_track, framenr);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-27 16:20:17 +01:00
|
|
|
BLI_gset_free(point_tracks, NULL);
|
2019-05-24 14:54:54 +02:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2019-11-28 11:14:32 +01:00
|
|
|
/********************** Average tracks operator *********************/
|
|
|
|
|
|
|
|
|
|
static int average_tracks_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
|
|
|
|
|
/* Collect source tracks. */
|
|
|
|
|
int num_source_tracks;
|
|
|
|
|
MovieTrackingTrack **source_tracks = BKE_tracking_selected_tracks_in_active_object(
|
|
|
|
|
tracking, &num_source_tracks);
|
|
|
|
|
if (num_source_tracks == 0) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create new empty track, which will be the averaged result.
|
|
|
|
|
* Makes it simple to average all selection to it. */
|
|
|
|
|
ListBase *tracks_list = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
MovieTrackingTrack *result_track = BKE_tracking_track_add_empty(tracking, tracks_list);
|
|
|
|
|
|
|
|
|
|
/* Perform averaging. */
|
|
|
|
|
BKE_tracking_tracks_average(result_track, source_tracks, num_source_tracks);
|
|
|
|
|
|
|
|
|
|
const bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
|
|
|
|
|
if (!keep_original) {
|
|
|
|
|
for (int i = 0; i < num_source_tracks; i++) {
|
|
|
|
|
clip_delete_track(C, clip, source_tracks[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update selection, making the result track active and selected. */
|
|
|
|
|
/* TODO(sergey): Should become some sort of utility function available for all operators. */
|
|
|
|
|
|
|
|
|
|
BKE_tracking_track_select(tracks_list, result_track, TRACK_AREA_ALL, 0);
|
|
|
|
|
ListBase *plane_tracks_list = BKE_tracking_get_active_plane_tracks(tracking);
|
|
|
|
|
BKE_tracking_plane_tracks_deselect_all(plane_tracks_list);
|
|
|
|
|
|
|
|
|
|
clip->tracking.act_track = result_track;
|
|
|
|
|
clip->tracking.act_plane_track = NULL;
|
|
|
|
|
|
|
|
|
|
/* Inform the dependency graph and interface about changes. */
|
|
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
|
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
|
|
|
|
|
|
|
|
|
|
/* Free memory. */
|
|
|
|
|
MEM_freeN(source_tracks);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int average_tracks_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop_keep_original = RNA_struct_find_property(op->ptr, "keep_original");
|
|
|
|
|
if (!RNA_property_is_set(op->ptr, prop_keep_original)) {
|
|
|
|
|
SpaceClip *space_clip = CTX_wm_space_clip(C);
|
|
|
|
|
MovieClip *clip = ED_space_clip_get_clip(space_clip);
|
|
|
|
|
MovieTracking *tracking = &clip->tracking;
|
|
|
|
|
|
|
|
|
|
const int num_selected_tracks = BKE_tracking_count_selected_tracks_in_active_object(tracking);
|
|
|
|
|
|
|
|
|
|
if (num_selected_tracks == 1) {
|
|
|
|
|
RNA_property_boolean_set(op->ptr, prop_keep_original, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return average_tracks_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_average_tracks(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* Identifiers. */
|
|
|
|
|
ot->name = "Average Tracks";
|
|
|
|
|
ot->description = "Average selected tracks into active";
|
|
|
|
|
ot->idname = "CLIP_OT_average_tracks";
|
|
|
|
|
|
|
|
|
|
/* API callbacks. */
|
|
|
|
|
ot->exec = average_tracks_exec;
|
|
|
|
|
ot->invoke = average_tracks_invoke;
|
|
|
|
|
ot->poll = ED_space_clip_tracking_poll;
|
|
|
|
|
|
|
|
|
|
/* Flags. */
|
|
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
|
|
|
|
|
|
|
|
|
/* Properties. */
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "keep_original", 1, "Keep Original", "Keep original tracks");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/********************** lock tracks operator *********************/
|
|
|
|
|
|
2016-01-27 14:27:37 +01:00
|
|
|
enum {
|
|
|
|
|
TRACK_ACTION_LOCK = 0,
|
|
|
|
|
TRACK_ACTION_UNLOCK = 1,
|
|
|
|
|
TRACK_ACTION_TOGGLE = 2,
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
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
|
|
|
int action = RNA_enum_get(op->ptr, "action");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (TRACK_VIEW_SELECTED(sc, track)) {
|
2016-01-27 14:27:37 +01:00
|
|
|
switch (action) {
|
|
|
|
|
case TRACK_ACTION_LOCK:
|
|
|
|
|
track->flag |= TRACK_LOCKED;
|
|
|
|
|
break;
|
|
|
|
|
case TRACK_ACTION_UNLOCK:
|
|
|
|
|
track->flag &= ~TRACK_LOCKED;
|
|
|
|
|
break;
|
|
|
|
|
case TRACK_ACTION_TOGGLE:
|
|
|
|
|
track->flag ^= TRACK_LOCKED;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_lock_tracks(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem actions_items[] = {
|
2016-01-27 14:27:37 +01:00
|
|
|
{TRACK_ACTION_LOCK, "LOCK", 0, "Lock", "Lock selected tracks"},
|
|
|
|
|
{TRACK_ACTION_UNLOCK, "UNLOCK", 0, "Unlock", "Unlock selected tracks"},
|
|
|
|
|
{TRACK_ACTION_TOGGLE, "TOGGLE", 0, "Toggle", "Toggle locked flag for selected tracks"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{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 */
|
2016-01-15 13:48:24 +05:00
|
|
|
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute");
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-26 09:50:27 +00:00
|
|
|
/********************** set keyframe operator *********************/
|
|
|
|
|
|
2016-01-27 14:27:37 +01:00
|
|
|
enum {
|
|
|
|
|
SOLVER_KEYFRAME_A = 0,
|
|
|
|
|
SOLVER_KEYFRAME_B = 1,
|
|
|
|
|
};
|
|
|
|
|
|
2012-07-26 09:50:27 +00:00
|
|
|
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");
|
2016-01-15 13:48:24 +05:00
|
|
|
int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, sc->user.framenr);
|
2012-07-26 09:50:27 +00:00
|
|
|
|
2016-01-27 14:27:37 +01:00
|
|
|
if (keyframe == SOLVER_KEYFRAME_A) {
|
2012-10-09 10:33:18 +00:00
|
|
|
object->keyframe1 = framenr;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2016-01-15 14:02:26 +05:00
|
|
|
else {
|
|
|
|
|
object->keyframe2 = framenr;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
void CLIP_OT_set_solver_keyframe(wmOperatorType *ot)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem keyframe_items[] = {
|
2016-01-27 14:27:37 +01:00
|
|
|
{SOLVER_KEYFRAME_A, "KEYFRAME_A", 0, "Keyframe A", ""},
|
|
|
|
|
{SOLVER_KEYFRAME_B, "KEYFRAME_B", 0, "Keyframe B", ""},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2016-01-15 14:02:26 +05:00
|
|
|
};
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* identifiers */
|
2016-01-15 14:02:26 +05:00
|
|
|
ot->name = "Set Solver Keyframe";
|
|
|
|
|
ot->description = "Set keyframe used by solver";
|
|
|
|
|
ot->idname = "CLIP_OT_set_solver_keyframe";
|
2011-11-07 12:55:18 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2016-01-15 14:02:26 +05:00
|
|
|
ot->exec = set_solver_keyframe_exec;
|
|
|
|
|
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;
|
2016-01-15 14:02:26 +05:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
RNA_def_enum(ot->srna, "keyframe", keyframe_items, 0, "Keyframe", "Keyframe to set");
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
/********************** track copy color operator *********************/
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
static int track_copy_color_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;
|
2016-01-15 14:02:26 +05:00
|
|
|
ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking);
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
|
|
|
|
|
if (act_track == NULL) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first; track != NULL; track = track->next) {
|
|
|
|
|
if (TRACK_VIEW_SELECTED(sc, track) && track != act_track) {
|
|
|
|
|
track->flag &= ~TRACK_CUSTOMCOLOR;
|
|
|
|
|
if (act_track->flag & TRACK_CUSTOMCOLOR) {
|
|
|
|
|
copy_v3_v3(track->color, act_track->color);
|
|
|
|
|
track->flag |= TRACK_CUSTOMCOLOR;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-23 10:02:37 +02:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2016-01-15 14:02:26 +05:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip);
|
|
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
void CLIP_OT_track_copy_color(wmOperatorType *ot)
|
2011-11-07 12:55:18 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2016-01-15 14:02:26 +05: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 */
|
2016-01-15 14:02:26 +05:00
|
|
|
ot->exec = track_copy_color_exec;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/********************** 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;
|
2016-01-15 13:48:24 +05:00
|
|
|
int 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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (del) {
|
|
|
|
|
new_markers = MEM_callocN(markersnr * sizeof(MovieTrackingMarker), "track cleaned markers");
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
for (int a = 0; a < markersnr; a++) {
|
2012-03-25 23:19:21 +00:00
|
|
|
int end = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
if (prev == -1) {
|
2016-01-15 13:48:24 +05:00
|
|
|
if ((markers[a].flag & MARKER_DISABLED) == 0) {
|
2012-03-25 23:19:21 +00:00
|
|
|
prev = a;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-25 23:19:21 +00:00
|
|
|
start_disabled = 1;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (end) {
|
2012-03-25 23:19:21 +00:00
|
|
|
int segok = 1, len = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (a != prev && markers[a].framenr != markers[a - 1].framenr + 1) {
|
2012-05-07 08:53:59 +00:00
|
|
|
len = a - prev;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
|
|
|
|
else if (markers[a].flag & MARKER_DISABLED) {
|
2012-05-07 08:53:59 +00:00
|
|
|
len = a - prev;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len = a - prev + 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (!del) {
|
2011-11-07 12:55:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (del) {
|
|
|
|
|
if (segok) {
|
2012-03-25 23:19:21 +00:00
|
|
|
int t = len;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (markers[a].flag & MARKER_DISABLED) {
|
2011-11-07 12:55:18 +00:00
|
|
|
t++;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Place disabled marker in front of current segment. */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (start_disabled) {
|
2016-01-15 13:48:24 +05: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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05: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) {
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Current segment which would be deleted was finished by
|
|
|
|
|
* disabled marker, so next segment should be started from
|
|
|
|
|
* disabled marker.
|
|
|
|
|
*/
|
2012-03-25 23:19:21 +00:00
|
|
|
start_disabled = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
prev = -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-05 12:00:25 +01:00
|
|
|
if (del && count == 0) {
|
2018-01-08 14:10:50 +01:00
|
|
|
ok = 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (del) {
|
2011-11-07 12:55:18 +00:00
|
|
|
MEM_freeN(track->markers);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-25 23:19:21 +00:00
|
|
|
track->markersnr = count;
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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);
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingTrack *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");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if (error && action == TRACKING_CLEAN_DELETE_SEGMENT) {
|
2012-03-25 23:19:21 +00:00
|
|
|
action = TRACKING_CLEAN_DELETE_TRACK;
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
for (MovieTrackingTrack *track = tracksbase->first, *next_track; track != NULL;
|
|
|
|
|
track = next_track) {
|
|
|
|
|
next_track = track->next;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) {
|
2013-03-17 10:26:23 +00:00
|
|
|
bool ok;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) &&
|
|
|
|
|
((error == 0.0f) || (track->flag & TRACK_HAS_BUNDLE) == 0 || (track->error < error));
|
2019-04-17 06:17:24 +02: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) {
|
2016-01-15 13:48:24 +05:00
|
|
|
if (track == act_track) {
|
2012-03-25 23:19:21 +00:00
|
|
|
clip->tracking.act_track = NULL;
|
2016-01-15 13:48:24 +05: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/* Happens when all tracking segments are not long enough. */
|
2012-03-25 23:19:21 +00:00
|
|
|
if (track && track->markersnr == 0) {
|
2016-01-15 13:48:24 +05:00
|
|
|
if (track == act_track) {
|
2012-03-25 23:19:21 +00:00
|
|
|
clip->tracking.act_track = NULL;
|
2016-01-15 13:48:24 +05: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);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-23 10:02:37 +02:00
|
|
|
DEG_id_tag_update(&clip->id, 0);
|
2013-07-28 07:11:00 +00:00
|
|
|
BKE_tracking_dopesheet_tag_update(tracking);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-07 08:53:59 +00:00
|
|
|
WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05: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);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05: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);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05: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);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05: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);
|
2016-01-15 13:48:24 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
return clean_tracks_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CLIP_OT_clean_tracks(wmOperatorType *ot)
|
|
|
|
|
{
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem actions_items[] = {
|
2016-01-15 13:48:24 +05: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"},
|
2019-02-03 14:01:45 +11:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
2011-11-07 12:55:18 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-07 12:55:18 +00:00
|
|
|
/* flags */
|
2012-05-07 08:53:59 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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",
|
2016-01-15 13:48:24 +05:00
|
|
|
"Effect on tracks which are tracked less than "
|
|
|
|
|
"specified amount of frames",
|
|
|
|
|
0,
|
|
|
|
|
INT_MAX);
|
2012-04-14 15:44:31 +00:00
|
|
|
RNA_def_float(ot->srna,
|
|
|
|
|
"error",
|
|
|
|
|
0.0f,
|
|
|
|
|
0.0f,
|
|
|
|
|
FLT_MAX,
|
|
|
|
|
"Reprojection Error",
|
2020-12-24 13:11:22 -06:00
|
|
|
"Effect on tracks which have got larger reprojection error",
|
2016-01-15 13:48:24 +05:00
|
|
|
0.0f,
|
|
|
|
|
100.0f);
|
|
|
|
|
RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Cleanup action to execute");
|
2011-11-07 12:55:18 +00:00
|
|
|
}
|
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
|
|
|
|
2019-07-30 11:11:54 +02:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_COPY_ON_WRITE);
|
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) {
|
2016-01-15 13:48:24 +05: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
|
|
|
|
2019-07-30 11:11:54 +02:00
|
|
|
DEG_id_tag_update(&clip->id, ID_RECALC_COPY_ON_WRITE);
|
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
|
|
|
|
2016-01-15 14:02:26 +05:00
|
|
|
clip_tracking_clear_invisible_track_selection(sc, clip);
|
2012-01-09 20:18:48 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
/********************* paste tracks from clipboard operator ********************/
|
2012-01-09 20:18:48 +00:00
|
|
|
|
2018-07-02 11:47:00 +02:00
|
|
|
static bool paste_tracks_poll(bContext *C)
|
2012-01-09 20:18:48 +00:00
|
|
|
{
|
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);
|
2014-09-26 14:49:06 +06:00
|
|
|
ListBase *tracks_base = BKE_tracking_object_get_tracks(tracking, object);
|
2012-01-09 20:18:48 +00:00
|
|
|
|
2014-09-26 14:49:06 +06:00
|
|
|
BKE_tracking_tracks_deselect_all(tracks_base);
|
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
|
|
|
|
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;
|
|
|
|
|
int framenr = ED_space_clip_get_clip_frame_number(sc);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
ListBase *tracks_base = BKE_tracking_get_active_tracks(tracking);
|
|
|
|
|
for (MovieTrackingTrack *track = tracks_base->first; track != NULL; track = track->next) {
|
2013-09-09 11:55:52 +00:00
|
|
|
if (TRACK_VIEW_SELECTED(sc, track)) {
|
2013-09-17 08:58:12 +00:00
|
|
|
if (set) {
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_ensure(track, framenr);
|
2013-09-17 08:58:12 +00:00
|
|
|
marker->flag &= ~MARKER_TRACKED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
|
|
|
|
|
if (marker != NULL) {
|
2013-09-09 11:55:52 +00:00
|
|
|
marker->flag |= MARKER_TRACKED;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-09-09 11:55:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-15 13:48:24 +05:00
|
|
|
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
|
|
|
|
|
for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track != NULL;
|
|
|
|
|
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) {
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_ensure(plane_track,
|
|
|
|
|
framenr);
|
2013-09-17 08:58:12 +00:00
|
|
|
if (plane_marker->flag & PLANE_MARKER_TRACKED) {
|
|
|
|
|
plane_marker->flag &= ~PLANE_MARKER_TRACKED;
|
2016-01-15 13:48:24 +05:00
|
|
|
BKE_tracking_track_plane_from_existing_motion(plane_track, plane_marker->framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-09-09 11:55:52 +00:00
|
|
|
}
|
2013-09-17 08:58:12 +00:00
|
|
|
else {
|
2016-01-15 13:48:24 +05:00
|
|
|
MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get_exact(plane_track,
|
|
|
|
|
framenr);
|
2013-09-17 08:58:12 +00:00
|
|
|
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;
|
2016-01-15 13:48:24 +05:00
|
|
|
BKE_tracking_retrack_plane_from_existing_motion_at_segment(plane_track,
|
|
|
|
|
plane_marker->framenr);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-09-17 08:54:10 +00:00
|
|
|
}
|
2013-09-09 11:55:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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 */
|
2019-09-20 14:31:24 +02:00
|
|
|
ot->name = "Insert Keyframe";
|
2013-09-09 11:55:52 +00:00
|
|
|
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 */
|
2019-09-20 14:31:24 +02:00
|
|
|
ot->name = "Delete Keyframe";
|
2013-09-09 11:55:52 +00:00
|
|
|
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;
|
|
|
|
|
}
|