4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation,
23 * ***** END GPL LICENSE BLOCK *****
26 /** \file blender/makesrna/intern/rna_tracking.c
34 #include "MEM_guardedalloc.h"
36 #include "BKE_movieclip.h"
37 #include "BKE_tracking.h"
39 #include "RNA_define.h"
41 #include "rna_internal.h"
43 #include "DNA_movieclip_types.h"
44 #include "DNA_scene_types.h"
50 #include "BKE_depsgraph.h"
53 #include "IMB_imbuf.h"
57 static void rna_tracking_tracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
59 MovieClip *clip= (MovieClip*)ptr->id.data;
60 rna_iterator_listbase_begin(iter, &clip->tracking.tracks, NULL);
63 static void rna_tracking_tracks_add(MovieTracking *tracking, int framenr, int number)
65 BKE_tracking_add_track(tracking, 0, 0, framenr, 1, 1);
66 WM_main_add_notifier(NC_MOVIECLIP|NA_EDITED, NULL);
69 static PointerRNA rna_tracking_active_track_get(PointerRNA *ptr)
71 MovieClip *clip= (MovieClip*)ptr->id.data;
73 return rna_pointer_inherit_refine(ptr, &RNA_MovieTrackingTrack, clip->tracking.act_track);
76 static void rna_tracking_active_track_set(PointerRNA *ptr, PointerRNA value)
78 MovieClip *clip= (MovieClip*)ptr->id.data;
79 MovieTrackingTrack *track= (MovieTrackingTrack *)value.data;
80 int index= BLI_findindex(&clip->tracking.tracks, track);
82 if(index>=0) clip->tracking.act_track= track;
83 else clip->tracking.act_track= NULL;
86 void rna_trackingTrack_name_get(PointerRNA *ptr, char *value)
88 MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
89 BLI_strncpy(value, track->name, sizeof(track->name));
92 int rna_trackingTrack_name_length(PointerRNA *ptr)
94 MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
95 return strlen(track->name);
98 void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value)
100 MovieClip *clip= (MovieClip *)ptr->id.data;
101 MovieTrackingTrack *track= (MovieTrackingTrack *)ptr->data;
102 BLI_strncpy(track->name, value, sizeof(track->name));
104 BKE_track_unique_name(&clip->tracking, track);
107 static void rna_tracking_trackerPattern_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
109 MovieClip *clip= (MovieClip*)ptr->id.data;
110 MovieTrackingTrack *track;
112 /* XXX: clamp modified marker only */
113 track= clip->tracking.tracks.first;
115 BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
120 static void rna_tracking_trackerSearch_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
122 MovieClip *clip= (MovieClip*)ptr->id.data;
123 MovieTrackingTrack *track;
125 /* XXX: clamp modified marker only */
126 track= clip->tracking.tracks.first;
128 BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
133 static float rna_trackingCamera_focal_get(PointerRNA *ptr)
135 MovieClip *clip= (MovieClip*)ptr->id.data;
136 MovieTrackingCamera *camera= &clip->tracking.camera;
137 float val= camera->focal;
139 if(camera->units==CAMERA_UNITS_MM) {
140 if(clip->lastsize[0])
141 val= val*camera->sensor_width/(float)clip->lastsize[0];
147 static void rna_trackingCamera_focal_set(PointerRNA *ptr, float value)
149 MovieClip *clip= (MovieClip*)ptr->id.data;
150 MovieTrackingCamera *camera= &clip->tracking.camera;
152 if(camera->units==CAMERA_UNITS_MM) {
153 if(clip->lastsize[0])
154 value= clip->lastsize[0]*value/camera->sensor_width;
157 camera->focal= value;
160 static int rna_track_2d_stabilization(CollectionPropertyIterator *UNUSED(iter), void *data)
162 MovieTrackingTrack *track= (MovieTrackingTrack*)data;
164 if((track->flag&TRACK_USE_2D_STAB)==0)
170 static void rna_tracking_stabTracks_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
172 MovieClip *clip= (MovieClip*)ptr->id.data;
173 rna_iterator_listbase_begin(iter, &clip->tracking.tracks, rna_track_2d_stabilization);
176 static int rna_tracking_stabTracks_active_index_get(PointerRNA *ptr)
178 MovieClip *clip= (MovieClip*)ptr->id.data;
179 return clip->tracking.stabilization.act_track;
182 static void rna_tracking_stabTracks_active_index_set(PointerRNA *ptr, int value)
184 MovieClip *clip= (MovieClip*)ptr->id.data;
185 clip->tracking.stabilization.act_track= value;
188 static void rna_tracking_stabTracks_active_index_range(PointerRNA *ptr, int *min, int *max)
190 MovieClip *clip= (MovieClip*)ptr->id.data;
193 *max= clip->tracking.stabilization.tot_track-1;
197 static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
199 MovieClip *clip= (MovieClip*)ptr->id.data;
200 MovieTrackingStabilization *stab= &clip->tracking.stabilization;
204 NodeTagIDChanged(scene->nodetree, &clip->id);
206 WM_main_add_notifier(NC_SCENE|ND_NODES, NULL);
207 DAG_id_tag_update(&clip->id, 0);
212 static MovieTrackingMarker *rna_trackingTrack_marker_get(MovieTrackingTrack *track, int framenr)
214 return BKE_tracking_get_marker(track, framenr);
219 static int rna_matrix_dimsize_4x4[]= {4, 4};
221 static void rna_def_trackingSettings(BlenderRNA *brna)
226 static EnumPropertyItem tracker_items[] = {
227 {TRACKER_KLT, "KLT", 0, "KLT", "Kanade–Lucas–Tomasi racker"},
228 {TRACKER_SAD, "SAD", 0, "SAD", "Sum of Absolute Differences tracker"},
229 {0, NULL, 0, NULL, NULL}};
231 static EnumPropertyItem speed_items[] = {
232 {0, "FASTEST", 0, "Fastest", "Track as fast as it's possible"},
233 {TRACKING_SPEED_DOUBLE, "DOUBLE", 0, "Double", "Track with double speed"},
234 {TRACKING_SPEED_REALTIME, "REALTIME", 0, "Realtime", "Track with realtime speed"},
235 {TRACKING_SPEED_HALF, "HALF", 0, "Half", "Track with half of realtime speed"},
236 {TRACKING_SPEED_QUARTER, "QUARTER", 0, "Quarter", "Track with quarter of realtime speed"},
237 {0, NULL, 0, NULL, NULL}};
239 static EnumPropertyItem cleanup_items[] = {
240 {TRACKING_CLEAN_SELECT, "SELECT", 0, "Select", "Select un-clean tracks"},
241 {TRACKING_CLEAN_DELETE_TRACK, "DELETE_TRACK", 0, "Delete Track", "Delete un-clean tracks"},
242 {TRACKING_CLEAN_DELETE_SEGMENT, "DELETE_SEGMENTS", 0, "Delete Segments", "Delete un-clean segments of tracks"},
243 {0, NULL, 0, NULL, NULL}
246 srna= RNA_def_struct(brna, "MovieTrackingSettings", NULL);
247 RNA_def_struct_ui_text(srna, "Movie tracking settings", "Match-moving tracking settings");
250 prop= RNA_def_property(srna, "tracker", PROP_ENUM, PROP_NONE);
251 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
252 RNA_def_property_enum_items(prop, tracker_items);
253 RNA_def_property_ui_text(prop, "tracker", "Tracking algorithm to use");
256 prop= RNA_def_property(srna, "speed", PROP_ENUM, PROP_NONE);
257 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
258 RNA_def_property_enum_items(prop, speed_items);
259 RNA_def_property_ui_text(prop, "Speed", "Speed to make tracking with");
262 prop= RNA_def_property(srna, "frames_limit", PROP_INT, PROP_NONE);
263 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
264 RNA_def_property_int_sdna(prop, NULL, "frames_limit");
265 RNA_def_property_range(prop, 0, INT_MAX);
266 RNA_def_property_ui_text(prop, "Frames Limit", "Amount of frames to be tracked during single tracking operation");
269 prop= RNA_def_property(srna, "adjust_frames", PROP_INT, PROP_NONE);
270 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
271 RNA_def_property_int_sdna(prop, NULL, "adjframes");
272 RNA_def_property_range(prop, 0, INT_MAX);
273 RNA_def_property_ui_text(prop, "Adjust Frames", "Automatically re-adjust marker position using position on each N frames. 0 means only keyframed position is sued.");
276 prop= RNA_def_property(srna, "margin", PROP_INT, PROP_NONE);
277 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
278 RNA_def_property_int_sdna(prop, NULL, "margin");
279 RNA_def_property_range(prop, 0, 300);
280 RNA_def_property_ui_text(prop, "Margin", "Margin for markers from image boundary.");
283 prop= RNA_def_property(srna, "keyframe1", PROP_INT, PROP_NONE);
284 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
285 RNA_def_property_int_sdna(prop, NULL, "keyframe1");
286 RNA_def_property_ui_text(prop, "Keyframe 1", "First keyframe used for reconstruction initialization");
289 prop= RNA_def_property(srna, "keyframe2", PROP_INT, PROP_NONE);
290 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
291 RNA_def_property_int_sdna(prop, NULL, "keyframe2");
292 RNA_def_property_ui_text(prop, "Keyframe 2", "Second keyframe used for reconstruction initialization");
294 /* minmal correlation */
295 prop= RNA_def_property(srna, "min_correlation", PROP_FLOAT, PROP_NONE);
296 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
297 RNA_def_property_float_sdna(prop, NULL, "corr");
298 RNA_def_property_range(prop, -1.0f, 1.0f);
299 RNA_def_property_ui_range(prop, -1.f, 1.f, .1, 3);
300 RNA_def_property_ui_text(prop, "Correlation", "Minimal value of correlation between mathed pattern and reference which is still treated as successful tracking");
305 prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
306 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
307 RNA_def_property_float_sdna(prop, NULL, "dist");
308 RNA_def_property_ui_text(prop, "Distance", "Distance between two bundles used for scene scaling");
311 prop= RNA_def_property(srna, "clean_frames", PROP_INT, PROP_NONE);
312 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
313 RNA_def_property_int_sdna(prop, NULL, "clean_frames");
314 RNA_def_property_range(prop, 0, INT_MAX);
315 RNA_def_property_ui_text(prop, "Tracked Frames", "Affect on tracks which are tracked less than specified amount of frames");
317 /* reprojection error */
318 prop= RNA_def_property(srna, "clean_error", PROP_FLOAT, PROP_NONE);
319 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
320 RNA_def_property_float_sdna(prop, NULL, "clean_error");
321 RNA_def_property_range(prop, 0, FLT_MAX);
322 RNA_def_property_ui_text(prop, "Reprojection Error", "Affect on tracks with have got larger reprojection error");
325 prop= RNA_def_property(srna, "clean_action", PROP_ENUM, PROP_NONE);
326 RNA_def_property_enum_sdna(prop, NULL, "clean_action");
327 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
328 RNA_def_property_enum_items(prop, cleanup_items);
329 RNA_def_property_ui_text(prop, "Action", "Cleanup action to execute");
332 static void rna_def_trackingCamera(BlenderRNA *brna)
337 static EnumPropertyItem camera_units_items[] = {
338 {CAMERA_UNITS_PX, "PIXELS", 0, "px", "Use pixels for units of focal length"},
339 {CAMERA_UNITS_MM, "MILLIMETERS", 0, "mm", "Use millimeters for units of focal length"},
340 {0, NULL, 0, NULL, NULL}};
342 srna= RNA_def_struct(brna, "MovieTrackingCamera", NULL);
343 RNA_def_struct_ui_text(srna, "Movie tracking camera data", "Match-moving camera data for tracking");
346 prop= RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_NONE);
347 RNA_def_property_float_sdna(prop, NULL, "sensor_width");
348 RNA_def_property_range(prop, 0.0f, 500.0f);
349 RNA_def_property_ui_text(prop, "Sensor", "Width of CCD sensor in millimeters");
350 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
353 prop= RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_NONE);
354 RNA_def_property_float_sdna(prop, NULL, "focal");
355 RNA_def_property_range(prop, 0.0f, 5000.0f);
356 RNA_def_property_ui_text(prop, "Focal Length", "Camera's focal length in pixels");
357 RNA_def_property_float_funcs(prop, "rna_trackingCamera_focal_get", "rna_trackingCamera_focal_set", NULL);
358 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
361 prop= RNA_def_property(srna, "units", PROP_ENUM, PROP_NONE);
362 RNA_def_property_enum_sdna(prop, NULL, "units");
363 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
364 RNA_def_property_enum_items(prop, camera_units_items);
365 RNA_def_property_ui_text(prop, "Units", "Units used for camera focal length");
367 /* Principal Point */
368 prop= RNA_def_property(srna, "principal", PROP_FLOAT, PROP_NONE);
369 RNA_def_property_array(prop, 2);
370 RNA_def_property_float_sdna(prop, NULL, "principal");
371 RNA_def_property_ui_text(prop, "Principal Point", "Optical center of lens");
372 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
374 /* Radial distortion parameters */
375 prop= RNA_def_property(srna, "k1", PROP_FLOAT, PROP_NONE);
376 RNA_def_property_float_sdna(prop, NULL, "k1");
377 RNA_def_property_ui_range(prop, -10, 10, .1, 3);
378 RNA_def_property_ui_text(prop, "K1", "");
379 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
381 prop= RNA_def_property(srna, "k2", PROP_FLOAT, PROP_NONE);
382 RNA_def_property_float_sdna(prop, NULL, "k2");
383 RNA_def_property_ui_range(prop, -10, 10, .1, 3);
384 RNA_def_property_ui_text(prop, "K2", "");
385 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
387 prop= RNA_def_property(srna, "k3", PROP_FLOAT, PROP_NONE);
388 RNA_def_property_float_sdna(prop, NULL, "k3");
389 RNA_def_property_ui_range(prop, -10, 10, .1, 3);
390 RNA_def_property_ui_text(prop, "K3", "");
391 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
394 prop= RNA_def_property(srna, "pixel_aspect", PROP_FLOAT, PROP_XYZ);
395 RNA_def_property_float_sdna(prop, NULL, "pixel_aspect");
396 RNA_def_property_range(prop, 0.1f, 5000.0f);
397 RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
398 RNA_def_property_ui_text(prop, "Pixel Aspect", "Pixel aspect ratio");
399 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
402 static void rna_def_trackingMarker(BlenderRNA *brna)
407 srna= RNA_def_struct(brna, "MovieTrackingMarker", NULL);
408 RNA_def_struct_ui_text(srna, "Movie tracking marker data", "Match-moving marker data for tracking");
411 prop= RNA_def_property(srna, "pos", PROP_FLOAT, PROP_TRANSLATION);
412 RNA_def_property_array(prop, 2);
413 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
414 RNA_def_property_float_sdna(prop, NULL, "pos");
415 RNA_def_property_ui_text(prop, "Position", "Marker position at frame in unified coordinates");
416 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
419 prop= RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
420 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* can't be safty edited for now, need to re-sort markers array after change */
421 RNA_def_property_int_sdna(prop, NULL, "framenr");
422 RNA_def_property_ui_text(prop, "Frame", "Frame number marker is keyframed on");
423 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
426 prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
427 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MARKER_DISABLED);
428 RNA_def_property_ui_text(prop, "Enabled", "Is marker enabled for current frame");
429 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
432 static void rna_def_trackingTrack(BlenderRNA *brna)
440 rna_def_trackingMarker(brna);
442 srna= RNA_def_struct(brna, "MovieTrackingTrack", NULL);
443 RNA_def_struct_ui_text(srna, "Movie tracking track data", "Match-moving track data for tracking");
444 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
447 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
448 RNA_def_property_ui_text(prop, "Name", "Unique name of track");
449 RNA_def_property_string_funcs(prop, "rna_trackingTrack_name_get", "rna_trackingTrack_name_length", "rna_trackingTrack_name_set");
450 RNA_def_property_string_maxlength(prop, MAX_ID_NAME);
451 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
452 RNA_def_struct_name_property(srna, prop);
455 prop= RNA_def_property(srna, "pattern_min", PROP_FLOAT, PROP_TRANSLATION);
456 RNA_def_property_array(prop, 2);
457 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
458 RNA_def_property_float_sdna(prop, NULL, "pat_min");
459 RNA_def_property_ui_text(prop, "Pattern Min", "Left-bottom corner of pattern area in unified coordinates relative to marker position");
460 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerPattern_update");
462 prop= RNA_def_property(srna, "pattern_max", PROP_FLOAT, PROP_TRANSLATION);
463 RNA_def_property_array(prop, 2);
464 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
465 RNA_def_property_float_sdna(prop, NULL, "pat_max");
466 RNA_def_property_ui_text(prop, "Pattern Max", "Right-bottom corner of pattern area in unified coordinates relative to marker position");
467 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerPattern_update");
470 prop= RNA_def_property(srna, "search_min", PROP_FLOAT, PROP_TRANSLATION);
471 RNA_def_property_array(prop, 2);
472 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
473 RNA_def_property_float_sdna(prop, NULL, "search_min");
474 RNA_def_property_ui_text(prop, "Search Min", "Left-bottom corner of search area in unified coordinates relative to marker position");
475 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerSearch_update");
477 prop= RNA_def_property(srna, "search_max", PROP_FLOAT, PROP_TRANSLATION);
478 RNA_def_property_array(prop, 2);
479 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 5);
480 RNA_def_property_float_sdna(prop, NULL, "search_max");
481 RNA_def_property_ui_text(prop, "Search Max", "Right-bottom corner of search area in unified coordinates relative to marker position");
482 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerSearch_update");
485 prop= RNA_def_property(srna, "markers_count", PROP_INT, PROP_NONE);
486 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
487 RNA_def_property_int_sdna(prop, NULL, "markersnr");
488 RNA_def_property_ui_text(prop, "Markers Count", "Total number of markers in track");
491 prop= RNA_def_property(srna, "markers", PROP_COLLECTION, PROP_NONE);
492 RNA_def_property_struct_type(prop, "MovieTrackingMarker");
493 RNA_def_property_collection_sdna(prop, NULL, "markers", "markersnr");
494 RNA_def_property_ui_text(prop, "Markers", "Collection of markers in track");
498 /* use_red_channel */
499 prop= RNA_def_property(srna, "use_red_channel", PROP_BOOLEAN, PROP_NONE);
500 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_RED);
501 RNA_def_property_ui_text(prop, "Use Red Channel", "Use red channel from footage for tracking");
502 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
504 /* use_green_channel */
505 prop= RNA_def_property(srna, "use_green_channel", PROP_BOOLEAN, PROP_NONE);
506 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_GREEN);
507 RNA_def_property_ui_text(prop, "Use Green Channel", "Use green channel from footage for tracking");
508 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
510 /* use_blue_channel */
511 prop= RNA_def_property(srna, "use_blue_channel", PROP_BOOLEAN, PROP_NONE);
512 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TRACK_DISABLE_BLUE);
513 RNA_def_property_ui_text(prop, "Use Blue Channel", "Use blue channel from footage for tracking");
514 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
517 prop= RNA_def_property(srna, "has_bundle", PROP_BOOLEAN, PROP_NONE);
518 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_HAS_BUNDLE);
519 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
520 RNA_def_property_ui_text(prop, "Has Bundle", "True if track has a valid bundle");
522 /* bundle position */
523 prop= RNA_def_property(srna, "bundle", PROP_FLOAT, PROP_TRANSLATION);
524 RNA_def_property_array(prop, 3);
525 RNA_def_property_float_sdna(prop, NULL, "bundle_pos");
526 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
527 RNA_def_property_ui_text(prop, "Bundle", "Position of bundle reconstructed from this tarck");
530 prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
531 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_HIDDEN);
532 RNA_def_property_ui_text(prop, "Hidden", "Track is hidden");
533 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
536 prop= RNA_def_property(srna, "locked", PROP_BOOLEAN, PROP_NONE);
537 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_LOCKED);
538 RNA_def_property_ui_text(prop, "Locked", "Track is locked and all changes to it are disabled");
539 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
542 prop= RNA_def_property(srna, "use_custom_color", PROP_BOOLEAN, PROP_NONE);
543 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACK_CUSTOMCOLOR);
544 RNA_def_property_ui_text(prop, "Custom Color", "Use custom color instead of theme-defined");
545 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
548 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
549 RNA_def_property_array(prop, 3);
550 RNA_def_property_range(prop, 0.0f, 1.0f);
551 RNA_def_property_ui_text(prop, "Color", "Color of the track in the Clip Editor");
552 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL);
555 prop= RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE);
556 RNA_def_property_float_sdna(prop, NULL, "error");
557 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
558 RNA_def_property_ui_text(prop, "Average Error", "Average error of re-projection");
562 func= RNA_def_function(srna, "get_marker", "rna_trackingTrack_marker_get");
563 RNA_def_function_ui_description(func, "Get marker for specified frame.");
564 parm= RNA_def_int(func, "frame", 1, MINFRAME, MAXFRAME, "Frame", "type for the new spline.", MINFRAME, MAXFRAME);
565 RNA_def_property_flag(parm, PROP_REQUIRED);
566 parm= RNA_def_pointer(func, "marker", "MovieTrackingMarker", "", "Marker for specified frame.");
567 RNA_def_function_return(func, parm);
570 static void rna_def_trackingStabilization(BlenderRNA *brna)
575 srna= RNA_def_struct(brna, "MovieTrackingStabilization", NULL);
576 RNA_def_struct_ui_text(srna, "Movie tracking stabilization data", "Match-moving stabilization data for tracking");
578 /* 2d stabilization */
579 prop= RNA_def_property(srna, "use_2d_stabilization", PROP_BOOLEAN, PROP_NONE);
580 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_2D_STABILIZATION);
581 RNA_def_property_ui_text(prop, "Use 2D stabilization", "Use 2D stabilization for footage");
582 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
585 prop= RNA_def_property(srna, "tracks", PROP_COLLECTION, PROP_NONE);
586 RNA_def_property_collection_funcs(prop, "rna_tracking_stabTracks_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
587 RNA_def_property_struct_type(prop, "MovieTrackingTrack");
588 RNA_def_property_ui_text(prop, "Tracks", "Collection of tracks used for stabilization");
589 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
592 prop= RNA_def_property(srna, "rotation_track", PROP_POINTER, PROP_NONE);
593 RNA_def_property_pointer_sdna(prop, NULL, "rot_track");
594 RNA_def_property_flag(prop, PROP_EDITABLE);
595 RNA_def_property_ui_text(prop, "Rotation Track", "Track used to compensate rotation");
596 RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_flushUpdate");
598 /* active track index */
599 prop= RNA_def_property(srna, "active_track_index", PROP_INT, PROP_NONE);
600 RNA_def_property_int_sdna(prop, NULL, "act_track");
601 RNA_def_property_int_funcs(prop, "rna_tracking_stabTracks_active_index_get", "rna_tracking_stabTracks_active_index_set", "rna_tracking_stabTracks_active_index_range");
602 RNA_def_property_ui_text(prop, "Active Track Index", "Index of active track in stabilization tracks list");
605 prop= RNA_def_property(srna, "use_autoscale", PROP_BOOLEAN, PROP_NONE);
606 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_AUTOSCALE);
607 RNA_def_property_ui_text(prop, "Autoscale", "Automatically scale footage to cover unfilled areas when stabilizating");
608 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
611 prop= RNA_def_property(srna, "max_scale", PROP_FLOAT, PROP_FACTOR);
612 RNA_def_property_float_sdna(prop, NULL, "maxscale");
613 RNA_def_property_range(prop, 0.f, 10.f);
614 RNA_def_property_ui_text(prop, "Miximal Scale", "Maximal value for scale factor");
615 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
617 /* influence_location */
618 prop= RNA_def_property(srna, "influence_location", PROP_FLOAT, PROP_FACTOR);
619 RNA_def_property_float_sdna(prop, NULL, "locinf");
620 RNA_def_property_range(prop, 0.f, 1.f);
621 RNA_def_property_ui_text(prop, "Location Influence", "Influence of stabilization algorithm on footage location");
622 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
624 /* influence_scale */
625 prop= RNA_def_property(srna, "influence_scale", PROP_FLOAT, PROP_FACTOR);
626 RNA_def_property_float_sdna(prop, NULL, "scaleinf");
627 RNA_def_property_range(prop, 0.f, 1.f);
628 RNA_def_property_ui_text(prop, "Scale Influence", "Influence of stabilization algorithm on footage scale");
629 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
631 /* influence_rotation */
632 prop= RNA_def_property(srna, "influence_rotation", PROP_FLOAT, PROP_FACTOR);
633 RNA_def_property_float_sdna(prop, NULL, "rotinf");
634 RNA_def_property_range(prop, 0.f, 1.f);
635 RNA_def_property_ui_text(prop, "Rotation Influence", "Influence of stabilization algorithm on footage rotation");
636 RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, "rna_tracking_flushUpdate");
639 static void rna_def_reconstructedCamera(BlenderRNA *brna)
644 srna= RNA_def_struct(brna, "MovieReconstructedCamera", NULL);
645 RNA_def_struct_ui_text(srna, "Movie tracking reconstructed camera data", "Match-moving reconstructed camera data from tracker");
648 prop= RNA_def_property(srna, "frame", PROP_INT, PROP_NONE);
649 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
650 RNA_def_property_int_sdna(prop, NULL, "framenr");
651 RNA_def_property_ui_text(prop, "Frame", "Frame number marker is keyframed on");
654 prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX);
655 RNA_def_property_float_sdna(prop, NULL, "mat");
656 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
657 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
658 RNA_def_property_ui_text(prop, "Matrix", "Worldspace transformation matrix");
661 static void rna_def_trackingReconstruction(BlenderRNA *brna)
666 rna_def_reconstructedCamera(brna);
668 srna= RNA_def_struct(brna, "MovieTrackingReconstruction", NULL);
669 RNA_def_struct_ui_text(srna, "Movie tracking reconstruction data", "Match-moving reconstruction data from tracker");
671 /* is_reconstructed */
672 prop= RNA_def_property(srna, "is_reconstructed", PROP_BOOLEAN, PROP_NONE);
673 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
674 RNA_def_property_boolean_sdna(prop, NULL, "flag", TRACKING_RECONSTRUCTED);
675 RNA_def_property_ui_text(prop, "Reconstructed", "Is tracking data contsains valid reconstruction information");
678 prop= RNA_def_property(srna, "average_error", PROP_FLOAT, PROP_NONE);
679 RNA_def_property_float_sdna(prop, NULL, "error");
680 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
681 RNA_def_property_ui_text(prop, "Average Error", "Average error of resonctruction");
684 prop= RNA_def_property(srna, "cameras", PROP_COLLECTION, PROP_NONE);
685 RNA_def_property_struct_type(prop, "MovieReconstructedCamera");
686 RNA_def_property_collection_sdna(prop, NULL, "cameras", "camnr");
687 RNA_def_property_ui_text(prop, "Cameras", "Collection of solved cameras");
690 static void rna_def_trackingTracks(BlenderRNA *brna, PropertyRNA *cprop)
695 RNA_def_property_srna(cprop, "MovieTrackingTracks");
696 srna= RNA_def_struct(brna, "MovieTrackingTracks", NULL);
697 RNA_def_struct_sdna(srna, "MovieTracking");
698 RNA_def_struct_ui_text(srna, "Movie Tracks", "Collection of movie tracking tracks");
700 func= RNA_def_function(srna, "add", "rna_tracking_tracks_add");
701 RNA_def_function_ui_description(func, "Add a number of tracks to this movie clip.");
702 RNA_def_int(func, "framenr", 1, MINFRAME, MAXFRAME, "Frame", "Frame number to add tracks on", MINFRAME, MAXFRAME);
703 RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of tracks to add to the movie clip", 0, INT_MAX);
706 static void rna_def_tracking(BlenderRNA *brna)
711 rna_def_trackingSettings(brna);
712 rna_def_trackingCamera(brna);
713 rna_def_trackingTrack(brna);
714 rna_def_trackingStabilization(brna);
715 rna_def_trackingReconstruction(brna);
717 srna= RNA_def_struct(brna, "MovieTracking", NULL);
718 RNA_def_struct_ui_text(srna, "Movie tracking data", "Match-moving data for tracking");
721 prop= RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
722 RNA_def_property_struct_type(prop, "MovieTrackingSettings");
724 /* camera properties */
725 prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
726 RNA_def_property_struct_type(prop, "MovieTrackingCamera");
729 prop= RNA_def_property(srna, "tracks", PROP_COLLECTION, PROP_NONE);
730 RNA_def_property_collection_funcs(prop, "rna_tracking_tracks_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
731 RNA_def_property_struct_type(prop, "MovieTrackingTrack");
732 RNA_def_property_ui_text(prop, "Tracks", "Collection of tracks in this tracking data object");
733 rna_def_trackingTracks(brna, prop);
736 prop= RNA_def_property(srna, "active_track", PROP_POINTER, PROP_NONE);
737 RNA_def_property_struct_type(prop, "MovieTrackingTrack");
738 RNA_def_property_pointer_funcs(prop, "rna_tracking_active_track_get", "rna_tracking_active_track_set", NULL, NULL);
739 RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK);
740 RNA_def_property_ui_text(prop, "Active Track", "Active track in this tracking data object");
743 prop= RNA_def_property(srna, "stabilization", PROP_POINTER, PROP_NONE);
744 RNA_def_property_struct_type(prop, "MovieTrackingStabilization");
747 prop= RNA_def_property(srna, "reconstruction", PROP_POINTER, PROP_NONE);
748 RNA_def_property_struct_type(prop, "MovieTrackingReconstruction");
751 void RNA_def_tracking(BlenderRNA *brna)
753 rna_def_tracking(brna);