2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2011 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): Blender Foundation,
26 * ***** END GPL LICENSE BLOCK *****
29 /** \file DNA_tracking_types.h
32 * \author Sergey Sharybin
34 * Structs used for camera tracking and the movie-clip editor.
37 #ifndef __DNA_TRACKING_TYPES_H__
38 #define __DNA_TRACKING_TYPES_H__
41 #include "DNA_listBase.h"
43 /* match-moving data */
47 struct MovieReconstructedCamera;
48 struct MovieTrackingCamera;
49 struct MovieTrackingMarker;
50 struct MovieTrackingTrack;
53 typedef struct MovieReconstructedCamera {
57 } MovieReconstructedCamera;
59 typedef struct MovieTrackingCamera {
60 /** Intrinsics handle. */
63 short distortion_model;
66 /** Width of CCD sensor. */
68 /** Pixel aspect ratio. */
72 /** Units of focal length user is working with. */
75 /** Principal point. */
78 /* Polynomial distortion */
79 /** Polynomial radial distortion. */
82 /* Division distortion model coefficients */
83 float division_k1, division_k2;
84 } MovieTrackingCamera;
86 typedef struct MovieTrackingMarker {
87 /** 2d position of marker on frame (in unified 0..1 space). */
90 /* corners of pattern in the following order:
101 * the coordinates are stored relative to pos.
103 float pattern_corners[4][2];
105 /* positions of left-bottom and right-top corners of search area (in unified 0..1 units,
106 * relative to marker->pos
108 float search_min[2], search_max[2];
110 /** Number of frame marker is associated with. */
112 /** Marker's flag (alive, ...). */
114 } MovieTrackingMarker;
116 typedef struct MovieTrackingTrack {
117 struct MovieTrackingTrack *next, *prev;
124 /* positions of left-bottom and right-top corners of pattern (in unified 0..1 units,
125 * relative to marker->pos)
126 * moved to marker's corners since planar tracking implementation
128 float pat_min[2] DNA_DEPRECATED, pat_max[2] DNA_DEPRECATED;
130 /* positions of left-bottom and right-top corners of search area (in unified 0..1 units,
131 * relative to marker->pos
132 * moved to marker since affine tracking implementation
134 float search_min[2] DNA_DEPRECATED, search_max[2] DNA_DEPRECATED;
136 /** Offset to "parenting" point. */
140 /** Count of markers in track. */
142 /** Most recently used marker. */
144 /** Markers in track. */
145 MovieTrackingMarker *markers;
147 /* ** reconstruction data ** */
148 /** Reconstructed position. */
150 /** Average track reprojection error. */
153 /* ** UI editing ** */
154 /** Flags (selection, ...). */
155 int flag, pat_flag, search_flag;
156 /** Custom color for track. */
159 /* ** control how tracking happens */
161 * Number of frames to be tarcked during single tracking session
162 * (if TRACKING_FRAMES_LIMIT is set).
165 /** Margin from frame boundaries. */
167 /** Re-adjust every N frames. */
170 /* tracking parameters */
171 /** Model of the motion for this track. */
173 /** Flags for the tracking algorithm (use brute, use esm, use pyramid, etc. */
175 /** Minimal correlation which is still treated as successful tracking. */
176 float minimum_correlation;
178 /** Grease-pencil data. */
181 /* Weight of this track.
183 * Weight defines how much the track affects on the final reconstruction,
184 * usually gets animated in a way so when track has just appeared it's
185 * weight is zero and then it gets faded up.
187 * Used to prevent jumps of the camera when tracks are appearing or
192 /* track weight especially for 2D stabilization */
194 } MovieTrackingTrack;
196 typedef struct MovieTrackingPlaneMarker {
197 /* Corners of the plane in the following order:
208 * The coordinates are stored in frame normalized coordinates.
212 /** Number of frame plane marker is associated with. */
214 /** Marker's flag (alive, ...). */
216 } MovieTrackingPlaneMarker;
218 typedef struct MovieTrackingPlaneTrack {
219 struct MovieTrackingPlaneTrack *next, *prev;
225 * Array of point tracks used to define this pla.ne.
226 * Each element is a pointer to MovieTrackingTrack.
228 MovieTrackingTrack **point_tracks;
229 /** Number of tracks in point_tracks array. */
230 int point_tracksnr, pad;
232 /** Markers in the plane track. */
233 MovieTrackingPlaneMarker *markers;
234 /** Count of markers in track (size of markers array). */
237 /** Flags (selection, ...). */
240 /** Image displaying during editing. */
242 /** Opacity of the image. */
246 /** Most recently used marker. */
248 } MovieTrackingPlaneTrack;
250 typedef struct MovieTrackingSettings {
253 /* ** default tracker settings */
254 /** Model of the motion for this track. */
255 short default_motion_model;
256 /** Flags for the tracking algorithm (use brute, use esm, use pyramid, etc. */
257 short default_algorithm_flag;
258 /** Minimal correlation which is still treated as successful tracking. */
259 float default_minimum_correlation;
260 /** Size of pattern area for new tracks. */
261 short default_pattern_size;
262 /** Size of search area for new tracks. */
263 short default_search_size;
264 /** Number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set). */
265 short default_frames_limit;
266 /** Margin from frame boundaries. */
267 short default_margin;
268 /** Re-adjust every N frames. */
269 short default_pattern_match;
270 /** Default flags like color channels used by default. */
272 /** Default weight of the track. */
273 float default_weight;
275 /** Flags describes motion type. */
278 /* ** common tracker settings ** */
279 /** Speed of tracking. */
282 /* ** reconstruction settings ** */
283 /* two keyframes for reconstruction initialization
284 * were moved to per-tracking object settings
286 int keyframe1 DNA_DEPRECATED,
287 keyframe2 DNA_DEPRECATED;
289 int reconstruction_flag;
291 /* which camera intrinsics to refine. uses on the REFINE_* flags */
292 short refine_camera_intrinsics, pad2;
294 /* ** tool settings ** */
297 /** Distance between two bundles used for scene scaling. */
301 int clean_frames, clean_action;
304 /* set object scale */
305 /** Distance between two bundles used for object scaling. */
306 float object_distance;
309 } MovieTrackingSettings;
311 typedef struct MovieTrackingStabilization {
313 /** Total number of translation tracks and index of active track in list. */
314 int tot_track, act_track;
315 /** Total number of rotation tracks and index of active track in list. */
316 int tot_rot_track, act_rot_track;
318 /* 2d stabilization */
319 /** Max auto-scale factor. */
321 /** Use TRACK_USE_2D_STAB_ROT on individual tracks instead. */
322 MovieTrackingTrack *rot_track DNA_DEPRECATED;
324 /** Reference point to anchor stabilization offset. */
326 /** Expected target position of frame after raw stabilization, will be subtracted. */
328 /** Expected target rotation of frame after raw stabilization, will be compensated. */
330 /** Zoom factor known to be present on original footage. Also used for autoscale. */
333 /** Influence on location, scale and rotation. */
334 float locinf, scaleinf, rotinf;
336 /** Filter used for pixel interpolation. */
339 /* initialization and run-time data */
340 /** Without effect now, we initialize on every frame. Formerly used for caching of init values. */
341 int ok DNA_DEPRECATED;
342 } MovieTrackingStabilization;
344 typedef struct MovieTrackingReconstruction {
347 /** Average error of reconstruction. */
350 /** Most recently used camera. */
352 /** Number of reconstructed cameras. */
354 /** Reconstructed cameras. */
355 struct MovieReconstructedCamera *cameras;
356 } MovieTrackingReconstruction;
358 typedef struct MovieTrackingObject {
359 struct MovieTrackingObject *next, *prev;
361 /** Name of tracking object, MAX_NAME. */
364 /** Scale of object solution in amera space. */
367 /** List of tracks use to tracking this object. */
369 /** List of plane tracks used by this object. */
370 ListBase plane_tracks;
371 /** Reconstruction data for this object. */
372 MovieTrackingReconstruction reconstruction;
374 /* reconstruction options */
375 /** Two keyframes for reconstruction initialization. */
376 int keyframe1, keyframe2;
377 } MovieTrackingObject;
379 typedef struct MovieTrackingStats {
381 } MovieTrackingStats;
383 typedef struct MovieTrackingDopesheetChannel {
384 struct MovieTrackingDopesheetChannel *next, *prev;
386 /** Motion track for which channel is created. */
387 MovieTrackingTrack *track;
390 /** Name of channel. */
393 /** Total number of segments. */
395 /** Tracked segments. */
397 /** Longest segment length and total number of tracked frames. */
398 int max_segment, total_frames;
399 } MovieTrackingDopesheetChannel;
401 typedef struct MovieTrackingDopesheetCoverageSegment {
402 struct MovieTrackingDopesheetCoverageSegment *next, *prev;
409 } MovieTrackingDopesheetCoverageSegment;
411 typedef struct MovieTrackingDopesheet {
412 /** Flag if dopesheet information is still relevant. */
415 /** Method to be used to sort tracks. */
417 /** Dopesheet building flag such as inverted order of sort. */
420 /* ** runtime stuff ** */
423 ListBase coverage_segments;
430 } MovieTrackingDopesheet;
432 typedef struct MovieTracking {
433 /** Different tracking-related settings. */
434 MovieTrackingSettings settings;
435 /** Camera intrinsics. */
436 MovieTrackingCamera camera;
437 /** List of tracks used for camera object. */
439 /** List of plane tracks used by camera object. */
440 ListBase plane_tracks;
441 /** Reconstruction data for camera object. */
442 MovieTrackingReconstruction reconstruction;
443 /** Stabilization data. */
444 MovieTrackingStabilization stabilization;
446 MovieTrackingTrack *act_track;
447 /** Active plane track. */
448 MovieTrackingPlaneTrack *act_plane_track;
451 /** Index of active object and total number of objects. */
452 int objectnr, tot_object;
454 /** Statistics displaying in clip editor. */
455 MovieTrackingStats *stats;
457 /** Dopesheet data. */
458 MovieTrackingDopesheet dopesheet;
461 /* MovieTrackingCamera->distortion_model */
463 TRACKING_DISTORTION_MODEL_POLYNOMIAL = 0,
464 TRACKING_DISTORTION_MODEL_DIVISION = 1
467 /* MovieTrackingCamera->units */
473 /* MovieTrackingMarker->flag */
475 MARKER_DISABLED = (1 << 0),
476 MARKER_TRACKED = (1 << 1),
477 MARKER_GRAPH_SEL_X = (1 << 2),
478 MARKER_GRAPH_SEL_Y = (1 << 3),
479 MARKER_GRAPH_SEL = (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)
482 /* MovieTrackingTrack->flag */
484 TRACK_HAS_BUNDLE = (1 << 1),
485 TRACK_DISABLE_RED = (1 << 2),
486 TRACK_DISABLE_GREEN = (1 << 3),
487 TRACK_DISABLE_BLUE = (1 << 4),
488 TRACK_HIDDEN = (1 << 5),
489 TRACK_LOCKED = (1 << 6),
490 TRACK_CUSTOMCOLOR = (1 << 7),
491 TRACK_USE_2D_STAB = (1 << 8),
492 TRACK_PREVIEW_GRAYSCALE = (1 << 9),
493 TRACK_DOPE_SEL = (1 << 10),
494 TRACK_PREVIEW_ALPHA = (1 << 11),
495 TRACK_USE_2D_STAB_ROT = (1 << 12)
498 /* MovieTrackingTrack->motion_model */
500 TRACK_MOTION_MODEL_TRANSLATION = 0,
501 TRACK_MOTION_MODEL_TRANSLATION_ROTATION = 1,
502 TRACK_MOTION_MODEL_TRANSLATION_SCALE = 2,
503 TRACK_MOTION_MODEL_TRANSLATION_ROTATION_SCALE = 3,
504 TRACK_MOTION_MODEL_AFFINE = 4,
505 TRACK_MOTION_MODEL_HOMOGRAPHY = 5
508 /* MovieTrackingTrack->algorithm_flag */
510 TRACK_ALGORITHM_FLAG_USE_BRUTE = (1 << 0),
511 TRACK_ALGORITHM_FLAG_USE_NORMALIZATION = (1 << 2),
512 TRACK_ALGORITHM_FLAG_USE_MASK = (1 << 3)
515 /* MovieTrackingTrack->adjframes */
517 TRACK_MATCH_KEYFRAME = 0,
518 TRACK_MATCH_PREVFRAME = 1
521 /* MovieTrackingSettings->flag */
523 TRACKING_SETTINGS_SHOW_DEFAULT_EXPANDED = (1 << 0),
524 TRACKING_SETTINGS_SHOW_EXTRA_EXPANDED = (1 << 1)
527 /* MovieTrackingSettings->motion_flag */
529 TRACKING_MOTION_TRIPOD = (1 << 0),
531 TRACKING_MOTION_MODAL = (TRACKING_MOTION_TRIPOD)
534 /* MovieTrackingSettings->speed */
536 TRACKING_SPEED_FASTEST = 0,
537 TRACKING_SPEED_REALTIME = 1,
538 TRACKING_SPEED_HALF = 2,
539 TRACKING_SPEED_QUARTER = 4,
540 TRACKING_SPEED_DOUBLE = 5
543 /* MovieTrackingSettings->reconstruction_flag */
545 /* TRACKING_USE_FALLBACK_RECONSTRUCTION = (1 << 0), */ /* DEPRECATED */
546 TRACKING_USE_KEYFRAME_SELECTION = (1 << 1)
549 /* MovieTrackingSettings->refine_camera_intrinsics */
551 REFINE_FOCAL_LENGTH = (1 << 0),
552 REFINE_PRINCIPAL_POINT = (1 << 1),
553 REFINE_RADIAL_DISTORTION_K1 = (1 << 2),
554 REFINE_RADIAL_DISTORTION_K2 = (1 << 4)
557 /* MovieTrackingStrabilization->flag */
559 TRACKING_2D_STABILIZATION = (1 << 0),
560 TRACKING_AUTOSCALE = (1 << 1),
561 TRACKING_STABILIZE_ROTATION = (1 << 2),
562 TRACKING_STABILIZE_SCALE = (1 << 3),
563 TRACKING_SHOW_STAB_TRACKS = (1 << 5)
566 /* MovieTrackingStrabilization->filter */
568 TRACKING_FILTER_NEAREST = 0,
569 TRACKING_FILTER_BILINEAR = 1,
570 TRACKING_FILTER_BICUBIC = 2
573 /* MovieTrackingReconstruction->flag */
575 TRACKING_RECONSTRUCTED = (1 << 0)
578 /* MovieTrackingObject->flag */
580 TRACKING_OBJECT_CAMERA = (1 << 0)
584 TRACKING_CLEAN_SELECT = 0,
585 TRACKING_CLEAN_DELETE_TRACK = 1,
586 TRACKING_CLEAN_DELETE_SEGMENT = 2
589 /* MovieTrackingDopesheet->sort_method */
591 TRACKING_DOPE_SORT_NAME = 0,
592 TRACKING_DOPE_SORT_LONGEST = 1,
593 TRACKING_DOPE_SORT_TOTAL = 2,
594 TRACKING_DOPE_SORT_AVERAGE_ERROR = 3
597 /* MovieTrackingDopesheet->flag */
599 TRACKING_DOPE_SORT_INVERSE = (1 << 0),
600 TRACKING_DOPE_SELECTED_ONLY = (1 << 1),
601 TRACKING_DOPE_SHOW_HIDDEN = (1 << 2)
604 /* MovieTrackingDopesheetCoverageSegment->trackness */
606 TRACKING_COVERAGE_BAD = 0,
607 TRACKING_COVERAGE_ACCEPTABLE = 1,
608 TRACKING_COVERAGE_OK = 2
611 /* MovieTrackingPlaneMarker->flag */
613 PLANE_MARKER_DISABLED = (1 << 0),
614 PLANE_MARKER_TRACKED = (1 << 1),
617 /* MovieTrackingPlaneTrack->flag */
619 PLANE_TRACK_HIDDEN = (1 << 1),
620 PLANE_TRACK_LOCKED = (1 << 2),
621 PLANE_TRACK_AUTOKEY = (1 << 3),
624 #endif /* __DNA_TRACKING_TYPES_H__ */