Blender  V3.3
tracking.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. All rights reserved. */
3 
8 #include <limits.h>
9 #include <math.h>
10 #include <memory.h>
11 #include <stddef.h>
12 
13 #include "MEM_guardedalloc.h"
14 
15 #include "DNA_anim_types.h"
16 #include "DNA_camera_types.h"
17 #include "DNA_gpencil_types.h"
18 #include "DNA_movieclip_types.h"
19 #include "DNA_object_types.h" /* SELECT */
20 #include "DNA_scene_types.h"
21 
22 #include "BLI_bitmap_draw_2d.h"
23 #include "BLI_ghash.h"
24 #include "BLI_listbase.h"
25 #include "BLI_math.h"
26 #include "BLI_math_base.h"
27 #include "BLI_string.h"
28 #include "BLI_string_utils.h"
29 #include "BLI_threads.h"
30 #include "BLI_utildefines.h"
31 
32 #include "BLT_translation.h"
33 
34 #include "BKE_fcurve.h"
35 #include "BKE_layer.h"
36 #include "BKE_lib_id.h"
37 #include "BKE_movieclip.h"
38 #include "BKE_object.h"
39 #include "BKE_scene.h"
40 #include "BKE_tracking.h"
41 
42 #include "IMB_imbuf.h"
43 #include "IMB_imbuf_types.h"
44 
45 #include "RNA_access.h"
46 #include "RNA_prototypes.h"
47 
48 #include "libmv-capi.h"
49 #include "tracking_private.h"
50 
51 typedef struct MovieDistortion {
53  /* Parameters needed for coordinates normalization. */
54  float principal[2];
55  float pixel_aspect;
56  float focal;
58 
59 static struct {
62 
63 /* --------------------------------------------------------------------
64  * Common functions.
65  */
66 
67 /* Free the whole list of tracks, list's head and tail are set to NULL. */
69 {
72  }
73 
75 }
76 
77 /* Free the whole list of plane tracks, list's head and tail are set to NULL. */
78 static void tracking_plane_tracks_free(ListBase *plane_tracks)
79 {
80  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks) {
81  BKE_tracking_plane_track_free(plane_track);
82  }
83 
84  BLI_freelistN(plane_tracks);
85 }
86 
87 /* Free reconstruction structures, only frees contents of a structure,
88  * (if structure is allocated in heap, it shall be handled outside).
89  *
90  * All the pointers inside structure becomes invalid after this call.
91  */
93 {
94  if (reconstruction->cameras) {
95  MEM_freeN(reconstruction->cameras);
96  }
97 }
98 
99 /* Free memory used by tracking object, only frees contents of the structure,
100  * (if structure is allocated in heap, it shall be handled outside).
101  *
102  * All the pointers inside structure becomes invalid after this call.
103  */
105 {
106  tracking_tracks_free(&object->tracks);
109 }
110 
111 /* Free list of tracking objects, list's head and tail is set to NULL. */
112 static void tracking_objects_free(ListBase *objects)
113 {
114  /* Free objects contents. */
115  LISTBASE_FOREACH (MovieTrackingObject *, object, objects) {
116  tracking_object_free(object);
117  }
118 
119  /* Free objects themselves. */
120  BLI_freelistN(objects);
121 }
122 
123 /* Free memory used by a dopesheet, only frees dopesheet contents.
124  * leaving dopesheet crystal clean for further usage.
125  */
127 {
129 
130  /* Free channel's segments. */
131  channel = dopesheet->channels.first;
132  while (channel) {
133  if (channel->segments) {
134  MEM_freeN(channel->segments);
135  }
136 
137  channel = channel->next;
138  }
139 
140  /* Free lists themselves. */
141  BLI_freelistN(&dopesheet->channels);
142  BLI_freelistN(&dopesheet->coverage_segments);
143 
144  /* Ensure lists are clean. */
145  BLI_listbase_clear(&dopesheet->channels);
147  dopesheet->tot_channel = 0;
148 }
149 
151 {
152  tracking_tracks_free(&tracking->tracks);
155  tracking_objects_free(&tracking->objects);
156 
157  if (tracking->camera.intrinsics) {
159  }
160 
162 }
163 
164 /* Copy the whole list of tracks. */
165 static void tracking_tracks_copy(ListBase *tracks_dst,
166  const ListBase *tracks_src,
167  GHash *tracks_mapping,
168  const int flag)
169 {
170  BLI_listbase_clear(tracks_dst);
171  BLI_ghash_clear(tracks_mapping, NULL, NULL);
172 
173  LISTBASE_FOREACH (MovieTrackingTrack *, track_src, tracks_src) {
174  MovieTrackingTrack *track_dst = MEM_dupallocN(track_src);
175  if (track_src->markers) {
176  track_dst->markers = MEM_dupallocN(track_src->markers);
177  }
178  if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
179  id_us_plus(&track_dst->gpd->id);
180  }
181  BLI_addtail(tracks_dst, track_dst);
182  BLI_ghash_insert(tracks_mapping, track_src, track_dst);
183  }
184 }
185 
186 /* Copy the whole list of plane tracks
187  * (need whole MovieTracking structures due to embedded pointers to tracks).
188  * WARNING: implies tracking_[dst/src] and their tracks have already been copied. */
189 static void tracking_plane_tracks_copy(ListBase *plane_tracks_list_dst,
190  const ListBase *plane_tracks_list_src,
191  GHash *tracks_mapping,
192  const int flag)
193 {
194  BLI_listbase_clear(plane_tracks_list_dst);
195 
196  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track_src, plane_tracks_list_src) {
197  MovieTrackingPlaneTrack *plane_track_dst = MEM_dupallocN(plane_track_src);
198  if (plane_track_src->markers) {
199  plane_track_dst->markers = MEM_dupallocN(plane_track_src->markers);
200  }
201  plane_track_dst->point_tracks = MEM_mallocN(
202  sizeof(*plane_track_dst->point_tracks) * plane_track_dst->point_tracksnr, __func__);
203  for (int i = 0; i < plane_track_dst->point_tracksnr; i++) {
204  plane_track_dst->point_tracks[i] = BLI_ghash_lookup(tracks_mapping,
205  plane_track_src->point_tracks[i]);
206  }
207  if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
208  id_us_plus(&plane_track_dst->image->id);
209  }
210  BLI_addtail(plane_tracks_list_dst, plane_track_dst);
211  }
212 }
213 
214 /* Copy reconstruction structure. */
216  const MovieTrackingReconstruction *reconstruction_src,
217  const int UNUSED(flag))
218 {
219  *reconstruction_dst = *reconstruction_src;
220  if (reconstruction_src->cameras) {
221  reconstruction_dst->cameras = MEM_dupallocN(reconstruction_src->cameras);
222  }
223 }
224 
225 /* Copy stabilization structure. */
227  const MovieTrackingStabilization *stabilization_src,
228  const int UNUSED(flag))
229 {
230  *stabilization_dst = *stabilization_src;
231 }
232 
233 /* Copy tracking object. */
235  const MovieTrackingObject *object_src,
236  GHash *tracks_mapping,
237  const int flag)
238 {
239  *object_dst = *object_src;
240  tracking_tracks_copy(&object_dst->tracks, &object_src->tracks, tracks_mapping, flag);
242  &object_dst->plane_tracks, &object_src->plane_tracks, tracks_mapping, flag);
243  tracking_reconstruction_copy(&object_dst->reconstruction, &object_src->reconstruction, flag);
244 }
245 
246 /* Copy list of tracking objects. */
247 static void tracking_objects_copy(ListBase *objects_dst,
248  const ListBase *objects_src,
249  GHash *tracks_mapping,
250  const int flag)
251 {
252  BLI_listbase_clear(objects_dst);
253 
254  LISTBASE_FOREACH (MovieTrackingObject *, object_src, objects_src) {
255  MovieTrackingObject *object_dst = MEM_mallocN(sizeof(*object_dst), __func__);
256  tracking_object_copy(object_dst, object_src, tracks_mapping, flag);
257  BLI_addtail(objects_dst, object_dst);
258  }
259 }
260 
261 void BKE_tracking_copy(MovieTracking *tracking_dst,
262  const MovieTracking *tracking_src,
263  const int flag)
264 {
265  GHash *tracks_mapping = BLI_ghash_ptr_new(__func__);
266 
267  *tracking_dst = *tracking_src;
268 
269  tracking_tracks_copy(&tracking_dst->tracks, &tracking_src->tracks, tracks_mapping, flag);
271  &tracking_dst->plane_tracks, &tracking_src->plane_tracks, tracks_mapping, flag);
272  tracking_reconstruction_copy(&tracking_dst->reconstruction, &tracking_src->reconstruction, flag);
273  tracking_stabilization_copy(&tracking_dst->stabilization, &tracking_src->stabilization, flag);
274  if (tracking_src->act_track) {
275  tracking_dst->act_track = BLI_ghash_lookup(tracks_mapping, tracking_src->act_track);
276  }
277  if (tracking_src->act_plane_track) {
278  MovieTrackingPlaneTrack *plane_track_src, *plane_track_dst;
279  for (plane_track_src = tracking_src->plane_tracks.first,
280  plane_track_dst = tracking_dst->plane_tracks.first;
281  !ELEM(NULL, plane_track_src, plane_track_dst);
282  plane_track_src = plane_track_src->next, plane_track_dst = plane_track_dst->next) {
283  if (plane_track_src == tracking_src->act_plane_track) {
284  tracking_dst->act_plane_track = plane_track_dst;
285  break;
286  }
287  }
288  }
289 
290  /* Warning! Will override tracks_mapping. */
291  tracking_objects_copy(&tracking_dst->objects, &tracking_src->objects, tracks_mapping, flag);
292 
293  /* Those remaining are runtime data, they will be reconstructed as needed,
294  * do not bother copying them. */
295  tracking_dst->dopesheet.ok = false;
296  BLI_listbase_clear(&tracking_dst->dopesheet.channels);
298 
299  tracking_dst->camera.intrinsics = NULL;
300  tracking_dst->stats = NULL;
301 
302  BLI_ghash_free(tracks_mapping, NULL, NULL);
303 }
304 
306 {
307  tracking->camera.sensor_width = 35.0f;
308  tracking->camera.pixel_aspect = 1.0f;
309  tracking->camera.units = CAMERA_UNITS_MM;
310 
312  tracking->settings.default_minimum_correlation = 0.75;
313  tracking->settings.default_pattern_size = 21;
314  tracking->settings.default_search_size = 71;
316  tracking->settings.default_weight = 1.0f;
317  tracking->settings.dist = 1;
318  tracking->settings.object_distance = 1;
320 
321  tracking->stabilization.scaleinf = 1.0f;
322  tracking->stabilization.anchor_frame = 1;
323  zero_v2(tracking->stabilization.target_pos);
324  tracking->stabilization.target_rot = 0.0f;
325  tracking->stabilization.scale = 1.0f;
326 
327  tracking->stabilization.act_track = 0;
328  tracking->stabilization.act_rot_track = 0;
329  tracking->stabilization.tot_track = 0;
330  tracking->stabilization.tot_rot_track = 0;
331 
332  tracking->stabilization.scaleinf = 1.0f;
333  tracking->stabilization.locinf = 1.0f;
334  tracking->stabilization.rotinf = 1.0f;
335  tracking->stabilization.maxscale = 2.0f;
338 
339  /* Descending order of average error: tracks with the highest error are on top. */
342 
343  BKE_tracking_object_add(tracking, DATA_("Camera"));
344 }
345 
347 {
349 
350  if (object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
351  return &object->tracks;
352  }
353 
354  return &tracking->tracks;
355 }
356 
358 {
360 
361  if (object && (object->flag & TRACKING_OBJECT_CAMERA) == 0) {
362  return &object->plane_tracks;
363  }
364 
365  return &tracking->plane_tracks;
366 }
367 
369 {
371 
372  return BKE_tracking_object_get_reconstruction(tracking, object);
373 }
374 
375 void BKE_tracking_get_camera_object_matrix(Object *camera_object, float mat[4][4])
376 {
377  BLI_assert(camera_object != NULL);
378  /* NOTE: Construct matrix from scratch rather than using obmat because the camera object here
379  * will have camera solver constraint taken into account. But here we do not want or need it:
380  * object is solved in camera space (as in, camera is stationary and object is moving).
381  *
382  * This will include animation applied on the camera, but not possible camera rig. This isn't
383  * an issue in practice due to the way how VFX is constructed.
384  *
385  * If we ever need to support crazy setups like that one possible solution would be to use
386  * final camera matrix and multiple it by an inverse of solved camera matrix at the current
387  * frame. */
388  BKE_object_where_is_calc_mat4(camera_object, mat);
389 }
390 
392  MovieTrackingObject *object,
393  int framenr,
394  int winx,
395  int winy,
396  float mat[4][4])
397 {
399  float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx;
400  float viewfac, pixsize, left, right, bottom, top, clipsta, clipend;
401  float winmat[4][4];
402  float ycor = 1.0f / tracking->camera.pixel_aspect;
403  float shiftx, shifty, winside = (float)min_ii(winx, winy);
404 
405  BKE_tracking_camera_shift_get(tracking, winx, winy, &shiftx, &shifty);
406 
407  clipsta = 0.1f;
408  clipend = 1000.0f;
409 
410  if (winx >= winy) {
411  viewfac = (lens * winx) / tracking->camera.sensor_width;
412  }
413  else {
414  viewfac = (ycor * lens * winy) / tracking->camera.sensor_width;
415  }
416 
417  pixsize = clipsta / viewfac;
418 
419  left = -0.5f * (float)winx + shiftx * winside;
420  bottom = -0.5f * (ycor) * (float)winy + shifty * winside;
421  right = 0.5f * (float)winx + shiftx * winside;
422  top = 0.5f * (ycor) * (float)winy + shifty * winside;
423 
424  left *= pixsize;
425  right *= pixsize;
426  bottom *= pixsize;
427  top *= pixsize;
428 
429  perspective_m4(winmat, left, right, bottom, top, clipsta, clipend);
430 
431  camera = BKE_tracking_camera_get_reconstructed(tracking, object, framenr);
432 
433  if (camera) {
434  float imat[4][4];
435 
436  invert_m4_m4(imat, camera->mat);
437  mul_m4_m4m4(mat, winmat, imat);
438  }
439  else {
440  copy_m4_m4(mat, winmat);
441  }
442 }
443 
444 /* --------------------------------------------------------------------
445  * Clipboard.
446  */
447 
449 {
450  MovieTrackingTrack *track = tracking_clipboard.tracks.first, *next_track;
451 
452  while (track) {
453  next_track = track->next;
454 
456  MEM_freeN(track);
457 
458  track = next_track;
459  }
460 
462 }
463 
465 {
466  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
467  MovieTrackingTrack *track = tracksbase->first;
468 
469  /* First drop all tracks from current clipboard. */
471 
472  /* Then copy all selected visible tracks to it. */
473  while (track) {
474  if (TRACK_SELECTED(track) && (track->flag & TRACK_HIDDEN) == 0) {
476 
477  BLI_addtail(&tracking_clipboard.tracks, new_track);
478  }
479 
480  track = track->next;
481  }
482 }
483 
485 {
486  return (BLI_listbase_is_empty(&tracking_clipboard.tracks) == false);
487 }
488 
490 {
491  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
492  MovieTrackingTrack *track = tracking_clipboard.tracks.first;
493 
494  while (track) {
496  if (track->prev == NULL) {
497  tracking->act_track = new_track;
498  }
499 
500  BLI_addtail(tracksbase, new_track);
501  BKE_tracking_track_unique_name(tracksbase, new_track);
502 
503  track = track->next;
504  }
505 }
506 
507 /* --------------------------------------------------------------------
508  * Tracks.
509  */
510 
512 {
513  const MovieTrackingSettings *settings = &tracking->settings;
514 
515  MovieTrackingTrack *track = MEM_callocN(sizeof(MovieTrackingTrack), "add_marker_exec track");
516  strcpy(track->name, "Track");
517 
518  /* Fill track's settings from default settings. */
519  track->motion_model = settings->default_motion_model;
521  track->margin = settings->default_margin;
522  track->pattern_match = settings->default_pattern_match;
523  track->frames_limit = settings->default_frames_limit;
524  track->flag = settings->default_flag;
525  track->algorithm_flag = settings->default_algorithm_flag;
526  track->weight = settings->default_weight;
527  track->weight_stab = settings->default_weight;
528 
529  BLI_addtail(tracks_list, track);
530  BKE_tracking_track_unique_name(tracks_list, track);
531 
532  return track;
533 }
534 
536  ListBase *tracksbase,
537  float x,
538  float y,
539  int framenr,
540  int width,
541  int height)
542 {
543  const MovieTrackingSettings *settings = &tracking->settings;
544 
545  MovieTrackingTrack *track = BKE_tracking_track_add_empty(tracking, tracksbase);
546  MovieTrackingMarker marker;
547 
548  const float half_pattern_px = settings->default_pattern_size / 2.0f;
549  const float half_search_px = settings->default_search_size / 2.0f;
550 
551  const float pattern_size[2] = {half_pattern_px / width, half_pattern_px / height};
552  const float search_size[2] = {half_search_px / width, half_search_px / height};
553 
554  memset(&marker, 0, sizeof(marker));
555  marker.pos[0] = x;
556  marker.pos[1] = y;
557  marker.framenr = framenr;
558 
559  marker.pattern_corners[0][0] = -pattern_size[0];
560  marker.pattern_corners[0][1] = -pattern_size[1];
561 
562  marker.pattern_corners[1][0] = pattern_size[0];
563  marker.pattern_corners[1][1] = -pattern_size[1];
564 
565  negate_v2_v2(marker.pattern_corners[2], marker.pattern_corners[0]);
566  negate_v2_v2(marker.pattern_corners[3], marker.pattern_corners[1]);
567 
568  copy_v2_v2(marker.search_max, search_size);
569  negate_v2_v2(marker.search_min, search_size);
570 
571  BKE_tracking_marker_insert(track, &marker);
572 
573  return track;
574 }
575 
577 {
578  MovieTrackingTrack *new_track;
579 
580  new_track = MEM_callocN(sizeof(MovieTrackingTrack), "tracking_track_duplicate new_track");
581 
582  *new_track = *track;
583  new_track->next = new_track->prev = NULL;
584 
585  new_track->markers = MEM_dupallocN(new_track->markers);
586 
587  /* Prevent duplicate from being used for 2D stabilization.
588  * If necessary, it shall be added explicitly.
589  */
590  new_track->flag &= ~TRACK_USE_2D_STAB;
591  new_track->flag &= ~TRACK_USE_2D_STAB_ROT;
592 
593  return new_track;
594 }
595 
597 {
598  BLI_uniquename(tracksbase,
599  track,
601  '.',
602  offsetof(MovieTrackingTrack, name),
603  sizeof(track->name));
604 }
605 
607 {
608  if (track->markers) {
609  MEM_freeN(track->markers);
610  }
611 }
612 
614  int *r_first_frame,
615  int *r_last_frame)
616 {
617  BLI_assert(track->markersnr > 0);
618  const int last_marker_index = track->markersnr - 1;
619  *r_first_frame = track->markers[0].framenr;
620  *r_last_frame = track->markers[last_marker_index].framenr;
621 }
622 
624  const int num_tracks,
625  int *r_first_frame,
626  int *r_last_frame)
627 {
628  *r_first_frame = INT_MAX;
629  *r_last_frame = INT_MIN;
630  for (int i = 0; i < num_tracks; ++i) {
631  const struct MovieTrackingTrack *track = tracks[i];
632  int track_first_frame, track_last_frame;
633  BKE_tracking_track_first_last_frame_get(track, &track_first_frame, &track_last_frame);
634  *r_first_frame = min_ii(*r_first_frame, track_first_frame);
635  *r_last_frame = max_ii(*r_last_frame, track_last_frame);
636  }
637 }
638 
640 {
641  int num_selected_tracks = 0;
642  LISTBASE_FOREACH (const MovieTrackingTrack *, track, tracks_list) {
643  if (TRACK_SELECTED(track)) {
644  ++num_selected_tracks;
645  }
646  }
647  return num_selected_tracks;
648 }
649 
651 {
652  ListBase *tracks_list = BKE_tracking_get_active_tracks(tracking);
653  return BKE_tracking_count_selected_tracks_in_list(tracks_list);
654 }
655 
657  int *r_num_tracks)
658 {
659  *r_num_tracks = 0;
660 
661  ListBase *tracks_list = BKE_tracking_get_active_tracks(tracking);
662  if (tracks_list == NULL) {
663  return NULL;
664  }
665 
666  /* Initialize input. */
667  const int num_selected_tracks = BKE_tracking_count_selected_tracks_in_active_object(tracking);
668  if (num_selected_tracks == 0) {
669  return NULL;
670  }
671 
672  MovieTrackingTrack **source_tracks = MEM_malloc_arrayN(
673  num_selected_tracks, sizeof(MovieTrackingTrack *), "selected tracks array");
674  int source_track_index = 0;
675  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracks_list) {
676  if (!TRACK_SELECTED(track)) {
677  continue;
678  }
679  source_tracks[source_track_index] = track;
680  ++source_track_index;
681  }
682 
683  *r_num_tracks = num_selected_tracks;
684 
685  return source_tracks;
686 }
687 
689 {
690  if (area == TRACK_AREA_NONE) {
691  return;
692  }
693 
694  if (area & TRACK_AREA_POINT) {
695  track->flag |= flag;
696  }
697  if (area & TRACK_AREA_PAT) {
698  track->pat_flag |= flag;
699  }
700  if (area & TRACK_AREA_SEARCH) {
701  track->search_flag |= flag;
702  }
703 }
704 
706 {
707  if (area == TRACK_AREA_NONE) {
708  return;
709  }
710 
711  if (area & TRACK_AREA_POINT) {
712  track->flag &= ~flag;
713  }
714  if (area & TRACK_AREA_PAT) {
715  track->pat_flag &= ~flag;
716  }
717  if (area & TRACK_AREA_SEARCH) {
718  track->search_flag &= ~flag;
719  }
720 }
721 
723 {
724  return BKE_tracking_marker_get_exact(track, framenr) != NULL;
725 }
726 
728 {
729  MovieTrackingMarker *marker = BKE_tracking_marker_get_exact(track, framenr);
730 
731  return marker && (marker->flag & MARKER_DISABLED) == 0;
732 }
733 
734 static void path_clear_remained(MovieTrackingTrack *track, const int ref_frame)
735 {
736  for (int a = 1; a < track->markersnr; a++) {
737  if (track->markers[a].framenr > ref_frame) {
738  track->markersnr = a;
739  track->markers = MEM_reallocN(track->markers,
740  sizeof(MovieTrackingMarker) * track->markersnr);
741 
742  break;
743  }
744  }
745 
746  if (track->markersnr) {
747  tracking_marker_insert_disabled(track, &track->markers[track->markersnr - 1], false, true);
748  }
749 }
750 
751 static void path_clear_up_to(MovieTrackingTrack *track, const int ref_frame)
752 {
753  for (int a = track->markersnr - 1; a >= 0; a--) {
754  if (track->markers[a].framenr <= ref_frame) {
755  memmove(track->markers,
756  track->markers + a,
757  (track->markersnr - a) * sizeof(MovieTrackingMarker));
758 
759  track->markersnr = track->markersnr - a;
760  track->markers = MEM_reallocN(track->markers,
761  sizeof(MovieTrackingMarker) * track->markersnr);
762 
763  break;
764  }
765  }
766 
767  if (track->markersnr) {
768  tracking_marker_insert_disabled(track, &track->markers[0], true, true);
769  }
770 }
771 
772 static void path_clear_all(MovieTrackingTrack *track, const int ref_frame)
773 {
774  MovieTrackingMarker *marker, marker_new;
775 
776  marker = BKE_tracking_marker_get(track, ref_frame);
777  marker_new = *marker;
778 
779  MEM_freeN(track->markers);
780  track->markers = NULL;
781  track->markersnr = 0;
782 
783  BKE_tracking_marker_insert(track, &marker_new);
784 
785  tracking_marker_insert_disabled(track, &marker_new, true, true);
786  tracking_marker_insert_disabled(track, &marker_new, false, true);
787 }
788 
790  const int ref_frame,
791  const eTrackClearAction action)
792 {
793  switch (action) {
795  path_clear_remained(track, ref_frame);
796  break;
797  case TRACK_CLEAR_UPTO:
798  path_clear_up_to(track, ref_frame);
799  break;
800  case TRACK_CLEAR_ALL:
801  path_clear_all(track, ref_frame);
802  break;
803  };
804 }
805 
807  MovieTrackingTrack *dst_track,
808  MovieTrackingTrack *src_track)
809 {
810  int i = 0, a = 0, b = 0, tot;
812 
813  tot = dst_track->markersnr + src_track->markersnr;
814  markers = MEM_callocN(tot * sizeof(MovieTrackingMarker), "tmp tracking joined tracks");
815 
816  while (a < src_track->markersnr || b < dst_track->markersnr) {
817  if (b >= dst_track->markersnr) {
818  markers[i] = src_track->markers[a++];
819  }
820  else if (a >= src_track->markersnr) {
821  markers[i] = dst_track->markers[b++];
822  }
823  else if (src_track->markers[a].framenr < dst_track->markers[b].framenr) {
824  markers[i] = src_track->markers[a++];
825  }
826  else if (src_track->markers[a].framenr > dst_track->markers[b].framenr) {
827  markers[i] = dst_track->markers[b++];
828  }
829  else {
830  if ((src_track->markers[a].flag & MARKER_DISABLED) == 0) {
831  if ((dst_track->markers[b].flag & MARKER_DISABLED) == 0) {
832  /* both tracks are enabled on this frame, so find the whole segment
833  * on which tracks are intersecting and blend tracks using linear
834  * interpolation to prevent jumps
835  */
836 
837  MovieTrackingMarker *marker_a, *marker_b;
838  int start_a = a, start_b = b, len = 0, frame = src_track->markers[a].framenr;
839  int inverse = 0;
840 
841  inverse = (b == 0) || (dst_track->markers[b - 1].flag & MARKER_DISABLED) ||
842  (dst_track->markers[b - 1].framenr != frame - 1);
843 
844  /* find length of intersection */
845  while (a < src_track->markersnr && b < dst_track->markersnr) {
846  marker_a = &src_track->markers[a];
847  marker_b = &dst_track->markers[b];
848 
849  if (marker_a->flag & MARKER_DISABLED || marker_b->flag & MARKER_DISABLED) {
850  break;
851  }
852 
853  if (marker_a->framenr != frame || marker_b->framenr != frame) {
854  break;
855  }
856 
857  frame++;
858  len++;
859  a++;
860  b++;
861  }
862 
863  a = start_a;
864  b = start_b;
865 
866  /* linear interpolation for intersecting frames */
867  for (int j = 0; j < len; j++) {
868  float fac = 0.5f;
869 
870  if (len > 1) {
871  fac = 1.0f / (len - 1) * j;
872  }
873 
874  if (inverse) {
875  fac = 1.0f - fac;
876  }
877 
878  marker_a = &src_track->markers[a];
879  marker_b = &dst_track->markers[b];
880 
881  markers[i] = dst_track->markers[b];
882  interp_v2_v2v2(markers[i].pos, marker_b->pos, marker_a->pos, fac);
883  a++;
884  b++;
885  i++;
886  }
887 
888  /* this values will be incremented at the end of the loop cycle */
889  a--;
890  b--;
891  i--;
892  }
893  else {
894  markers[i] = src_track->markers[a];
895  }
896  }
897  else {
898  markers[i] = dst_track->markers[b];
899  }
900 
901  a++;
902  b++;
903  }
904 
905  i++;
906  }
907 
908  MEM_freeN(dst_track->markers);
909 
910  dst_track->markers = MEM_mallocN(i * sizeof(MovieTrackingMarker), "tracking joined tracks");
911  memcpy(dst_track->markers, markers, i * sizeof(MovieTrackingMarker));
912 
913  dst_track->markersnr = i;
914 
916 
918 }
919 
920 static void accumulate_marker(MovieTrackingMarker *dst_marker,
921  const MovieTrackingMarker *src_marker)
922 {
923  BLI_assert(dst_marker->framenr == src_marker->framenr);
924 
925  if (src_marker->flag & MARKER_DISABLED) {
926  return;
927  }
928 
929  add_v2_v2(dst_marker->pos, src_marker->pos);
930  for (int corner = 0; corner < 4; ++corner) {
931  add_v2_v2(dst_marker->pattern_corners[corner], src_marker->pattern_corners[corner]);
932  }
933  add_v2_v2(dst_marker->search_min, src_marker->search_min);
934  add_v2_v2(dst_marker->search_max, src_marker->search_max);
935 
936  BLI_assert(is_finite_v2(src_marker->search_min));
937  BLI_assert(is_finite_v2(src_marker->search_max));
938 
939  dst_marker->flag &= ~MARKER_DISABLED;
940  if ((src_marker->flag & MARKER_TRACKED) == 0) {
941  dst_marker->flag &= ~MARKER_TRACKED;
942  }
943 }
944 
945 static void multiply_marker(MovieTrackingMarker *marker, const float multiplier)
946 {
947  mul_v2_fl(marker->pos, multiplier);
948  for (int corner = 0; corner < 4; ++corner) {
949  mul_v2_fl(marker->pattern_corners[corner], multiplier);
950  }
951  mul_v2_fl(marker->search_min, multiplier);
952  mul_v2_fl(marker->search_max, multiplier);
953 }
954 
955 /* Helper function for BKE_tracking_tracks_average which takes care of averaging fields of
956  * markers (position, patterns, ...). */
958  /*const*/ MovieTrackingTrack **src_tracks,
959  const int num_src_tracks)
960 {
961  /* Get global range of frames within which averaging would happen. */
962  int first_frame, last_frame;
964  src_tracks, num_src_tracks, &first_frame, &last_frame);
965  if (last_frame < first_frame) {
966  return;
967  }
968  const int num_frames = last_frame - first_frame + 1;
969 
970  /* Allocate temporary array where averaging will happen into. */
971  MovieTrackingMarker *accumulator = MEM_calloc_arrayN(
972  num_frames, sizeof(MovieTrackingMarker), "tracks average accumulator");
973  int *counters = MEM_calloc_arrayN(num_frames, sizeof(int), "tracks accumulator counters");
974  for (int frame = first_frame; frame <= last_frame; ++frame) {
975  const int frame_index = frame - first_frame;
976  accumulator[frame_index].framenr = frame;
977  accumulator[frame_index].flag |= (MARKER_DISABLED | MARKER_TRACKED);
978  }
979 
980  /* Accumulate track markers. */
981  for (int track_index = 0; track_index < num_src_tracks; ++track_index) {
982  /*const*/ MovieTrackingTrack *track = src_tracks[track_index];
983  for (int frame = first_frame; frame <= last_frame; ++frame) {
984  MovieTrackingMarker interpolated_marker;
985  if (!BKE_tracking_marker_get_interpolated(track, frame, &interpolated_marker)) {
986  continue;
987  }
988  const int frame_index = frame - first_frame;
989  accumulate_marker(&accumulator[frame_index], &interpolated_marker);
990  ++counters[frame_index];
991  }
992  }
993 
994  /* Average and store the result. */
995  for (int frame = first_frame; frame <= last_frame; ++frame) {
996  /* Average. */
997  const int frame_index = frame - first_frame;
998  if (!counters[frame_index]) {
999  continue;
1000  }
1001  const float multiplier = 1.0f / (float)counters[frame_index];
1002  multiply_marker(&accumulator[frame_index], multiplier);
1003  /* Store the result. */
1004  BKE_tracking_marker_insert(dst_track, &accumulator[frame_index]);
1005  }
1006 
1007  /* Free memory. */
1008  MEM_freeN(accumulator);
1009  MEM_freeN(counters);
1010 }
1011 
1012 /* Helper function for BKE_tracking_tracks_average which takes care of averaging fields of
1013  * tracks (track for example, offset). */
1015  /*const*/ MovieTrackingTrack **src_tracks,
1016  const int num_src_tracks)
1017 {
1018  /* TODO(sergey): Consider averaging weight, stabilization weight, maybe even bundle position. */
1019  zero_v2(dst_track->offset);
1020  for (int track_index = 0; track_index < num_src_tracks; track_index++) {
1021  add_v2_v2(dst_track->offset, src_tracks[track_index]->offset);
1022  }
1023  mul_v2_fl(dst_track->offset, 1.0f / num_src_tracks);
1024 }
1025 
1027  /*const*/ MovieTrackingTrack **src_tracks,
1028  const int num_src_tracks)
1029 {
1030  if (num_src_tracks == 0) {
1031  return;
1032  }
1033 
1034  tracking_average_markers(dst_track, src_tracks, num_src_tracks);
1035  tracking_average_tracks(dst_track, src_tracks, num_src_tracks);
1036 }
1037 
1039  MovieTrackingObject *object,
1040  const char *name)
1041 {
1042  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
1043  MovieTrackingTrack *track = tracksbase->first;
1044 
1045  while (track) {
1046  if (STREQ(track->name, name)) {
1047  return track;
1048  }
1049 
1050  track = track->next;
1051  }
1052 
1053  return NULL;
1054 }
1055 
1057  int tracknr,
1058  ListBase **r_tracksbase)
1059 {
1060  MovieTrackingObject *object;
1061  int cur = 1;
1062 
1063  object = tracking->objects.first;
1064  while (object) {
1065  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
1066  MovieTrackingTrack *track = tracksbase->first;
1067 
1068  while (track) {
1069  if (track->flag & TRACK_HAS_BUNDLE) {
1070  if (cur == tracknr) {
1071  *r_tracksbase = tracksbase;
1072  return track;
1073  }
1074 
1075  cur++;
1076  }
1077 
1078  track = track->next;
1079  }
1080 
1081  object = object->next;
1082  }
1083 
1084  *r_tracksbase = NULL;
1085 
1086  return NULL;
1087 }
1088 
1090 {
1091  ListBase *tracksbase;
1092 
1093  if (!tracking->act_track) {
1094  return NULL;
1095  }
1096 
1097  tracksbase = BKE_tracking_get_active_tracks(tracking);
1098 
1099  /* check that active track is in current tracks list */
1100  if (BLI_findindex(tracksbase, tracking->act_track) != -1) {
1101  return tracking->act_track;
1102  }
1103 
1104  return NULL;
1105 }
1106 
1108 {
1109  bGPDlayer *layer;
1110 
1111  if (!track->gpd) {
1112  return NULL;
1113  }
1114 
1115  layer = track->gpd->layers.first;
1116 
1117  while (layer) {
1118  if (layer->flag & GP_LAYER_ACTIVE) {
1119  bGPDframe *frame = layer->frames.first;
1120  bool ok = false;
1121 
1122  while (frame) {
1123  if (frame->strokes.first) {
1124  ok = true;
1125  break;
1126  }
1127 
1128  frame = frame->next;
1129  }
1130 
1131  if (ok) {
1132  return layer;
1133  }
1134  }
1135 
1136  layer = layer->next;
1137  }
1138 
1139  return NULL;
1140 }
1141 
1142 typedef struct TrackMaskSetPixelData {
1143  float *mask;
1147 
1148 static void track_mask_set_pixel_cb(int x, int x_end, int y, void *user_data)
1149 {
1151  size_t index = (size_t)y * data->mask_width + x;
1152  size_t index_end = (size_t)y * data->mask_width + x_end;
1153  do {
1154  data->mask[index] = 1.0f;
1155  } while (++index != index_end);
1156 }
1157 
1158 static void track_mask_gpencil_layer_rasterize(int frame_width,
1159  int frame_height,
1160  const float region_min[2],
1161  bGPDlayer *layer,
1162  float *mask,
1163  int mask_width,
1164  int mask_height)
1165 {
1166  bGPDframe *frame = layer->frames.first;
1168 
1169  data.mask = mask;
1170  data.mask_width = mask_width;
1171  data.mask_height = mask_height;
1172 
1173  while (frame) {
1174  bGPDstroke *stroke = frame->strokes.first;
1175 
1176  while (stroke) {
1177  bGPDspoint *stroke_points = stroke->points;
1178  if (stroke->flag & GP_STROKE_2DSPACE) {
1179  int *mask_points, *point;
1180  point = mask_points = MEM_callocN(2 * stroke->totpoints * sizeof(int),
1181  "track mask rasterization points");
1182  for (int i = 0; i < stroke->totpoints; i++, point += 2) {
1183  point[0] = stroke_points[i].x * frame_width - region_min[0];
1184  point[1] = stroke_points[i].y * frame_height - region_min[1];
1185  }
1186  /* TODO: add an option to control whether AA is enabled or not */
1188  0,
1189  mask_width,
1190  mask_height,
1191  (const int(*)[2])mask_points,
1192  stroke->totpoints,
1194  &data);
1195  MEM_freeN(mask_points);
1196  }
1197  stroke = stroke->next;
1198  }
1199  frame = frame->next;
1200  }
1201 }
1202 
1203 float *tracking_track_get_mask_for_region(int frame_width,
1204  int frame_height,
1205  const float region_min[2],
1206  const float region_max[2],
1207  MovieTrackingTrack *track)
1208 {
1209  float *mask = NULL;
1210  bGPDlayer *layer = track_mask_gpencil_layer_get(track);
1211  if (layer != NULL) {
1212  const int mask_width = region_max[0] - region_min[0];
1213  const int mask_height = region_max[1] - region_min[1];
1214  mask = MEM_callocN(mask_width * mask_height * sizeof(float), "track mask");
1216  frame_width, frame_height, region_min, layer, mask, mask_width, mask_height);
1217  }
1218  return mask;
1219 }
1220 
1221 float *BKE_tracking_track_get_mask(int frame_width,
1222  int frame_height,
1223  MovieTrackingTrack *track,
1224  MovieTrackingMarker *marker)
1225 {
1226  /* Convert normalized space marker's search area to pixel-space region. */
1227  const float region_min[2] = {
1228  marker->search_min[0] * frame_width,
1229  marker->search_min[1] * frame_height,
1230  };
1231  const float region_max[2] = {
1232  marker->search_max[0] * frame_width,
1233  marker->search_max[1] * frame_height,
1234  };
1236  frame_width, frame_height, region_min, region_max, track);
1237 }
1238 
1240  MovieTrackingTrack *track,
1241  MovieTrackingMarker *marker)
1242 {
1243  FCurve *weight_fcurve;
1244  float weight = track->weight;
1245 
1246  weight_fcurve = id_data_find_fcurve(
1247  &clip->id, track, &RNA_MovieTrackingTrack, "weight", 0, NULL);
1248 
1249  if (weight_fcurve) {
1250  int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
1251  weight = evaluate_fcurve(weight_fcurve, scene_framenr);
1252  }
1253 
1254  return weight;
1255 }
1256 
1258  MovieTrackingTrack *track,
1259  int area,
1260  bool extend)
1261 {
1262  if (extend) {
1264  }
1265  else {
1266  MovieTrackingTrack *cur = tracksbase->first;
1267 
1268  while (cur) {
1269  if ((cur->flag & TRACK_HIDDEN) == 0) {
1270  if (cur == track) {
1273  }
1274  else {
1276  }
1277  }
1278 
1279  cur = cur->next;
1280  }
1281  }
1282 }
1283 
1285 {
1287 }
1288 
1290 {
1291  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
1292  if ((track->flag & TRACK_HIDDEN) == 0) {
1294  }
1295  }
1296 }
1297 
1298 /* --------------------------------------------------------------------
1299  * Marker.
1300  */
1301 
1303  MovieTrackingMarker *marker)
1304 {
1305  MovieTrackingMarker *old_marker = NULL;
1306 
1307  if (track->markersnr) {
1308  old_marker = BKE_tracking_marker_get_exact(track, marker->framenr);
1309  }
1310 
1311  if (old_marker) {
1312  /* simply replace settings for already allocated marker */
1313  *old_marker = *marker;
1314 
1315  return old_marker;
1316  }
1317 
1318  int a = track->markersnr;
1319 
1320  /* find position in array where to add new marker */
1321  while (a--) {
1322  if (track->markers[a].framenr < marker->framenr) {
1323  break;
1324  }
1325  }
1326 
1327  track->markersnr++;
1328 
1329  if (track->markers) {
1330  track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr);
1331  }
1332  else {
1333  track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers");
1334  }
1335 
1336  /* shift array to "free" space for new marker */
1337  memmove(track->markers + a + 2,
1338  track->markers + a + 1,
1339  (track->markersnr - a - 2) * sizeof(MovieTrackingMarker));
1340 
1341  /* put new marker */
1342  track->markers[a + 1] = *marker;
1343 
1344  return &track->markers[a + 1];
1345 }
1346 
1348 {
1349  int a = 0;
1350 
1351  while (a < track->markersnr) {
1352  if (track->markers[a].framenr == framenr) {
1353  if (track->markersnr > 1) {
1354  memmove(track->markers + a,
1355  track->markers + a + 1,
1356  (track->markersnr - a - 1) * sizeof(MovieTrackingMarker));
1357  track->markersnr--;
1358  track->markers = MEM_reallocN(track->markers,
1359  sizeof(MovieTrackingMarker) * track->markersnr);
1360  }
1361  else {
1362  MEM_freeN(track->markers);
1363  track->markers = NULL;
1364  track->markersnr = 0;
1365  }
1366 
1367  break;
1368  }
1369 
1370  a++;
1371  }
1372 }
1373 
1375 {
1376  float pat_min[2], pat_max[2];
1377  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1378 
1379  for (int a = 0; a < 2; a++) {
1380  if (pat_min[a] < marker->search_min[a]) {
1381  for (int b = 0; b < 4; b++) {
1382  marker->pattern_corners[b][a] += marker->search_min[a] - pat_min[a];
1383  }
1384  }
1385  if (pat_max[a] > marker->search_max[a]) {
1386  for (int b = 0; b < 4; b++) {
1387  marker->pattern_corners[b][a] -= pat_max[a] - marker->search_max[a];
1388  }
1389  }
1390  }
1391 }
1392 
1394 {
1395  float pat_min[2], pat_max[2];
1396  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1397 
1398  for (int a = 0; a < 2; a++) {
1399  marker->search_min[a] = min_ff(pat_min[a], marker->search_min[a]);
1400  marker->search_max[a] = max_ff(pat_max[a], marker->search_max[a]);
1401  }
1402 }
1403 
1405 {
1406  float pat_min[2], pat_max[2];
1407  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
1408 
1409  float dim[2];
1410  sub_v2_v2v2(dim, marker->search_max, marker->search_min);
1411 
1412  for (int a = 0; a < 2; a++) {
1413  if (marker->search_min[a] > pat_min[a]) {
1414  marker->search_min[a] = pat_min[a];
1415  marker->search_max[a] = marker->search_min[a] + dim[a];
1416  }
1417  if (marker->search_max[a] < pat_max[a]) {
1418  marker->search_max[a] = pat_max[a];
1419  marker->search_min[a] = marker->search_max[a] - dim[a];
1420  }
1421  }
1422 }
1423 
1425 {
1426  const int num_markers = track->markersnr;
1427 
1428  if (num_markers == 0) {
1429  BLI_assert_msg(0, "Detected degenerated track, should never happen.");
1430  return NULL;
1431  }
1432 
1433  int left_boundary = 0;
1434  int right_boundary = num_markers;
1435  while (left_boundary < right_boundary) {
1436  const int median_index = (left_boundary + right_boundary) / 2;
1437  MovieTrackingMarker *marker = &track->markers[median_index];
1438 
1439  if (marker->framenr == framenr) {
1440  return marker;
1441  }
1442 
1443  if (marker->framenr < framenr) {
1444  left_boundary = median_index + 1;
1445  }
1446  else {
1447  BLI_assert(marker->framenr > framenr);
1448  right_boundary = median_index - 1;
1449  }
1450  }
1451 
1452  const int closest_index = clamp_i(right_boundary, 0, num_markers - 1);
1453 
1454  return &track->markers[closest_index];
1455 }
1456 
1458 {
1459  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1460 
1461  if (marker->framenr != framenr) {
1462  return NULL;
1463  }
1464 
1465  return marker;
1466 }
1467 
1469 {
1470  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1471 
1472  if (marker->framenr != framenr) {
1473  MovieTrackingMarker marker_new;
1474 
1475  marker_new = *marker;
1476  marker_new.framenr = framenr;
1477 
1478  BKE_tracking_marker_insert(track, &marker_new);
1479  marker = BKE_tracking_marker_get(track, framenr);
1480  }
1481 
1482  return marker;
1483 }
1484 
1486  struct MovieTrackingTrack *track,
1487  const MovieTrackingMarker *anchor_marker,
1488  const int direction)
1489 {
1490  BLI_assert(ELEM(direction, -1, 1));
1491 
1492  const MovieTrackingMarker *last_marker = track->markers + track->markersnr - 1;
1493  const MovieTrackingMarker *current_marker = anchor_marker;
1494 
1495  while (current_marker >= track->markers && current_marker <= last_marker) {
1496  if ((current_marker->flag & MARKER_DISABLED) == 0) {
1497  return current_marker;
1498  }
1499  current_marker += direction;
1500  }
1501 
1502  return NULL;
1503 }
1504 
1506  const int framenr,
1507  struct MovieTrackingMarker *r_marker)
1508 {
1509  const MovieTrackingMarker *closest_marker = BKE_tracking_marker_get(track, framenr);
1510  if (closest_marker == NULL) {
1511  return false;
1512  }
1513  if (closest_marker->framenr == framenr && (closest_marker->flag & MARKER_DISABLED) == 0) {
1514  *r_marker = *closest_marker;
1515  return true;
1516  }
1517 
1519  track, closest_marker, -1);
1520  if (left_marker == NULL) {
1521  return false;
1522  }
1523 
1525  track, closest_marker + 1, 1);
1526  if (right_marker == NULL) {
1527  return false;
1528  }
1529 
1530  if (left_marker == right_marker) {
1531  *r_marker = *left_marker;
1532  return true;
1533  }
1534 
1535  const float factor = (float)(framenr - left_marker->framenr) /
1536  (right_marker->framenr - left_marker->framenr);
1537 
1538  interp_v2_v2v2(r_marker->pos, left_marker->pos, right_marker->pos, factor);
1539 
1540  for (int i = 0; i < 4; i++) {
1541  interp_v2_v2v2(r_marker->pattern_corners[i],
1542  left_marker->pattern_corners[i],
1543  right_marker->pattern_corners[i],
1544  factor);
1545  }
1546 
1547  interp_v2_v2v2(r_marker->search_min, left_marker->search_min, right_marker->search_min, factor);
1548  interp_v2_v2v2(r_marker->search_max, left_marker->search_max, right_marker->search_max, factor);
1549 
1550  r_marker->framenr = framenr;
1551  r_marker->flag = 0;
1552 
1553  if (framenr == left_marker->framenr) {
1554  r_marker->flag = left_marker->flag;
1555  }
1556  else if (framenr == right_marker->framenr) {
1557  r_marker->flag = right_marker->flag;
1558  }
1559 
1560  return true;
1561 }
1562 
1564  float min[2],
1565  float max[2])
1566 {
1567  INIT_MINMAX2(min, max);
1568 
1569  minmax_v2v2_v2(min, max, marker->pattern_corners[0]);
1570  minmax_v2v2_v2(min, max, marker->pattern_corners[1]);
1571  minmax_v2v2_v2(min, max, marker->pattern_corners[2]);
1572  minmax_v2v2_v2(min, max, marker->pattern_corners[3]);
1573 }
1574 
1576  float framenr,
1577  float pos[2])
1578 {
1579  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, (int)framenr);
1580  MovieTrackingMarker *marker_last = track->markers + (track->markersnr - 1);
1581 
1582  if (marker != marker_last) {
1583  MovieTrackingMarker *marker_next = marker + 1;
1584 
1585  if (marker_next->framenr == marker->framenr + 1) {
1586  /* currently only do subframing inside tracked ranges, do not extrapolate tracked segments
1587  * could be changed when / if mask parent would be interpolating position in-between
1588  * tracked segments
1589  */
1590 
1591  float fac = (framenr - (int)framenr) / (marker_next->framenr - marker->framenr);
1592 
1593  interp_v2_v2v2(pos, marker->pos, marker_next->pos, fac);
1594  }
1595  else {
1596  copy_v2_v2(pos, marker->pos);
1597  }
1598  }
1599  else {
1600  copy_v2_v2(pos, marker->pos);
1601  }
1602 
1603  /* currently track offset is always wanted to be applied here, could be made an option later */
1604  add_v2_v2(pos, track->offset);
1605 }
1606 
1607 /* --------------------------------------------------------------------
1608  * Plane track.
1609  */
1610 
1612  ListBase *plane_tracks_base,
1613  ListBase *tracks,
1614  int framenr)
1615 {
1616  MovieTrackingPlaneTrack *plane_track;
1617  MovieTrackingPlaneMarker plane_marker;
1618  float tracks_min[2], tracks_max[2];
1619  int num_selected_tracks = 0;
1620 
1621  (void)tracking; /* Ignored. */
1622 
1623  /* Use bounding box of selected markers as an initial size of plane. */
1624  INIT_MINMAX2(tracks_min, tracks_max);
1626  if (TRACK_SELECTED(track)) {
1627  MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr);
1628  float pattern_min[2], pattern_max[2];
1629  BKE_tracking_marker_pattern_minmax(marker, pattern_min, pattern_max);
1630  add_v2_v2(pattern_min, marker->pos);
1631  add_v2_v2(pattern_max, marker->pos);
1632  minmax_v2v2_v2(tracks_min, tracks_max, pattern_min);
1633  minmax_v2v2_v2(tracks_min, tracks_max, pattern_max);
1634  num_selected_tracks++;
1635  }
1636  }
1637 
1638  if (num_selected_tracks < 4) {
1639  return NULL;
1640  }
1641 
1642  /* Allocate new plane track. */
1643  plane_track = MEM_callocN(sizeof(MovieTrackingPlaneTrack), "new plane track");
1644 
1645  /* Use some default name. */
1646  strcpy(plane_track->name, "Plane Track");
1647 
1648  plane_track->image_opacity = 1.0f;
1649 
1650  /* Use selected tracks from given list as a plane. */
1651  plane_track->point_tracks = MEM_mallocN(sizeof(MovieTrackingTrack *) * num_selected_tracks,
1652  "new plane tracks array");
1653  int track_index = 0;
1655  if (TRACK_SELECTED(track)) {
1656  plane_track->point_tracks[track_index] = track;
1657  track_index++;
1658  }
1659  }
1660  plane_track->point_tracksnr = num_selected_tracks;
1661 
1662  /* Setup new plane marker and add it to the track. */
1663  plane_marker.framenr = framenr;
1664  plane_marker.flag = 0;
1665 
1666  copy_v2_v2(plane_marker.corners[0], tracks_min);
1667  copy_v2_v2(plane_marker.corners[2], tracks_max);
1668 
1669  plane_marker.corners[1][0] = tracks_max[0];
1670  plane_marker.corners[1][1] = tracks_min[1];
1671  plane_marker.corners[3][0] = tracks_min[0];
1672  plane_marker.corners[3][1] = tracks_max[1];
1673 
1674  BKE_tracking_plane_marker_insert(plane_track, &plane_marker);
1675 
1676  /* Put new plane track to the list, ensure its name is unique. */
1677  BLI_addtail(plane_tracks_base, plane_track);
1678  BKE_tracking_plane_track_unique_name(plane_tracks_base, plane_track);
1679 
1680  return plane_track;
1681 }
1682 
1684  MovieTrackingPlaneTrack *plane_track)
1685 {
1686  BLI_uniquename(plane_tracks_base,
1687  plane_track,
1688  CTX_DATA_(BLT_I18NCONTEXT_ID_MOVIECLIP, "Plane Track"),
1689  '.',
1690  offsetof(MovieTrackingPlaneTrack, name),
1691  sizeof(plane_track->name));
1692 }
1693 
1695 {
1696  if (plane_track->markers) {
1697  MEM_freeN(plane_track->markers);
1698  }
1699 
1700  MEM_freeN(plane_track->point_tracks);
1701 }
1702 
1704  MovieTrackingObject *object,
1705  const char *name)
1706 {
1707  ListBase *plane_tracks_base = BKE_tracking_object_get_plane_tracks(tracking, object);
1708 
1709  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
1710  if (STREQ(plane_track->name, name)) {
1711  return plane_track;
1712  }
1713  }
1714 
1715  return NULL;
1716 }
1717 
1719 {
1720  if (tracking->act_plane_track == NULL) {
1721  return NULL;
1722  }
1723 
1724  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1725 
1726  /* Check that active track is in current plane tracks list */
1727  if (BLI_findindex(plane_tracks_base, tracking->act_plane_track) != -1) {
1728  return tracking->act_plane_track;
1729  }
1730 
1731  return NULL;
1732 }
1733 
1735 {
1736  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
1737  plane_track->flag &= ~SELECT;
1738  }
1739 }
1740 
1742  MovieTrackingTrack *track)
1743 {
1744  for (int i = 0; i < plane_track->point_tracksnr; i++) {
1745  if (plane_track->point_tracks[i] == track) {
1746  return true;
1747  }
1748  }
1749  return false;
1750 }
1751 
1753  MovieTrackingTrack *track)
1754 {
1755  if (plane_track->point_tracksnr <= 4) {
1756  return false;
1757  }
1758 
1759  MovieTrackingTrack **new_point_tracks = MEM_mallocN(
1760  sizeof(*new_point_tracks) * (plane_track->point_tracksnr - 1), "new point tracks array");
1761 
1762  for (int i = 0, track_index = 0; i < plane_track->point_tracksnr; i++) {
1763  if (plane_track->point_tracks[i] != track) {
1764  new_point_tracks[track_index++] = plane_track->point_tracks[i];
1765  }
1766  }
1767 
1768  MEM_freeN(plane_track->point_tracks);
1769  plane_track->point_tracks = new_point_tracks;
1770  plane_track->point_tracksnr--;
1771 
1772  return true;
1773 }
1774 
1776  MovieTrackingTrack *track)
1777 {
1778  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1779  LISTBASE_FOREACH_MUTABLE (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
1780  if (BKE_tracking_plane_track_has_point_track(plane_track, track)) {
1781  if (!BKE_tracking_plane_track_remove_point_track(plane_track, track)) {
1782  /* Delete planes with less than 3 point tracks in it. */
1783  BKE_tracking_plane_track_free(plane_track);
1784  BLI_freelinkN(plane_tracks_base, plane_track);
1785  }
1786  }
1787  }
1788 }
1789 
1791  MovieTrackingTrack *old_track,
1792  MovieTrackingTrack *new_track)
1793 {
1794  for (int i = 0; i < plane_track->point_tracksnr; i++) {
1795  if (plane_track->point_tracks[i] == old_track) {
1796  plane_track->point_tracks[i] = new_track;
1797  break;
1798  }
1799  }
1800 }
1801 
1803  MovieTrackingTrack *old_track,
1804  MovieTrackingTrack *new_track)
1805 {
1806  ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking);
1807  LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
1808  if (BKE_tracking_plane_track_has_point_track(plane_track, old_track)) {
1809  BKE_tracking_plane_track_replace_point_track(plane_track, old_track, new_track);
1810  }
1811  }
1812 }
1813 
1814 /* --------------------------------------------------------------------
1815  * Plane marker.
1816  */
1817 
1819  MovieTrackingPlaneMarker *plane_marker)
1820 {
1821  MovieTrackingPlaneMarker *old_plane_marker = NULL;
1822 
1823  if (plane_track->markersnr) {
1824  old_plane_marker = BKE_tracking_plane_marker_get_exact(plane_track, plane_marker->framenr);
1825  }
1826 
1827  if (old_plane_marker) {
1828  /* Simply replace settings in existing marker. */
1829  *old_plane_marker = *plane_marker;
1830 
1831  return old_plane_marker;
1832  }
1833 
1834  int a = plane_track->markersnr;
1835 
1836  /* Find position in array where to add new marker. */
1837  /* TODO(sergey): we could use bisect to speed things up. */
1838  while (a--) {
1839  if (plane_track->markers[a].framenr < plane_marker->framenr) {
1840  break;
1841  }
1842  }
1843 
1844  plane_track->markersnr++;
1845  plane_track->markers = MEM_reallocN(plane_track->markers,
1846  sizeof(MovieTrackingPlaneMarker) * plane_track->markersnr);
1847 
1848  /* Shift array to "free" space for new marker. */
1849  memmove(plane_track->markers + a + 2,
1850  plane_track->markers + a + 1,
1851  (plane_track->markersnr - a - 2) * sizeof(MovieTrackingPlaneMarker));
1852 
1853  /* Put new marker to an array. */
1854  plane_track->markers[a + 1] = *plane_marker;
1855 
1856  return &plane_track->markers[a + 1];
1857 }
1858 
1860 {
1861  int a = 0;
1862 
1863  while (a < plane_track->markersnr) {
1864  if (plane_track->markers[a].framenr == framenr) {
1865  if (plane_track->markersnr > 1) {
1866  memmove(plane_track->markers + a,
1867  plane_track->markers + a + 1,
1868  (plane_track->markersnr - a - 1) * sizeof(MovieTrackingPlaneMarker));
1869  plane_track->markersnr--;
1870  plane_track->markers = MEM_reallocN(plane_track->markers,
1871  sizeof(MovieTrackingMarker) * plane_track->markersnr);
1872  }
1873  else {
1874  MEM_freeN(plane_track->markers);
1875  plane_track->markers = NULL;
1876  plane_track->markersnr = 0;
1877  }
1878 
1879  break;
1880  }
1881 
1882  a++;
1883  }
1884 }
1885 
1886 /* TODO(sergey): The next couple of functions are really quite the same as point marker version,
1887  * would be nice to de-duplicate them somehow..
1888  */
1889 
1891  int framenr)
1892 {
1893  int a = plane_track->markersnr - 1;
1894 
1895  if (!plane_track->markersnr) {
1896  return NULL;
1897  }
1898 
1899  /* Approximate pre-first framenr marker with first marker. */
1900  if (framenr < plane_track->markers[0].framenr) {
1901  return &plane_track->markers[0];
1902  }
1903 
1904  if (plane_track->last_marker < plane_track->markersnr) {
1905  a = plane_track->last_marker;
1906  }
1907 
1908  if (plane_track->markers[a].framenr <= framenr) {
1909  while (a < plane_track->markersnr && plane_track->markers[a].framenr <= framenr) {
1910  if (plane_track->markers[a].framenr == framenr) {
1911  plane_track->last_marker = a;
1912 
1913  return &plane_track->markers[a];
1914  }
1915  a++;
1916  }
1917 
1918  /* If there's no marker for exact position, use nearest marker from left side. */
1919  return &plane_track->markers[a - 1];
1920  }
1921 
1922  while (a >= 0 && plane_track->markers[a].framenr >= framenr) {
1923  if (plane_track->markers[a].framenr == framenr) {
1924  plane_track->last_marker = a;
1925 
1926  return &plane_track->markers[a];
1927  }
1928 
1929  a--;
1930  }
1931 
1932  /* If there's no marker for exact position, use nearest marker from left side. */
1933  return &plane_track->markers[a];
1934 
1935  return NULL;
1936 }
1937 
1939  int framenr)
1940 {
1941  MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1942 
1943  if (plane_marker->framenr != framenr) {
1944  return NULL;
1945  }
1946 
1947  return plane_marker;
1948 }
1949 
1951  int framenr)
1952 {
1953  MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr);
1954 
1955  if (plane_marker->framenr != framenr) {
1956  MovieTrackingPlaneMarker plane_marker_new;
1957 
1958  plane_marker_new = *plane_marker;
1959  plane_marker_new.framenr = framenr;
1960 
1961  plane_marker = BKE_tracking_plane_marker_insert(plane_track, &plane_marker_new);
1962  }
1963 
1964  return plane_marker;
1965 }
1966 
1968  float framenr,
1969  float corners[4][2])
1970 {
1971  MovieTrackingPlaneMarker *marker = BKE_tracking_plane_marker_get(plane_track, (int)framenr);
1972  MovieTrackingPlaneMarker *marker_last = plane_track->markers + (plane_track->markersnr - 1);
1973  if (marker != marker_last) {
1974  MovieTrackingPlaneMarker *marker_next = marker + 1;
1975  if (marker_next->framenr == marker->framenr + 1) {
1976  float fac = (framenr - (int)framenr) / (marker_next->framenr - marker->framenr);
1977  for (int i = 0; i < 4; i++) {
1978  interp_v2_v2v2(corners[i], marker->corners[i], marker_next->corners[i], fac);
1979  }
1980  }
1981  else {
1982  for (int i = 0; i < 4; i++) {
1983  copy_v2_v2(corners[i], marker->corners[i]);
1984  }
1985  }
1986  }
1987  else {
1988  for (int i = 0; i < 4; i++) {
1989  copy_v2_v2(corners[i], marker->corners[i]);
1990  }
1991  }
1992 }
1993 
1994 /* --------------------------------------------------------------------
1995  * Object.
1996  */
1997 
1999 {
2000  MovieTrackingObject *object = MEM_callocN(sizeof(MovieTrackingObject), "tracking object");
2001 
2002  if (tracking->tot_object == 0) {
2003  /* first object is always camera */
2004  BLI_strncpy(object->name, "Camera", sizeof(object->name));
2005 
2006  object->flag |= TRACKING_OBJECT_CAMERA;
2007  }
2008  else {
2009  BLI_strncpy(object->name, name, sizeof(object->name));
2010  }
2011 
2012  BLI_addtail(&tracking->objects, object);
2013 
2014  tracking->tot_object++;
2015  tracking->objectnr = BLI_listbase_count(&tracking->objects) - 1;
2016 
2017  object->scale = 1.0f;
2018  object->keyframe1 = 1;
2019  object->keyframe2 = 30;
2020 
2021  BKE_tracking_object_unique_name(tracking, object);
2023 
2024  return object;
2025 }
2026 
2028 {
2029  MovieTrackingTrack *track;
2030  int index = BLI_findindex(&tracking->objects, object);
2031 
2032  if (index == -1) {
2033  return false;
2034  }
2035 
2036  if (object->flag & TRACKING_OBJECT_CAMERA) {
2037  /* object used for camera solving can't be deleted */
2038  return false;
2039  }
2040 
2041  track = object->tracks.first;
2042  while (track) {
2043  if (track == tracking->act_track) {
2044  tracking->act_track = NULL;
2045  }
2046 
2047  track = track->next;
2048  }
2049 
2050  tracking_object_free(object);
2051  BLI_freelinkN(&tracking->objects, object);
2052 
2053  tracking->tot_object--;
2054 
2055  if (index != 0) {
2056  tracking->objectnr = index - 1;
2057  }
2058  else {
2059  tracking->objectnr = 0;
2060  }
2061 
2063 
2064  return true;
2065 }
2066 
2068 {
2069  BLI_uniquename(&tracking->objects,
2070  object,
2071  DATA_("Object"),
2072  '.',
2073  offsetof(MovieTrackingObject, name),
2074  sizeof(object->name));
2075 }
2076 
2078 {
2079  MovieTrackingObject *object = tracking->objects.first;
2080 
2081  while (object) {
2082  if (STREQ(object->name, name)) {
2083  return object;
2084  }
2085 
2086  object = object->next;
2087  }
2088 
2089  return NULL;
2090 }
2091 
2093 {
2094  return BLI_findlink(&tracking->objects, tracking->objectnr);
2095 }
2096 
2098 {
2099  MovieTrackingObject *object = tracking->objects.first;
2100 
2101  while (object) {
2102  if (object->flag & TRACKING_OBJECT_CAMERA) {
2103  return object;
2104  }
2105 
2106  object = object->next;
2107  }
2108 
2109  return NULL;
2110 }
2111 
2113 {
2114  if (object->flag & TRACKING_OBJECT_CAMERA) {
2115  return &tracking->tracks;
2116  }
2117 
2118  return &object->tracks;
2119 }
2120 
2122  MovieTrackingObject *object)
2123 {
2124  if (object->flag & TRACKING_OBJECT_CAMERA) {
2125  return &tracking->plane_tracks;
2126  }
2127 
2128  return &object->plane_tracks;
2129 }
2130 
2132  MovieTrackingObject *object)
2133 {
2134  if (object->flag & TRACKING_OBJECT_CAMERA) {
2135  return &tracking->reconstruction;
2136  }
2137 
2138  return &object->reconstruction;
2139 }
2140 
2141 /* --------------------------------------------------------------------
2142  * Camera.
2143  */
2144 
2146  int framenr,
2147  bool nearest)
2148 {
2149  MovieReconstructedCamera *cameras = reconstruction->cameras;
2150  int a = 0, d = 1;
2151 
2152  if (!reconstruction->camnr) {
2153  return -1;
2154  }
2155 
2156  if (framenr < cameras[0].framenr) {
2157  if (nearest) {
2158  return 0;
2159  }
2160 
2161  return -1;
2162  }
2163 
2164  if (framenr > cameras[reconstruction->camnr - 1].framenr) {
2165  if (nearest) {
2166  return reconstruction->camnr - 1;
2167  }
2168 
2169  return -1;
2170  }
2171 
2172  if (reconstruction->last_camera < reconstruction->camnr) {
2173  a = reconstruction->last_camera;
2174  }
2175 
2176  if (cameras[a].framenr >= framenr) {
2177  d = -1;
2178  }
2179 
2180  while (a >= 0 && a < reconstruction->camnr) {
2181  int cfra = cameras[a].framenr;
2182 
2183  /* check if needed framenr was "skipped" -- no data for requested frame */
2184 
2185  if (d > 0 && cfra > framenr) {
2186  /* interpolate with previous position */
2187  if (nearest) {
2188  return a - 1;
2189  }
2190 
2191  break;
2192  }
2193 
2194  if (d < 0 && cfra < framenr) {
2195  /* interpolate with next position */
2196  if (nearest) {
2197  return a;
2198  }
2199 
2200  break;
2201  }
2202 
2203  if (cfra == framenr) {
2204  reconstruction->last_camera = a;
2205 
2206  return a;
2207  }
2208 
2209  a += d;
2210  }
2211 
2212  return -1;
2213 }
2214 
2215 static void reconstructed_camera_scale_set(MovieTrackingObject *object, float mat[4][4])
2216 {
2217  if ((object->flag & TRACKING_OBJECT_CAMERA) == 0) {
2218  float smat[4][4];
2219 
2220  scale_m4_fl(smat, 1.0f / object->scale);
2221  mul_m4_m4m4(mat, mat, smat);
2222  }
2223 }
2224 
2226  MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
2227 {
2228  /* Indeed in both of cases it should be winx -
2229  * it's just how camera shift works for blender's camera. */
2230  *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx;
2231  *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx;
2232 }
2233 
2235  MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height)
2236 {
2237  float focal = tracking->camera.focal;
2238 
2239  camera->sensor_x = tracking->camera.sensor_width;
2240  camera->sensor_fit = CAMERA_SENSOR_FIT_AUTO;
2241  camera->lens = focal * camera->sensor_x / width;
2242 
2243  scene->r.xsch = width;
2244  scene->r.ysch = height;
2245 
2246  scene->r.xasp = tracking->camera.pixel_aspect;
2247  scene->r.yasp = 1.0f;
2248 
2249  BKE_tracking_camera_shift_get(tracking, width, height, &camera->shiftx, &camera->shifty);
2250 }
2251 
2253  MovieTrackingObject *object,
2254  int framenr)
2255 {
2257  int a;
2258 
2260  a = reconstructed_camera_index_get(reconstruction, framenr, false);
2261 
2262  if (a == -1) {
2263  return NULL;
2264  }
2265 
2266  return &reconstruction->cameras[a];
2267 }
2268 
2270  MovieTrackingObject *object,
2271  float framenr,
2272  float mat[4][4])
2273 {
2275  MovieReconstructedCamera *cameras;
2276  int a;
2277 
2279  cameras = reconstruction->cameras;
2280  a = reconstructed_camera_index_get(reconstruction, (int)framenr, true);
2281 
2282  if (a == -1) {
2283  unit_m4(mat);
2284  return;
2285  }
2286 
2287  if (cameras[a].framenr != framenr && a < reconstruction->camnr - 1) {
2288  float t = ((float)framenr - cameras[a].framenr) /
2289  (cameras[a + 1].framenr - cameras[a].framenr);
2290  blend_m4_m4m4(mat, cameras[a].mat, cameras[a + 1].mat, t);
2291  }
2292  else {
2293  copy_m4_m4(mat, cameras[a].mat);
2294  }
2295 
2296  reconstructed_camera_scale_set(object, mat);
2297 }
2298 
2299 /* --------------------------------------------------------------------
2300  * (Un)distortion.
2301  */
2302 
2304  int calibration_width,
2305  int calibration_height)
2306 {
2307  MovieDistortion *distortion;
2308  libmv_CameraIntrinsicsOptions camera_intrinsics_options;
2309 
2311  tracking, calibration_width, calibration_height, &camera_intrinsics_options);
2312 
2313  distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
2314  distortion->intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options);
2315 
2316  const MovieTrackingCamera *camera = &tracking->camera;
2317  copy_v2_v2(distortion->principal, camera->principal);
2318  distortion->pixel_aspect = camera->pixel_aspect;
2319  distortion->focal = camera->focal;
2320 
2321  return distortion;
2322 }
2323 
2325  MovieTracking *tracking,
2326  int calibration_width,
2327  int calibration_height)
2328 {
2329  libmv_CameraIntrinsicsOptions camera_intrinsics_options;
2330 
2332  tracking, calibration_width, calibration_height, &camera_intrinsics_options);
2333 
2334  const MovieTrackingCamera *camera = &tracking->camera;
2335  copy_v2_v2(distortion->principal, camera->principal);
2336  distortion->pixel_aspect = camera->pixel_aspect;
2337  distortion->focal = camera->focal;
2338 
2339  libmv_cameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
2340 }
2341 
2343 {
2345 }
2346 
2348 {
2349  MovieDistortion *new_distortion;
2350 
2351  new_distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
2352  *new_distortion = *distortion;
2353  new_distortion->intrinsics = libmv_cameraIntrinsicsCopy(distortion->intrinsics);
2354 
2355  return new_distortion;
2356 }
2357 
2359  MovieTracking *tracking,
2360  ImBuf *ibuf,
2361  int calibration_width,
2362  int calibration_height,
2363  float overscan,
2364  bool undistort)
2365 {
2366  ImBuf *resibuf;
2367 
2368  BKE_tracking_distortion_update(distortion, tracking, calibration_width, calibration_height);
2369 
2370  resibuf = IMB_dupImBuf(ibuf);
2371 
2372  if (ibuf->rect_float) {
2373  if (undistort) {
2375  ibuf->rect_float,
2376  ibuf->x,
2377  ibuf->y,
2378  overscan,
2379  ibuf->channels,
2380  resibuf->rect_float);
2381  }
2382  else {
2384  ibuf->rect_float,
2385  ibuf->x,
2386  ibuf->y,
2387  overscan,
2388  ibuf->channels,
2389  resibuf->rect_float);
2390  }
2391 
2392  if (ibuf->rect) {
2393  imb_freerectImBuf(ibuf);
2394  }
2395  }
2396  else {
2397  if (undistort) {
2399  (unsigned char *)ibuf->rect,
2400  ibuf->x,
2401  ibuf->y,
2402  overscan,
2403  ibuf->channels,
2404  (unsigned char *)resibuf->rect);
2405  }
2406  else {
2408  (unsigned char *)ibuf->rect,
2409  ibuf->x,
2410  ibuf->y,
2411  overscan,
2412  ibuf->channels,
2413  (unsigned char *)resibuf->rect);
2414  }
2415  }
2416 
2417  return resibuf;
2418 }
2419 
2421  const float co[2],
2422  float r_co[2])
2423 {
2424  const float aspy = 1.0f / distortion->pixel_aspect;
2425 
2426  /* Normalize coords. */
2427  float inv_focal = 1.0f / distortion->focal;
2428  double x = (co[0] - distortion->principal[0]) * inv_focal,
2429  y = (co[1] - distortion->principal[1] * aspy) * inv_focal;
2430 
2431  libmv_cameraIntrinsicsApply(distortion->intrinsics, x, y, &x, &y);
2432 
2433  /* Result is in image coords already. */
2434  r_co[0] = x;
2435  r_co[1] = y;
2436 }
2437 
2439  const float co[2],
2440  float r_co[2])
2441 {
2442  double x = co[0], y = co[1];
2443  libmv_cameraIntrinsicsInvert(distortion->intrinsics, x, y, &x, &y);
2444 
2445  const float aspy = 1.0f / distortion->pixel_aspect;
2446  r_co[0] = (float)x * distortion->focal + distortion->principal[0];
2447  r_co[1] = (float)y * distortion->focal + distortion->principal[1] * aspy;
2448 }
2449 
2451 {
2453 
2454  MEM_freeN(distortion);
2455 }
2456 
2458  MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
2459 {
2460  const MovieTrackingCamera *camera = &tracking->camera;
2461  const float aspy = 1.0f / tracking->camera.pixel_aspect;
2462 
2463  libmv_CameraIntrinsicsOptions camera_intrinsics_options;
2465  tracking, image_width, image_height, &camera_intrinsics_options);
2466  libmv_CameraIntrinsics *intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options);
2467 
2468  /* Normalize coordinates. */
2469  double x = (co[0] - camera->principal[0]) / camera->focal,
2470  y = (co[1] - camera->principal[1] * aspy) / camera->focal;
2471 
2472  libmv_cameraIntrinsicsApply(intrinsics, x, y, &x, &y);
2473  libmv_cameraIntrinsicsDestroy(intrinsics);
2474 
2475  /* Result is in image coords already. */
2476  r_co[0] = x;
2477  r_co[1] = y;
2478 }
2479 
2481  MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
2482 {
2483  const MovieTrackingCamera *camera = &tracking->camera;
2484  const float aspy = 1.0f / tracking->camera.pixel_aspect;
2485 
2486  libmv_CameraIntrinsicsOptions camera_intrinsics_options;
2488  tracking, image_width, image_height, &camera_intrinsics_options);
2489  libmv_CameraIntrinsics *intrinsics = libmv_cameraIntrinsicsNew(&camera_intrinsics_options);
2490 
2491  double x = co[0], y = co[1];
2492  libmv_cameraIntrinsicsInvert(intrinsics, x, y, &x, &y);
2493  libmv_cameraIntrinsicsDestroy(intrinsics);
2494 
2495  r_co[0] = (float)x * camera->focal + camera->principal[0];
2496  r_co[1] = (float)y * camera->focal + camera->principal[1] * aspy;
2497 }
2498 
2500  ImBuf *ibuf,
2501  int calibration_width,
2502  int calibration_height,
2503  float overscan)
2504 {
2505  MovieTrackingCamera *camera = &tracking->camera;
2506 
2507  if (camera->intrinsics == NULL) {
2508  camera->intrinsics = BKE_tracking_distortion_new(
2509  tracking, calibration_width, calibration_height);
2510  }
2511 
2513  camera->intrinsics, tracking, ibuf, calibration_width, calibration_height, overscan, true);
2514 }
2515 
2517  ImBuf *ibuf,
2518  int calibration_width,
2519  int calibration_height,
2520  float overscan)
2521 {
2522  MovieTrackingCamera *camera = &tracking->camera;
2523 
2524  if (camera->intrinsics == NULL) {
2525  camera->intrinsics = BKE_tracking_distortion_new(
2526  tracking, calibration_width, calibration_height);
2527  }
2528 
2530  camera->intrinsics, tracking, ibuf, calibration_width, calibration_height, overscan, false);
2531 }
2532 
2534  int image_width,
2535  int image_height,
2536  rcti *rect,
2537  bool undistort,
2538  float delta[2])
2539 {
2540  float pos[2], warped_pos[2];
2541  const int coord_delta = 5;
2542  void (*apply_distortion)(MovieTracking * tracking,
2543  int image_width,
2544  int image_height,
2545  const float pos[2],
2546  float out[2]);
2547 
2548  if (undistort) {
2549  apply_distortion = BKE_tracking_undistort_v2;
2550  }
2551  else {
2552  apply_distortion = BKE_tracking_distort_v2;
2553  }
2554 
2555  delta[0] = delta[1] = -FLT_MAX;
2556 
2557  for (int a = rect->xmin; a <= rect->xmax + coord_delta; a += coord_delta) {
2558  if (a > rect->xmax) {
2559  a = rect->xmax;
2560  }
2561 
2562  /* bottom edge */
2563  pos[0] = a;
2564  pos[1] = rect->ymin;
2565 
2566  apply_distortion(tracking, image_width, image_height, pos, warped_pos);
2567 
2568  delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
2569  delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
2570 
2571  /* top edge */
2572  pos[0] = a;
2573  pos[1] = rect->ymax;
2574 
2575  apply_distortion(tracking, image_width, image_height, pos, warped_pos);
2576 
2577  delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
2578  delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
2579 
2580  if (a >= rect->xmax) {
2581  break;
2582  }
2583  }
2584 
2585  for (int a = rect->ymin; a <= rect->ymax + coord_delta; a += coord_delta) {
2586  if (a > rect->ymax) {
2587  a = rect->ymax;
2588  }
2589 
2590  /* left edge */
2591  pos[0] = rect->xmin;
2592  pos[1] = a;
2593 
2594  apply_distortion(tracking, image_width, image_height, pos, warped_pos);
2595 
2596  delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
2597  delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
2598 
2599  /* right edge */
2600  pos[0] = rect->xmax;
2601  pos[1] = a;
2602 
2603  apply_distortion(tracking, image_width, image_height, pos, warped_pos);
2604 
2605  delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
2606  delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
2607 
2608  if (a >= rect->ymax) {
2609  break;
2610  }
2611  }
2612 }
2613 
2614 /* --------------------------------------------------------------------
2615  * Image sampling.
2616  */
2617 
2618 static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, bool grayscale)
2619 {
2621  track->flag & TRACK_DISABLE_RED,
2622  track->flag & TRACK_DISABLE_GREEN,
2623  track->flag & TRACK_DISABLE_BLUE,
2624  grayscale);
2625 }
2626 
2628  int frame_height,
2629  ImBuf *search_ibuf,
2630  MovieTrackingTrack *track,
2631  MovieTrackingMarker *marker,
2632  bool from_anchor,
2633  bool use_mask,
2634  int num_samples_x,
2635  int num_samples_y,
2636  float pos[2])
2637 {
2638  ImBuf *pattern_ibuf;
2639  double src_pixel_x[5], src_pixel_y[5];
2640  double warped_position_x, warped_position_y;
2641  float *mask = NULL;
2642 
2643  if (num_samples_x <= 0 || num_samples_y <= 0) {
2644  return NULL;
2645  }
2646 
2647  pattern_ibuf = IMB_allocImBuf(
2648  num_samples_x, num_samples_y, 32, search_ibuf->rect_float ? IB_rectfloat : IB_rect);
2649 
2651  frame_width, frame_height, marker, src_pixel_x, src_pixel_y);
2652 
2653  /* from_anchor means search buffer was obtained for an anchored position,
2654  * which means applying track offset rounded to pixel space (we could not
2655  * store search buffer with sub-pixel precision)
2656  *
2657  * in this case we need to alter coordinates a bit, to compensate rounded
2658  * fractional part of offset
2659  */
2660  if (from_anchor) {
2661  for (int a = 0; a < 5; a++) {
2662  src_pixel_x[a] += (double)((track->offset[0] * frame_width) -
2663  ((int)(track->offset[0] * frame_width)));
2664  src_pixel_y[a] += (double)((track->offset[1] * frame_height) -
2665  ((int)(track->offset[1] * frame_height)));
2666 
2667  /* when offset is negative, rounding happens in opposite direction */
2668  if (track->offset[0] < 0.0f) {
2669  src_pixel_x[a] += 1.0;
2670  }
2671  if (track->offset[1] < 0.0f) {
2672  src_pixel_y[a] += 1.0;
2673  }
2674  }
2675  }
2676 
2677  if (use_mask) {
2678  mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
2679  }
2680 
2681  if (search_ibuf->rect_float) {
2683  search_ibuf->x,
2684  search_ibuf->y,
2685  4,
2686  src_pixel_x,
2687  src_pixel_y,
2688  num_samples_x,
2689  num_samples_y,
2690  mask,
2691  pattern_ibuf->rect_float,
2692  &warped_position_x,
2693  &warped_position_y);
2694  }
2695  else {
2696  libmv_samplePlanarPatchByte((unsigned char *)search_ibuf->rect,
2697  search_ibuf->x,
2698  search_ibuf->y,
2699  4,
2700  src_pixel_x,
2701  src_pixel_y,
2702  num_samples_x,
2703  num_samples_y,
2704  mask,
2705  (unsigned char *)pattern_ibuf->rect,
2706  &warped_position_x,
2707  &warped_position_y);
2708  }
2709 
2710  if (pos) {
2711  pos[0] = warped_position_x;
2712  pos[1] = warped_position_y;
2713  }
2714 
2715  if (mask) {
2716  MEM_freeN(mask);
2717  }
2718 
2719  return pattern_ibuf;
2720 }
2721 
2723  MovieTrackingTrack *track,
2724  MovieTrackingMarker *marker,
2725  bool anchored,
2726  bool disable_channels)
2727 {
2728  ImBuf *pattern_ibuf, *search_ibuf;
2729  float pat_min[2], pat_max[2];
2730  int num_samples_x, num_samples_y;
2731 
2732  BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
2733 
2734  num_samples_x = (pat_max[0] - pat_min[0]) * ibuf->x;
2735  num_samples_y = (pat_max[1] - pat_min[1]) * ibuf->y;
2736 
2737  search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels);
2738 
2739  if (search_ibuf) {
2740  pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x,
2741  ibuf->y,
2742  search_ibuf,
2743  track,
2744  marker,
2745  anchored,
2746  false,
2747  num_samples_x,
2748  num_samples_y,
2749  NULL);
2750 
2751  IMB_freeImBuf(search_ibuf);
2752  }
2753  else {
2754  pattern_ibuf = NULL;
2755  }
2756 
2757  return pattern_ibuf;
2758 }
2759 
2761  MovieTrackingTrack *track,
2762  MovieTrackingMarker *marker,
2763  bool anchored,
2764  bool disable_channels)
2765 {
2766  ImBuf *searchibuf;
2767  int x, y, w, h;
2768  float search_origin[2];
2769 
2770  tracking_get_search_origin_frame_pixel(ibuf->x, ibuf->y, marker, search_origin);
2771 
2772  x = search_origin[0];
2773  y = search_origin[1];
2774 
2775  if (anchored) {
2776  x += track->offset[0] * ibuf->x;
2777  y += track->offset[1] * ibuf->y;
2778  }
2779 
2780  w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
2781  h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
2782 
2783  if (w <= 0 || h <= 0) {
2784  return NULL;
2785  }
2786 
2787  searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
2788 
2789  IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h);
2790 
2791  if (disable_channels) {
2792  if ((track->flag & TRACK_PREVIEW_GRAYSCALE) || (track->flag & TRACK_DISABLE_RED) ||
2793  (track->flag & TRACK_DISABLE_GREEN) || (track->flag & TRACK_DISABLE_BLUE)) {
2794  disable_imbuf_channels(searchibuf, track, true);
2795  }
2796  }
2797 
2798  return searchibuf;
2799 }
2800 
2802  const float b[2],
2803  const int frame_width,
2804  const int frame_height)
2805 {
2806  const float a_px[2] = {a[0] * frame_width, a[1] * frame_height};
2807  const float b_px[2] = {b[0] * frame_width, b[1] * frame_height};
2808 
2809  return ceilf(len_v2v2(a_px, b_px));
2810 }
2811 
2813  const MovieTrackingPlaneMarker *plane_marker)
2814 {
2815  /* Alias for corners, allowing shorter access to coordinates. */
2816  const float(*corners)[2] = plane_marker->corners;
2817 
2818  /* Dimensions of the frame image in pixels. */
2819  const int frame_width = frame_ibuf->x;
2820  const int frame_height = frame_ibuf->y;
2821 
2822  /* Lengths of left and right edges of the plane marker, in pixels. */
2823  const int left_side_len_px = plane_marker_size_len_in_pixels(
2824  corners[0], corners[3], frame_width, frame_height);
2825  const int right_side_len_px = plane_marker_size_len_in_pixels(
2826  corners[1], corners[2], frame_width, frame_height);
2827 
2828  /* Lengths of top and bottom edges of the plane marker, in pixels. */
2829  const int top_side_len_px = plane_marker_size_len_in_pixels(
2830  corners[3], corners[2], frame_width, frame_height);
2831  const int bottom_side_len_px = plane_marker_size_len_in_pixels(
2832  corners[0], corners[1], frame_width, frame_height);
2833 
2834  /* Choose the number of samples as a maximum of the corresponding sides in pixels. */
2835  const int num_samples_x = max_ii(top_side_len_px, bottom_side_len_px);
2836  const int num_samples_y = max_ii(left_side_len_px, right_side_len_px);
2837 
2838  /* Create new result image with the same type of content as the original. */
2839  ImBuf *plane_ibuf = IMB_allocImBuf(
2840  num_samples_x, num_samples_y, 32, frame_ibuf->rect_float ? IB_rectfloat : IB_rect);
2841 
2842  /* Calculate corner coordinates in pixel space, as separate X/Y arrays. */
2843  const double src_pixel_x[4] = {corners[0][0] * frame_width,
2844  corners[1][0] * frame_width,
2845  corners[2][0] * frame_width,
2846  corners[3][0] * frame_width};
2847  const double src_pixel_y[4] = {corners[0][1] * frame_height,
2848  corners[1][1] * frame_height,
2849  corners[2][1] * frame_height,
2850  corners[3][1] * frame_height};
2851 
2852  /* Warped Position is unused but is expected to be provided by the API. */
2853  double warped_position_x, warped_position_y;
2854 
2855  /* Actual sampling. */
2856  if (frame_ibuf->rect_float != NULL) {
2858  frame_ibuf->x,
2859  frame_ibuf->y,
2860  4,
2861  src_pixel_x,
2862  src_pixel_y,
2863  num_samples_x,
2864  num_samples_y,
2865  NULL,
2866  plane_ibuf->rect_float,
2867  &warped_position_x,
2868  &warped_position_y);
2869  }
2870  else {
2871  libmv_samplePlanarPatchByte((unsigned char *)frame_ibuf->rect,
2872  frame_ibuf->x,
2873  frame_ibuf->y,
2874  4,
2875  src_pixel_x,
2876  src_pixel_y,
2877  num_samples_x,
2878  num_samples_y,
2879  NULL,
2880  (unsigned char *)plane_ibuf->rect,
2881  &warped_position_x,
2882  &warped_position_y);
2883  }
2884 
2885  plane_ibuf->rect_colorspace = frame_ibuf->rect_colorspace;
2886  plane_ibuf->float_colorspace = frame_ibuf->float_colorspace;
2887 
2888  return plane_ibuf;
2889 }
2890 
2892  ImBuf *ibuf, bool disable_red, bool disable_green, bool disable_blue, bool grayscale)
2893 {
2894  if (!disable_red && !disable_green && !disable_blue && !grayscale) {
2895  return;
2896  }
2897 
2898  /* if only some components are selected, it's important to rescale the result
2899  * appropriately so that e.g. if only blue is selected, it's not zeroed out.
2900  */
2901  float scale = (disable_red ? 0.0f : 0.2126f) + (disable_green ? 0.0f : 0.7152f) +
2902  (disable_blue ? 0.0f : 0.0722f);
2903 
2904  for (int y = 0; y < ibuf->y; y++) {
2905  for (int x = 0; x < ibuf->x; x++) {
2906  int pixel = ibuf->x * y + x;
2907 
2908  if (ibuf->rect_float) {
2909  float *rrgbf = ibuf->rect_float + pixel * 4;
2910  float r = disable_red ? 0.0f : rrgbf[0];
2911  float g = disable_green ? 0.0f : rrgbf[1];
2912  float b = disable_blue ? 0.0f : rrgbf[2];
2913 
2914  if (grayscale) {
2915  float gray = (0.2126f * r + 0.7152f * g + 0.0722f * b) / scale;
2916 
2917  rrgbf[0] = rrgbf[1] = rrgbf[2] = gray;
2918  }
2919  else {
2920  rrgbf[0] = r;
2921  rrgbf[1] = g;
2922  rrgbf[2] = b;
2923  }
2924  }
2925  else {
2926  char *rrgb = (char *)ibuf->rect + pixel * 4;
2927  char r = disable_red ? 0 : rrgb[0];
2928  char g = disable_green ? 0 : rrgb[1];
2929  char b = disable_blue ? 0 : rrgb[2];
2930 
2931  if (grayscale) {
2932  float gray = (0.2126f * r + 0.7152f * g + 0.0722f * b) / scale;
2933 
2934  rrgb[0] = rrgb[1] = rrgb[2] = gray;
2935  }
2936  else {
2937  rrgb[0] = r;
2938  rrgb[1] = g;
2939  rrgb[2] = b;
2940  }
2941  }
2942  }
2943  }
2944 
2945  if (ibuf->rect_float) {
2946  ibuf->userflags |= IB_RECT_INVALID;
2947  }
2948 }
2949 
2950 /* --------------------------------------------------------------------
2951  * Dopesheet functions.
2952  */
2953 
2954 /* ** Channels sort comparators ** */
2955 
2956 static int channels_alpha_sort(const void *a, const void *b)
2957 {
2958  const MovieTrackingDopesheetChannel *channel_a = a;
2959  const MovieTrackingDopesheetChannel *channel_b = b;
2960 
2961  if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0) {
2962  return 1;
2963  }
2964 
2965  return 0;
2966 }
2967 
2968 static int channels_total_track_sort(const void *a, const void *b)
2969 {
2970  const MovieTrackingDopesheetChannel *channel_a = a;
2971  const MovieTrackingDopesheetChannel *channel_b = b;
2972 
2973  if (channel_a->total_frames > channel_b->total_frames) {
2974  return 1;
2975  }
2976 
2977  return 0;
2978 }
2979 
2980 static int channels_longest_segment_sort(const void *a, const void *b)
2981 {
2982  const MovieTrackingDopesheetChannel *channel_a = a;
2983  const MovieTrackingDopesheetChannel *channel_b = b;
2984 
2985  if (channel_a->max_segment > channel_b->max_segment) {
2986  return 1;
2987  }
2988 
2989  return 0;
2990 }
2991 
2992 static int channels_average_error_sort(const void *a, const void *b)
2993 {
2994  const MovieTrackingDopesheetChannel *channel_a = a;
2995  const MovieTrackingDopesheetChannel *channel_b = b;
2996 
2997  if (channel_a->track->error > channel_b->track->error) {
2998  return 1;
2999  }
3000 
3001  if (channel_a->track->error == channel_b->track->error) {
3002  return channels_alpha_sort(a, b);
3003  }
3004 
3005  return 0;
3006 }
3007 
3009  bool inverse, bool a_markerless, int a_value, bool b_markerless, int b_value)
3010 {
3011  if (a_markerless && b_markerless) {
3012  /* Neither channel has not-disabled markers, return whatever. */
3013  return 0;
3014  }
3015  if (a_markerless) {
3016  /* Put the markerless channel first. */
3017  return 0;
3018  }
3019  if (b_markerless) {
3020  /* Put the markerless channel first. */
3021  return 1;
3022  }
3023 
3024  /* Both channels have markers. */
3025 
3026  if (inverse) {
3027  if (a_value < b_value) {
3028  return 1;
3029  }
3030  return 0;
3031  }
3032 
3033  if (a_value > b_value) {
3034  return 1;
3035  }
3036  return 0;
3037 }
3038 
3039 static int channels_start_sort(const void *a, const void *b)
3040 {
3041  const MovieTrackingDopesheetChannel *channel_a = a;
3042  const MovieTrackingDopesheetChannel *channel_b = b;
3043 
3045  channel_a->tot_segment == 0,
3047  channel_b->tot_segment == 0,
3049 }
3050 
3051 static int channels_end_sort(const void *a, const void *b)
3052 {
3053  const MovieTrackingDopesheetChannel *channel_a = a;
3054  const MovieTrackingDopesheetChannel *channel_b = b;
3055 
3057  channel_a->tot_segment == 0,
3059  channel_b->tot_segment == 0,
3061 }
3062 
3063 static int channels_alpha_inverse_sort(const void *a, const void *b)
3064 {
3065  if (channels_alpha_sort(a, b)) {
3066  return 0;
3067  }
3068 
3069  return 1;
3070 }
3071 
3072 static int channels_total_track_inverse_sort(const void *a, const void *b)
3073 {
3074  if (channels_total_track_sort(a, b)) {
3075  return 0;
3076  }
3077 
3078  return 1;
3079 }
3080 
3081 static int channels_longest_segment_inverse_sort(const void *a, const void *b)
3082 {
3084  return 0;
3085  }
3086 
3087  return 1;
3088 }
3089 
3090 static int channels_average_error_inverse_sort(const void *a, const void *b)
3091 {
3092  const MovieTrackingDopesheetChannel *channel_a = a;
3093  const MovieTrackingDopesheetChannel *channel_b = b;
3094 
3095  if (channel_a->track->error < channel_b->track->error) {
3096  return 1;
3097  }
3098 
3099  return 0;
3100 }
3101 
3102 static int channels_start_inverse_sort(const void *a, const void *b)
3103 {
3104  const MovieTrackingDopesheetChannel *channel_a = a;
3105  const MovieTrackingDopesheetChannel *channel_b = b;
3106 
3108  channel_a->tot_segment == 0,
3110  channel_b->tot_segment == 0,
3112 }
3113 
3114 static int channels_end_inverse_sort(const void *a, const void *b)
3115 {
3116  const MovieTrackingDopesheetChannel *channel_a = a;
3117  const MovieTrackingDopesheetChannel *channel_b = b;
3118 
3120  channel_a->tot_segment == 0,
3122  channel_b->tot_segment == 0,
3124 }
3125 
3126 /* Calculate frames segments at which track is tracked continuously. */
3128 {
3129  MovieTrackingTrack *track = channel->track;
3130  int i, segment;
3131  bool first_not_disabled_marker_framenr_set;
3132 
3133  channel->tot_segment = 0;
3134  channel->max_segment = 0;
3135  channel->total_frames = 0;
3136 
3137  channel->first_not_disabled_marker_framenr = 0;
3138  channel->last_not_disabled_marker_framenr = 0;
3139 
3140  /* TODO(sergey): looks a bit code-duplicated, need to look into
3141  * logic de-duplication here.
3142  */
3143 
3144  /* count */
3145  i = 0;
3146  first_not_disabled_marker_framenr_set = false;
3147  while (i < track->markersnr) {
3148  MovieTrackingMarker *marker = &track->markers[i];
3149 
3150  if ((marker->flag & MARKER_DISABLED) == 0) {
3151  int prev_fra = marker->framenr, len = 0;
3152 
3153  i++;
3154  while (i < track->markersnr) {
3155  marker = &track->markers[i];
3156 
3157  if (marker->framenr != prev_fra + 1) {
3158  break;
3159  }
3160  if (marker->flag & MARKER_DISABLED) {
3161  break;
3162  }
3163 
3164  if (!first_not_disabled_marker_framenr_set) {
3165  channel->first_not_disabled_marker_framenr = marker->framenr;
3166  first_not_disabled_marker_framenr_set = true;
3167  }
3168  channel->last_not_disabled_marker_framenr = marker->framenr;
3169 
3170  prev_fra = marker->framenr;
3171  len++;
3172  i++;
3173  }
3174 
3175  channel->tot_segment++;
3176  }
3177 
3178  i++;
3179  }
3180 
3181  if (!channel->tot_segment) {
3182  return;
3183  }
3184 
3185  channel->segments = MEM_callocN(sizeof(int[2]) * channel->tot_segment,
3186  "tracking channel segments");
3187 
3188  /* create segments */
3189  i = 0;
3190  segment = 0;
3191  while (i < track->markersnr) {
3192  MovieTrackingMarker *marker = &track->markers[i];
3193 
3194  if ((marker->flag & MARKER_DISABLED) == 0) {
3195  MovieTrackingMarker *start_marker = marker;
3196  int prev_fra = marker->framenr, len = 0;
3197 
3198  i++;
3199  while (i < track->markersnr) {
3200  marker = &track->markers[i];
3201 
3202  if (marker->framenr != prev_fra + 1) {
3203  break;
3204  }
3205  if (marker->flag & MARKER_DISABLED) {
3206  break;
3207  }
3208 
3209  prev_fra = marker->framenr;
3210  channel->total_frames++;
3211  len++;
3212  i++;
3213  }
3214 
3215  channel->segments[2 * segment] = start_marker->framenr;
3216  channel->segments[2 * segment + 1] = start_marker->framenr + len;
3217 
3218  channel->max_segment = max_ii(channel->max_segment, len);
3219  segment++;
3220  }
3221 
3222  i++;
3223  }
3224 }
3225 
3226 /* Create channels for tracks and calculate tracked segments for them. */
3228 {
3230  MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
3232  object);
3233  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
3234 
3235  bool sel_only = (dopesheet->flag & TRACKING_DOPE_SELECTED_ONLY) != 0;
3236  bool show_hidden = (dopesheet->flag & TRACKING_DOPE_SHOW_HIDDEN) != 0;
3237 
3238  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
3239  if (!show_hidden && (track->flag & TRACK_HIDDEN) != 0) {
3240  continue;
3241  }
3242 
3243  if (sel_only && !TRACK_SELECTED(track)) {
3244  continue;
3245  }
3246 
3248  "tracking dopesheet channel");
3249  channel->track = track;
3250 
3251  if (reconstruction->flag & TRACKING_RECONSTRUCTED) {
3252  BLI_snprintf(channel->name, sizeof(channel->name), "%s (%.4f)", track->name, track->error);
3253  }
3254  else {
3255  BLI_strncpy(channel->name, track->name, sizeof(channel->name));
3256  }
3257 
3259 
3260  BLI_addtail(&dopesheet->channels, channel);
3261  dopesheet->tot_channel++;
3262  }
3263 }
3264 
3265 /* Sot dopesheet channels using given method (name, average error, total coverage,
3266  * longest tracked segment) and could also inverse the list if it's enabled.
3267  */
3269  int sort_method,
3270  bool inverse)
3271 {
3272  MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
3273 
3274  if (inverse) {
3275  if (sort_method == TRACKING_DOPE_SORT_NAME) {
3277  }
3278  else if (sort_method == TRACKING_DOPE_SORT_LONGEST) {
3280  }
3281  else if (sort_method == TRACKING_DOPE_SORT_TOTAL) {
3283  }
3284  else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) {
3286  }
3287  else if (sort_method == TRACKING_DOPE_SORT_START) {
3289  }
3290  else if (sort_method == TRACKING_DOPE_SORT_END) {
3292  }
3293  }
3294  else {
3295  if (sort_method == TRACKING_DOPE_SORT_NAME) {
3297  }
3298  else if (sort_method == TRACKING_DOPE_SORT_LONGEST) {
3300  }
3301  else if (sort_method == TRACKING_DOPE_SORT_TOTAL) {
3303  }
3304  else if (sort_method == TRACKING_DOPE_SORT_AVERAGE_ERROR) {
3306  }
3307  else if (sort_method == TRACKING_DOPE_SORT_START) {
3309  }
3310  else if (sort_method == TRACKING_DOPE_SORT_END) {
3312  }
3313  }
3314 }
3315 
3317 {
3318  /* Values are actually arbitrary here, probably need to be tweaked. */
3319  if (count < 8) {
3320  return TRACKING_COVERAGE_BAD;
3321  }
3322  if (count < 16) {
3324  }
3325  return TRACKING_COVERAGE_OK;
3326 }
3327 
3328 /* Calculate coverage of frames with tracks, this information
3329  * is used to highlight dopesheet background depending on how
3330  * many tracks exists on the frame.
3331  */
3333 {
3334  MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
3336  ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
3337  int frames, start_frame = INT_MAX, end_frame = -INT_MAX;
3338  int *per_frame_counter;
3339  int prev_coverage, last_segment_frame;
3340 
3341  /* find frame boundaries */
3342  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
3343  start_frame = min_ii(start_frame, track->markers[0].framenr);
3344  end_frame = max_ii(end_frame, track->markers[track->markersnr - 1].framenr);
3345  }
3346 
3347  if (start_frame > end_frame) {
3348  /* There are no markers at all, nothing to calculate coverage from. */
3349  return;
3350  }
3351 
3352  frames = end_frame - start_frame + 1;
3353 
3354  /* this is a per-frame counter of markers (how many markers belongs to the same frame) */
3355  per_frame_counter = MEM_callocN(sizeof(int) * frames, "per frame track counter");
3356 
3357  /* find per-frame markers count */
3358  LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
3359  for (int i = 0; i < track->markersnr; i++) {
3360  MovieTrackingMarker *marker = &track->markers[i];
3361 
3362  /* TODO: perhaps we need to add check for non-single-frame track here */
3363  if ((marker->flag & MARKER_DISABLED) == 0) {
3364  per_frame_counter[marker->framenr - start_frame]++;
3365  }
3366  }
3367  }
3368 
3369  /* convert markers count to coverage and detect segments with the same coverage */
3370  prev_coverage = coverage_from_count(per_frame_counter[0]);
3371  last_segment_frame = start_frame;
3372 
3373  /* means only disabled tracks in the beginning, could be ignored */
3374  if (!per_frame_counter[0]) {
3375  prev_coverage = TRACKING_COVERAGE_OK;
3376  }
3377 
3378  for (int i = 1; i < frames; i++) {
3379  int coverage = coverage_from_count(per_frame_counter[i]);
3380 
3381  /* means only disabled tracks in the end, could be ignored */
3382  if (i == frames - 1 && !per_frame_counter[i]) {
3383  coverage = TRACKING_COVERAGE_OK;
3384  }
3385 
3386  if (coverage != prev_coverage || i == frames - 1) {
3387  MovieTrackingDopesheetCoverageSegment *coverage_segment;
3388  int end_segment_frame = i - 1 + start_frame;
3389 
3390  if (end_segment_frame == last_segment_frame) {
3391  end_segment_frame++;
3392  }
3393 
3394  coverage_segment = MEM_callocN(sizeof(MovieTrackingDopesheetCoverageSegment),
3395  "tracking coverage segment");
3396  coverage_segment->coverage = prev_coverage;
3397  coverage_segment->start_frame = last_segment_frame;
3398  coverage_segment->end_frame = end_segment_frame;
3399 
3400  BLI_addtail(&dopesheet->coverage_segments, coverage_segment);
3401 
3402  last_segment_frame = end_segment_frame;
3403  }
3404 
3405  prev_coverage = coverage;
3406  }
3407 
3408  MEM_freeN(per_frame_counter);
3409 }
3410 
3412 {
3413  MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
3414 
3415  dopesheet->ok = false;
3416 }
3417 
3419 {
3420  MovieTrackingDopesheet *dopesheet = &tracking->dopesheet;
3421 
3422  short sort_method = dopesheet->sort_method;
3423  bool inverse = (dopesheet->flag & TRACKING_DOPE_SORT_INVERSE) != 0;
3424 
3425  if (dopesheet->ok) {
3426  return;
3427  }
3428 
3429  tracking_dopesheet_free(dopesheet);
3430 
3431  /* channels */
3433  tracking_dopesheet_channels_sort(tracking, sort_method, inverse);
3434 
3435  /* frame coverage */
3437 
3438  dopesheet->ok = true;
3439 }
3440 
3442  const MovieTrackingTrack *track)
3443 {
3444  const ListBase *tracksbase = &tracking->tracks;
3445  if (BLI_findindex(tracksbase, track) != -1) {
3446  return NULL;
3447  }
3448  MovieTrackingObject *object = tracking->objects.first;
3449  while (object != NULL) {
3450  if (BLI_findindex(&object->tracks, track) != -1) {
3451  return object;
3452  }
3453  object = object->next;
3454  }
3455  return NULL;
3456 }
3457 
3459  const MovieTrackingTrack *track)
3460 {
3461  MovieTrackingObject *object = BKE_tracking_find_object_for_track(tracking, track);
3462  if (object != NULL) {
3463  return &object->tracks;
3464  }
3465  return &tracking->tracks;
3466 }
3467 
3469  const MovieTracking *tracking, const MovieTrackingPlaneTrack *plane_track)
3470 {
3471  const ListBase *plane_tracks_base = &tracking->plane_tracks;
3472  if (BLI_findindex(plane_tracks_base, plane_track) != -1) {
3473  return NULL;
3474  }
3475  MovieTrackingObject *object = tracking->objects.first;
3476  while (object != NULL) {
3477  if (BLI_findindex(&object->plane_tracks, plane_track) != -1) {
3478  return object;
3479  }
3480  object = object->next;
3481  }
3482  return NULL;
3483 }
3484 
3486  const MovieTrackingPlaneTrack *plane_track)
3487 {
3488  MovieTrackingObject *object = BKE_tracking_find_object_for_plane_track(tracking, plane_track);
3489  if (object != NULL) {
3490  return &object->plane_tracks;
3491  }
3492  return &tracking->plane_tracks;
3493 }
3494 
3496  const struct MovieTrackingTrack *track,
3497  char *rna_path,
3498  size_t rna_path_len)
3499 {
3500  MovieTrackingObject *object = BKE_tracking_find_object_for_track(tracking, track);
3501  char track_name_esc[MAX_NAME * 2];
3502  BLI_str_escape(track_name_esc, track->name, sizeof(track_name_esc));
3503  if (object == NULL) {
3504  BLI_snprintf(rna_path, rna_path_len, "tracking.tracks[\"%s\"]", track_name_esc);
3505  }
3506  else {
3507  char object_name_esc[MAX_NAME * 2];
3508  BLI_str_escape(object_name_esc, object->name, sizeof(object_name_esc));
3509  BLI_snprintf(rna_path,
3510  rna_path_len,
3511  "tracking.objects[\"%s\"].tracks[\"%s\"]",
3512  object_name_esc,
3513  track_name_esc);
3514  }
3515 }
3516 
3518  const struct MovieTrackingTrack *track,
3519  char *rna_path,
3520  size_t rna_path_len)
3521 {
3522  MovieTrackingObject *object = BKE_tracking_find_object_for_track(tracking, track);
3523  if (object == NULL) {
3524  BLI_strncpy(rna_path, "tracking.tracks", rna_path_len);
3525  }
3526  else {
3527  char object_name_esc[MAX_NAME * 2];
3528  BLI_str_escape(object_name_esc, object->name, sizeof(object_name_esc));
3529  BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"]", object_name_esc);
3530  }
3531 }
3532 
3534  const struct MovieTrackingPlaneTrack *plane_track,
3535  char *rna_path,
3536  size_t rna_path_len)
3537 {
3538  MovieTrackingObject *object = BKE_tracking_find_object_for_plane_track(tracking, plane_track);
3539  char track_name_esc[MAX_NAME * 2];
3540  BLI_str_escape(track_name_esc, plane_track->name, sizeof(track_name_esc));
3541  if (object == NULL) {
3542  BLI_snprintf(rna_path, rna_path_len, "tracking.plane_tracks[\"%s\"]", track_name_esc);
3543  }
3544  else {
3545  char object_name_esc[MAX_NAME * 2];
3546  BLI_str_escape(object_name_esc, object->name, sizeof(object_name_esc));
3547  BLI_snprintf(rna_path,
3548  rna_path_len,
3549  "tracking.objects[\"%s\"].plane_tracks[\"%s\"]",
3550  object_name_esc,
3551  track_name_esc);
3552  }
3553 }
3554 
3556  const struct MovieTracking *tracking,
3557  const struct MovieTrackingPlaneTrack *plane_track,
3558  char *rna_path,
3559  size_t rna_path_len)
3560 {
3561  MovieTrackingObject *object = BKE_tracking_find_object_for_plane_track(tracking, plane_track);
3562  if (object == NULL) {
3563  BLI_strncpy(rna_path, "tracking.plane_tracks", rna_path_len);
3564  }
3565  else {
3566  char object_name_esc[MAX_NAME * 2];
3567  BLI_str_escape(object_name_esc, object->name, sizeof(object_name_esc));
3568  BLI_snprintf(rna_path, rna_path_len, "tracking.objects[\"%s\"].plane_tracks", object_name_esc);
3569  }
3570 }
typedef float(TangentPoint)[2]
float evaluate_fcurve(struct FCurve *fcu, float evaltime)
Definition: fcurve.c:2135
struct FCurve * id_data_find_fcurve(ID *id, void *data, struct StructRNA *type, const char *prop_name, int index, bool *r_driven)
Definition: fcurve.c:201
@ LIB_ID_CREATE_NO_USER_REFCOUNT
Definition: BKE_lib_id.h:126
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
float BKE_movieclip_remap_clip_to_scene_frame(const struct MovieClip *clip, float framenr)
General operations, lookup, etc. for blender objects.
void BKE_object_where_is_calc_mat4(struct Object *ob, float r_obmat[4][4])
Definition: object.cc:3478
@ TRACK_AREA_POINT
Definition: BKE_tracking.h:38
@ TRACK_AREA_ALL
Definition: BKE_tracking.h:43
@ TRACK_AREA_PAT
Definition: BKE_tracking.h:39
@ TRACK_AREA_SEARCH
Definition: BKE_tracking.h:40
@ TRACK_AREA_NONE
Definition: BKE_tracking.h:42
#define TRACK_SELECTED(track)
Definition: BKE_tracking.h:823
eTrackClearAction
Definition: BKE_tracking.h:231
@ TRACK_CLEAR_ALL
Definition: BKE_tracking.h:237
@ TRACK_CLEAR_REMAINED
Definition: BKE_tracking.h:235
@ TRACK_CLEAR_UPTO
Definition: BKE_tracking.h:233
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, const int verts[][2], int verts_len, void(*callback)(int x, int x_end, int y, void *), void *user_data)
#define BLI_INLINE
void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:858
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:239
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
void void BLI_listbase_sort(struct ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE int min_ii(int a, int b)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
void perspective_m4(float mat[4][4], float left, float right, float bottom, float top, float nearClip, float farClip)
Definition: math_geom.c:4542
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void blend_m4_m4m4(float out[4][4], const float dst[4][4], const float src[4][4], float srcweight)
Definition: math_matrix.c:2409
void unit_m4(float m[4][4])
Definition: rct.c:1090
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1287
void scale_m4_fl(float R[4][4], float scale)
Definition: math_matrix.c:2297
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
MINLINE void mul_v2_fl(float r[2], float f)
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
Definition: math_vector.c:14
MINLINE void copy_v2_v2(float r[2], const float a[2])
void minmax_v2v2_v2(float min[2], float max[2], const float vec[2])
Definition: math_vector.c:890
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void negate_v2_v2(float r[2], const float a[2])
bool is_finite_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
Definition: math_vector.c:344
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void zero_v2(float r[2])
MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: string.c:623
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:250
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_len)
Definition: string_utils.c:309
#define INIT_MINMAX2(min, max)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
#define CTX_DATA_(context, msgid)
#define BLT_I18NCONTEXT_ID_MOVIECLIP
#define DATA_(msgid)
typedef double(DMatrix)[4][4]
@ CAMERA_SENSOR_FIT_AUTO
#define MAX_NAME
Definition: DNA_defs.h:48
@ GP_STROKE_2DSPACE
@ GP_LAYER_ACTIVE
Object is a sort of wrapper for general info.
@ TRACKING_OBJECT_CAMERA
@ TRACKING_SHOW_STAB_TRACKS
@ TRACKING_FILTER_BILINEAR
@ TRACK_ALGORITHM_FLAG_USE_BRUTE
@ REFINE_NO_INTRINSICS
@ TRACKING_RECONSTRUCTED
@ MARKER_TRACKED
@ MARKER_DISABLED
@ TRACK_DISABLE_BLUE
@ TRACK_HIDDEN
@ TRACK_PREVIEW_GRAYSCALE
@ TRACK_USE_2D_STAB
@ TRACK_HAS_BUNDLE
@ TRACK_USE_2D_STAB_ROT
@ TRACK_DISABLE_RED
@ TRACK_DISABLE_GREEN
@ TRACKING_COVERAGE_BAD
@ TRACKING_COVERAGE_OK
@ TRACKING_COVERAGE_ACCEPTABLE
@ CAMERA_UNITS_MM
@ TRACKING_DOPE_SELECTED_ONLY
@ TRACKING_DOPE_SORT_INVERSE
@ TRACKING_DOPE_SHOW_HIDDEN
@ TRACK_MOTION_MODEL_TRANSLATION
@ TRACKING_DOPE_SORT_START
@ TRACKING_DOPE_SORT_AVERAGE_ERROR
@ TRACKING_DOPE_SORT_LONGEST
@ TRACKING_DOPE_SORT_NAME
@ TRACKING_DOPE_SORT_END
@ TRACKING_DOPE_SORT_TOTAL
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:500
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void imb_freerectImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:97
void IMB_rectcpy(struct ImBuf *dbuf, const struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height)
Contains defines and structs used throughout the imbuf module.
@ IB_RECT_INVALID
@ IB_rectfloat
@ IB_rect
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
btMatrix3x3 inverse() const
Return the inverse of the matrix.
Definition: btTransform.h:182
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
#define SELECT
Scene scene
void * user_data
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
uint pos
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
const vector< Marker > & markers
int count
void libmv_cameraIntrinsicsUndistortFloat(const libmv_CameraIntrinsics *libmv_intrinsics, const float *source_image, int width, int height, float overscan, int channels, float *destination_image)
void libmv_cameraIntrinsicsDestroy(libmv_CameraIntrinsics *libmv_intrinsics)
void libmv_cameraIntrinsicsUndistortByte(const libmv_CameraIntrinsics *libmv_intrinsics, const unsigned char *source_image, int width, int height, float overscan, int channels, unsigned char *destination_image)
void libmv_cameraIntrinsicsDistortByte(const struct libmv_CameraIntrinsics *libmv_intrinsics, const unsigned char *source_image, int width, int height, float overscan, int channels, unsigned char *destination_image)
void libmv_cameraIntrinsicsApply(const struct libmv_CameraIntrinsics *libmv_intrinsics, double x, double y, double *x1, double *y1)
libmv_CameraIntrinsics * libmv_cameraIntrinsicsNew(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options)
void libmv_cameraIntrinsicsDistortFloat(const libmv_CameraIntrinsics *libmv_intrinsics, float *source_image, int width, int height, float overscan, int channels, float *destination_image)
void libmv_cameraIntrinsicsSetThreads(libmv_CameraIntrinsics *libmv_intrinsics, int threads)
void libmv_cameraIntrinsicsUpdate(const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options, libmv_CameraIntrinsics *libmv_intrinsics)
void libmv_cameraIntrinsicsInvert(const struct libmv_CameraIntrinsics *libmv_intrinsics, double x, double y, double *x1, double *y1)
libmv_CameraIntrinsics * libmv_cameraIntrinsicsCopy(const libmv_CameraIntrinsics *libmv_intrinsics)
struct libmv_CameraIntrinsics libmv_CameraIntrinsics
void libmv_samplePlanarPatchFloat(const float *image, int width, int height, int channels, const double *xs, const double *ys, int num_samples_x, int num_samples_y, const float *mask, float *patch, double *warped_position_x, double *warped_position_y)
void libmv_samplePlanarPatchByte(const unsigned char *image, int width, int height, int channels, const double *xs, const double *ys, int num_samples_x, int num_samples_y, const float *mask, unsigned char *patch, double *warped_position_x, double *warped_position_y)
const ProjectiveReconstruction & reconstruction
Definition: intersect.cc:198
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:34
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
Definition: mallocn.c:32
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int left
#define ceilf(x)
Definition: metal/compat.h:225
#define fabsf(x)
Definition: metal/compat.h:219
Segment< FEdge *, Vec3r > segment
static unsigned a[3]
Definition: RandGen.cpp:78
static void area(int d1, int d2, int e1, int e2, float weights[2])
ListBase threads
list of all thread for every CPUDevice in cpudevices a thread exists.
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
#define min(a, b)
Definition: sort.c:35
int channels
int userflags
struct ColorSpace * rect_colorspace
unsigned int * rect
float * rect_float
struct ColorSpace * float_colorspace
void * first
Definition: DNA_listBase.h:31
float pixel_aspect
Definition: tracking.c:55
struct libmv_CameraIntrinsics * intrinsics
Definition: tracking.c:52
float principal[2]
Definition: tracking.c:54
struct MovieTrackingDopesheetChannel * next
MovieTrackingReconstruction reconstruction
struct MovieTrackingObject * next
struct MovieTrackingPlaneTrack * next
MovieTrackingTrack ** point_tracks
MovieTrackingPlaneMarker * markers
struct MovieReconstructedCamera * cameras
struct bGPdata * gpd
MovieTrackingMarker * markers
struct MovieTrackingTrack * next
struct MovieTrackingTrack * prev
MovieTrackingReconstruction reconstruction
MovieTrackingPlaneTrack * act_plane_track
MovieTrackingDopesheet dopesheet
MovieTrackingStats * stats
MovieTrackingTrack * act_track
MovieTrackingStabilization stabilization
MovieTrackingCamera camera
MovieTrackingSettings settings
struct RenderData r
struct bGPDframe * next
ListBase strokes
struct bGPDlayer * next
ListBase frames
bGPDspoint * points
struct bGPDstroke * next
ListBase layers
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63
int BKE_tracking_count_selected_tracks_in_list(const ListBase *tracks_list)
Definition: tracking.c:639
static void tracking_dopesheet_calc_coverage(MovieTracking *tracking)
Definition: tracking.c:3332
static void tracking_tracks_free(ListBase *tracks)
Definition: tracking.c:68
void BKE_tracking_distortion_undistort_v2(MovieDistortion *distortion, const float co[2], float r_co[2])
Definition: tracking.c:2438
MovieTrackingReconstruction * BKE_tracking_get_active_reconstruction(MovieTracking *tracking)
Definition: tracking.c:368
MovieTrackingObject * BKE_tracking_object_get_named(MovieTracking *tracking, const char *name)
Definition: tracking.c:2077
float BKE_tracking_track_get_weight_for_marker(MovieClip *clip, MovieTrackingTrack *track, MovieTrackingMarker *marker)
Definition: tracking.c:1239
static void tracking_object_free(MovieTrackingObject *object)
Definition: tracking.c:104
ListBase * BKE_tracking_object_get_tracks(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:2112
void BKE_tracking_plane_marker_get_subframe_corners(MovieTrackingPlaneTrack *plane_track, float framenr, float corners[4][2])
Definition: tracking.c:1967
static const MovieTrackingMarker * get_usable_marker_for_interpolation(struct MovieTrackingTrack *track, const MovieTrackingMarker *anchor_marker, const int direction)
Definition: tracking.c:1485
void BKE_tracking_track_deselect(MovieTrackingTrack *track, int area)
Definition: tracking.c:1284
ImBuf * BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *tracking, ImBuf *ibuf, int calibration_width, int calibration_height, float overscan, bool undistort)
Definition: tracking.c:2358
static void tracking_plane_tracks_free(ListBase *plane_tracks)
Definition: tracking.c:78
void BKE_tracking_distortion_free(MovieDistortion *distortion)
Definition: tracking.c:2450
static void reconstructed_camera_scale_set(MovieTrackingObject *object, float mat[4][4])
Definition: tracking.c:2215
int BKE_tracking_count_selected_tracks_in_active_object(MovieTracking *tracking)
Definition: tracking.c:650
MovieTrackingTrack * BKE_tracking_track_get_indexed(MovieTracking *tracking, int tracknr, ListBase **r_tracksbase)
Definition: tracking.c:1056
void BKE_tracking_track_first_last_frame_get(const MovieTrackingTrack *track, int *r_first_frame, int *r_last_frame)
Definition: tracking.c:613
MovieTrackingTrack * BKE_tracking_track_get_active(MovieTracking *tracking)
Definition: tracking.c:1089
ImBuf * BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, bool anchored, bool disable_channels)
Definition: tracking.c:2722
void BKE_tracking_settings_init(MovieTracking *tracking)
Definition: tracking.c:305
void BKE_tracking_marker_pattern_minmax(const MovieTrackingMarker *marker, float min[2], float max[2])
Definition: tracking.c:1563
void BKE_tracking_marker_clamp_pattern_position(MovieTrackingMarker *marker)
Definition: tracking.c:1374
void BKE_tracking_track_select(ListBase *tracksbase, MovieTrackingTrack *track, int area, bool extend)
Definition: tracking.c:1257
void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height)
Definition: tracking.c:2234
void BKE_tracking_disable_channels(ImBuf *ibuf, bool disable_red, bool disable_green, bool disable_blue, bool grayscale)
Definition: tracking.c:2891
void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingObject *object, int framenr, int winx, int winy, float mat[4][4])
Definition: tracking.c:391
static void tracking_plane_tracks_copy(ListBase *plane_tracks_list_dst, const ListBase *plane_tracks_list_src, GHash *tracks_mapping, const int flag)
Definition: tracking.c:189
static int channels_alpha_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3063
ListBase * BKE_tracking_find_tracks_list_for_plane_track(MovieTracking *tracking, const MovieTrackingPlaneTrack *plane_track)
Definition: tracking.c:3485
static void tracking_objects_free(ListBase *objects)
Definition: tracking.c:112
static int channels_average_error_sort(const void *a, const void *b)
Definition: tracking.c:2992
MovieTrackingObject * BKE_tracking_object_get_active(MovieTracking *tracking)
Definition: tracking.c:2092
MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get_exact(MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1938
void BKE_tracking_track_flag_set(MovieTrackingTrack *track, int area, int flag)
Definition: tracking.c:688
static struct @103 tracking_clipboard
ListBase * BKE_tracking_find_tracks_list_for_track(MovieTracking *tracking, const MovieTrackingTrack *track)
Definition: tracking.c:3458
MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_active(struct MovieTracking *tracking)
Definition: tracking.c:1718
static void multiply_marker(MovieTrackingMarker *marker, const float multiplier)
Definition: tracking.c:945
void BKE_tracking_track_path_clear(MovieTrackingTrack *track, const int ref_frame, const eTrackClearAction action)
Definition: tracking.c:789
static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, bool grayscale)
Definition: tracking.c:2618
static void tracking_dopesheet_channels_sort(MovieTracking *tracking, int sort_method, bool inverse)
Definition: tracking.c:3268
MovieTrackingPlaneMarker * BKE_tracking_plane_marker_get(MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1890
static void path_clear_all(MovieTrackingTrack *track, const int ref_frame)
Definition: tracking.c:772
static int channels_end_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3114
static int channels_total_track_sort(const void *a, const void *b)
Definition: tracking.c:2968
void BKE_tracking_get_rna_path_for_track(const struct MovieTracking *tracking, const struct MovieTrackingTrack *track, char *rna_path, size_t rna_path_len)
Definition: tracking.c:3495
static void path_clear_remained(MovieTrackingTrack *track, const int ref_frame)
Definition: tracking.c:734
MovieTrackingPlaneMarker * BKE_tracking_plane_marker_ensure(MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1950
bool BKE_tracking_plane_track_has_point_track(MovieTrackingPlaneTrack *plane_track, MovieTrackingTrack *track)
Definition: tracking.c:1741
static void path_clear_up_to(MovieTrackingTrack *track, const int ref_frame)
Definition: tracking.c:751
static void tracking_average_markers(MovieTrackingTrack *dst_track, MovieTrackingTrack **src_tracks, const int num_src_tracks)
Definition: tracking.c:957
static void accumulate_marker(MovieTrackingMarker *dst_marker, const MovieTrackingMarker *src_marker)
Definition: tracking.c:920
void BKE_tracking_marker_get_subframe_position(MovieTrackingTrack *track, float framenr, float pos[2])
Definition: tracking.c:1575
static int channels_start_sort(const void *a, const void *b)
Definition: tracking.c:3039
void BKE_tracking_track_free(MovieTrackingTrack *track)
Definition: tracking.c:606
void BKE_tracking_get_rna_path_prefix_for_track(const struct MovieTracking *tracking, const struct MovieTrackingTrack *track, char *rna_path, size_t rna_path_len)
Definition: tracking.c:3517
static void tracking_tracks_copy(ListBase *tracks_dst, const ListBase *tracks_src, GHash *tracks_mapping, const int flag)
Definition: tracking.c:165
void BKE_tracking_free(MovieTracking *tracking)
Definition: tracking.c:150
void BKE_tracking_track_unique_name(ListBase *tracksbase, MovieTrackingTrack *track)
Definition: tracking.c:596
void BKE_tracking_clipboard_free(void)
Definition: tracking.c:448
void BKE_tracking_plane_track_unique_name(ListBase *plane_tracks_base, MovieTrackingPlaneTrack *plane_track)
Definition: tracking.c:1683
struct MovieDistortion MovieDistortion
float * BKE_tracking_track_get_mask(int frame_width, int frame_height, MovieTrackingTrack *track, MovieTrackingMarker *marker)
Definition: tracking.c:1221
bool BKE_tracking_track_has_enabled_marker_at_frame(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:727
void BKE_tracking_undistort_v2(MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2480
void BKE_tracking_plane_tracks_replace_point_track(MovieTracking *tracking, MovieTrackingTrack *old_track, MovieTrackingTrack *new_track)
Definition: tracking.c:1802
static void tracking_dopesheet_channels_calc(MovieTracking *tracking)
Definition: tracking.c:3227
ImBuf * BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, bool anchored, bool disable_channels)
Definition: tracking.c:2760
void BKE_tracking_tracks_average(MovieTrackingTrack *dst_track, MovieTrackingTrack **src_tracks, const int num_src_tracks)
Definition: tracking.c:1026
bool BKE_tracking_object_delete(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:2027
static bGPDlayer * track_mask_gpencil_layer_get(MovieTrackingTrack *track)
Definition: tracking.c:1107
static void track_mask_gpencil_layer_rasterize(int frame_width, int frame_height, const float region_min[2], bGPDlayer *layer, float *mask, int mask_width, int mask_height)
Definition: tracking.c:1158
MovieTrackingObject * BKE_tracking_object_get_camera(MovieTracking *tracking)
Definition: tracking.c:2097
ImBuf * BKE_tracking_undistort_frame(MovieTracking *tracking, ImBuf *ibuf, int calibration_width, int calibration_height, float overscan)
Definition: tracking.c:2499
bool BKE_tracking_marker_get_interpolated(struct MovieTrackingTrack *track, const int framenr, struct MovieTrackingMarker *r_marker)
Definition: tracking.c:1505
MovieTrackingPlaneTrack * BKE_tracking_plane_track_add(MovieTracking *tracking, ListBase *plane_tracks_base, ListBase *tracks, int framenr)
Definition: tracking.c:1611
MovieTrackingObject * BKE_tracking_object_add(MovieTracking *tracking, const char *name)
Definition: tracking.c:1998
void BKE_tracking_plane_track_replace_point_track(MovieTrackingPlaneTrack *plane_track, MovieTrackingTrack *old_track, MovieTrackingTrack *new_track)
Definition: tracking.c:1790
static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet)
Definition: tracking.c:126
void BKE_tracking_distort_v2(MovieTracking *tracking, int image_width, int image_height, const float co[2], float r_co[2])
Definition: tracking.c:2457
MovieTrackingPlaneTrack * BKE_tracking_plane_track_get_named(MovieTracking *tracking, MovieTrackingObject *object, const char *name)
Definition: tracking.c:1703
static int channels_end_sort(const void *a, const void *b)
Definition: tracking.c:3051
MovieTrackingTrack * BKE_tracking_track_get_named(MovieTracking *tracking, MovieTrackingObject *object, const char *name)
Definition: tracking.c:1038
MovieTrackingMarker * BKE_tracking_marker_get_exact(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1457
static void tracking_objects_copy(ListBase *objects_dst, const ListBase *objects_src, GHash *tracks_mapping, const int flag)
Definition: tracking.c:247
void BKE_tracking_marker_clamp_search_size(MovieTrackingMarker *marker)
Definition: tracking.c:1393
void BKE_tracking_tracks_join(MovieTracking *tracking, MovieTrackingTrack *dst_track, MovieTrackingTrack *src_track)
Definition: tracking.c:806
MovieTrackingTrack ** BKE_tracking_selected_tracks_in_active_object(MovieTracking *tracking, int *r_num_tracks)
Definition: tracking.c:656
static int channels_longest_segment_sort(const void *a, const void *b)
Definition: tracking.c:2980
struct TrackMaskSetPixelData TrackMaskSetPixelData
static void tracking_reconstruction_free(MovieTrackingReconstruction *reconstruction)
Definition: tracking.c:92
void BKE_tracking_get_camera_object_matrix(Object *camera_object, float mat[4][4])
Definition: tracking.c:375
static void tracking_dopesheet_channels_segments_calc(MovieTrackingDopesheetChannel *channel)
Definition: tracking.c:3127
MovieTrackingMarker * BKE_tracking_marker_ensure(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1468
static void tracking_reconstruction_copy(MovieTrackingReconstruction *reconstruction_dst, const MovieTrackingReconstruction *reconstruction_src, const int UNUSED(flag))
Definition: tracking.c:215
void BKE_tracking_camera_shift_get(MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty)
Definition: tracking.c:2225
static void tracking_average_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack **src_tracks, const int num_src_tracks)
Definition: tracking.c:1014
float * tracking_track_get_mask_for_region(int frame_width, int frame_height, const float region_min[2], const float region_max[2], MovieTrackingTrack *track)
Definition: tracking.c:1203
ListBase * BKE_tracking_get_active_tracks(MovieTracking *tracking)
Definition: tracking.c:346
bool BKE_tracking_plane_track_remove_point_track(MovieTrackingPlaneTrack *plane_track, MovieTrackingTrack *track)
Definition: tracking.c:1752
static int channels_alpha_sort(const void *a, const void *b)
Definition: tracking.c:2956
void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:2067
ImBuf * BKE_tracking_get_plane_imbuf(const ImBuf *frame_ibuf, const MovieTrackingPlaneMarker *plane_marker)
Definition: tracking.c:2812
ImBuf * BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int calibration_width, int calibration_height, float overscan)
Definition: tracking.c:2516
void BKE_tracking_distortion_distort_v2(MovieDistortion *distortion, const float co[2], float r_co[2])
Definition: tracking.c:2420
ListBase * BKE_tracking_object_get_plane_tracks(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:2121
static void track_mask_set_pixel_cb(int x, int x_end, int y, void *user_data)
Definition: tracking.c:1148
MovieTrackingTrack * BKE_tracking_track_duplicate(MovieTrackingTrack *track)
Definition: tracking.c:576
bool BKE_tracking_track_has_marker_at_frame(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:722
void BKE_tracking_get_rna_path_for_plane_track(const struct MovieTracking *tracking, const struct MovieTrackingPlaneTrack *plane_track, char *rna_path, size_t rna_path_len)
Definition: tracking.c:3533
void BKE_tracking_track_flag_clear(MovieTrackingTrack *track, int area, int flag)
Definition: tracking.c:705
void BKE_tracking_tracks_deselect_all(ListBase *tracksbase)
Definition: tracking.c:1289
static int compare_firstlast_putting_undefined_first(bool inverse, bool a_markerless, int a_value, bool b_markerless, int b_value)
Definition: tracking.c:3008
static void tracking_object_copy(MovieTrackingObject *object_dst, const MovieTrackingObject *object_src, GHash *tracks_mapping, const int flag)
Definition: tracking.c:234
MovieTrackingObject * BKE_tracking_find_object_for_plane_track(const MovieTracking *tracking, const MovieTrackingPlaneTrack *plane_track)
Definition: tracking.c:3468
void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *tracking, int calibration_width, int calibration_height)
Definition: tracking.c:2324
MovieTrackingReconstruction * BKE_tracking_object_get_reconstruction(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:2131
MovieReconstructedCamera * BKE_tracking_camera_get_reconstructed(MovieTracking *tracking, MovieTrackingObject *object, int framenr)
Definition: tracking.c:2252
MovieDistortion * BKE_tracking_distortion_new(MovieTracking *tracking, int calibration_width, int calibration_height)
Definition: tracking.c:2303
void BKE_tracking_get_rna_path_prefix_for_plane_track(const struct MovieTracking *tracking, const struct MovieTrackingPlaneTrack *plane_track, char *rna_path, size_t rna_path_len)
Definition: tracking.c:3555
bool BKE_tracking_clipboard_has_tracks(void)
Definition: tracking.c:484
MovieTrackingMarker * BKE_tracking_marker_insert(MovieTrackingTrack *track, MovieTrackingMarker *marker)
Definition: tracking.c:1302
static int reconstructed_camera_index_get(MovieTrackingReconstruction *reconstruction, int framenr, bool nearest)
Definition: tracking.c:2145
static int coverage_from_count(int count)
Definition: tracking.c:3316
void BKE_tracking_distortion_set_threads(MovieDistortion *distortion, int threads)
Definition: tracking.c:2342
void BKE_tracking_marker_delete(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1347
void BKE_tracking_marker_clamp_search_position(MovieTrackingMarker *marker)
Definition: tracking.c:1404
static int channels_start_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3102
void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *tracking, MovieTrackingObject *object, float framenr, float mat[4][4])
Definition: tracking.c:2269
MovieTrackingObject * BKE_tracking_find_object_for_track(const MovieTracking *tracking, const MovieTrackingTrack *track)
Definition: tracking.c:3441
static int channels_longest_segment_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3081
MovieDistortion * BKE_tracking_distortion_copy(MovieDistortion *distortion)
Definition: tracking.c:2347
MovieTrackingTrack * BKE_tracking_track_add_empty(MovieTracking *tracking, ListBase *tracks_list)
Definition: tracking.c:511
ListBase * BKE_tracking_get_active_plane_tracks(MovieTracking *tracking)
Definition: tracking.c:357
void BKE_tracking_max_distortion_delta_across_bound(MovieTracking *tracking, int image_width, int image_height, rcti *rect, bool undistort, float delta[2])
Definition: tracking.c:2533
void BKE_tracking_tracks_first_last_frame_minmax(MovieTrackingTrack **tracks, const int num_tracks, int *r_first_frame, int *r_last_frame)
Definition: tracking.c:623
MovieTrackingMarker * BKE_tracking_marker_get(MovieTrackingTrack *track, int framenr)
Definition: tracking.c:1424
static void tracking_stabilization_copy(MovieTrackingStabilization *stabilization_dst, const MovieTrackingStabilization *stabilization_src, const int UNUSED(flag))
Definition: tracking.c:226
void BKE_tracking_plane_marker_delete(MovieTrackingPlaneTrack *plane_track, int framenr)
Definition: tracking.c:1859
void BKE_tracking_copy(MovieTracking *tracking_dst, const MovieTracking *tracking_src, const int flag)
Definition: tracking.c:261
void BKE_tracking_dopesheet_update(MovieTracking *tracking)
Definition: tracking.c:3418
void BKE_tracking_clipboard_paste_tracks(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:489
void BKE_tracking_plane_tracks_remove_point_track(MovieTracking *tracking, MovieTrackingTrack *track)
Definition: tracking.c:1775
void BKE_tracking_plane_tracks_deselect_all(ListBase *plane_tracks_base)
Definition: tracking.c:1734
ImBuf * BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *search_ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, bool from_anchor, bool use_mask, int num_samples_x, int num_samples_y, float pos[2])
Definition: tracking.c:2627
void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingObject *object)
Definition: tracking.c:464
void BKE_tracking_plane_track_free(MovieTrackingPlaneTrack *plane_track)
Definition: tracking.c:1694
static int channels_average_error_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3090
MovieTrackingTrack * BKE_tracking_track_add(MovieTracking *tracking, ListBase *tracksbase, float x, float y, int framenr, int width, int height)
Definition: tracking.c:535
MovieTrackingPlaneMarker * BKE_tracking_plane_marker_insert(MovieTrackingPlaneTrack *plane_track, MovieTrackingPlaneMarker *plane_marker)
Definition: tracking.c:1818
void BKE_tracking_dopesheet_tag_update(MovieTracking *tracking)
Definition: tracking.c:3411
BLI_INLINE int plane_marker_size_len_in_pixels(const float a[2], const float b[2], const int frame_width, const int frame_height)
Definition: tracking.c:2801
ListBase tracks
Definition: tracking.c:60
static int channels_total_track_inverse_sort(const void *a, const void *b)
Definition: tracking.c:3072
void tracking_marker_insert_disabled(MovieTrackingTrack *track, const MovieTrackingMarker *ref_marker, bool before, bool overwrite)
void tracking_cameraIntrinscisOptionsFromTracking(MovieTracking *tracking, int calibration_width, int calibration_height, libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
void tracking_get_marker_coords_for_tracking(int frame_width, int frame_height, const MovieTrackingMarker *marker, double search_pixel_x[5], double search_pixel_y[5])
void tracking_get_search_origin_frame_pixel(int frame_width, int frame_height, const MovieTrackingMarker *marker, float frame_pixel[2])
float max