Blender  V2.93
intern/autotrack.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2014 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #include "intern/autotrack.h"
21 #include "intern/tracksN.h"
22 #include "intern/utildefines.h"
24 
27 using mv::AutoTrack;
28 using mv::FrameAccessor;
29 using mv::Marker;
30 
33  (FrameAccessor*)frame_accessor);
34 }
35 
36 void libmv_autoTrackDestroy(libmv_AutoTrack* libmv_autotrack) {
37  LIBMV_OBJECT_DELETE(libmv_autotrack, AutoTrack);
38 }
39 
42  AutoTrack* autotrack = ((AutoTrack*)libmv_autotrack);
44  &autotrack->options.track_region);
45 
46  autotrack->options.search_region.min(0) = options->search_region.min[0];
47  autotrack->options.search_region.min(1) = options->search_region.min[1];
48  autotrack->options.search_region.max(0) = options->search_region.max[0];
49  autotrack->options.search_region.max(1) = options->search_region.max[1];
50 }
51 
53  const libmv_TrackRegionOptions* libmv_options,
54  libmv_Marker* libmv_tracked_marker,
55  libmv_TrackRegionResult* libmv_result) {
56  Marker tracked_marker;
59  libmv_apiMarkerToMarker(*libmv_tracked_marker, &tracked_marker);
61  bool ok = (((AutoTrack*)libmv_autotrack)
62  ->TrackMarker(&tracked_marker, &result, &options));
63  libmv_markerToApiMarker(tracked_marker, libmv_tracked_marker);
64  libmv_regionTrackergetResult(result, libmv_result);
65  return ok && result.is_usable();
66 }
67 
69  const libmv_Marker* libmv_marker) {
70  Marker marker;
71  libmv_apiMarkerToMarker(*libmv_marker, &marker);
72  ((AutoTrack*)libmv_autotrack)->AddMarker(marker);
73 }
74 
76  const libmv_Marker* libmv_marker,
77  size_t num_markers) {
78  if (num_markers == 0) {
79  // Early output.
80  return;
81  }
83  markers.resize(num_markers);
84  for (size_t i = 0; i < num_markers; ++i) {
85  libmv_apiMarkerToMarker(libmv_marker[i], &markers[i]);
86  }
87  ((AutoTrack*)libmv_autotrack)->SetMarkers(&markers);
88 }
89 
91  int clip,
92  int frame,
93  int track,
94  libmv_Marker* libmv_marker) {
95  Marker marker;
96  int ok =
97  ((AutoTrack*)libmv_autotrack)->GetMarker(clip, frame, track, &marker);
98  if (ok) {
99  libmv_markerToApiMarker(marker, libmv_marker);
100  }
101  return ok;
102 }
CCL_NAMESPACE_BEGIN struct Options options
const vector< Marker > & markers
void libmv_autoTrackSetMarkers(libmv_AutoTrack *libmv_autotrack, const libmv_Marker *libmv_marker, size_t num_markers)
libmv_AutoTrack * libmv_autoTrackNew(libmv_FrameAccessor *frame_accessor)
int libmv_autoTrackMarker(libmv_AutoTrack *libmv_autotrack, const libmv_TrackRegionOptions *libmv_options, libmv_Marker *libmv_tracked_marker, libmv_TrackRegionResult *libmv_result)
void libmv_autoTrackSetOptions(libmv_AutoTrack *libmv_autotrack, const libmv_AutoTrackOptions *options)
void libmv_autoTrackDestroy(libmv_AutoTrack *libmv_autotrack)
int libmv_autoTrackGetMarker(libmv_AutoTrack *libmv_autotrack, int clip, int frame, int track, libmv_Marker *libmv_marker)
void libmv_autoTrackAddMarker(libmv_AutoTrack *libmv_autotrack, const libmv_Marker *libmv_marker)
struct libmv_AutoTrack libmv_AutoTrack
struct libmv_FrameAccessor libmv_FrameAccessor
void libmv_configureTrackRegionOptions(const libmv_TrackRegionOptions &options, TrackRegionOptions *track_region_options)
void libmv_regionTrackergetResult(const TrackRegionResult &track_region_result, libmv_TrackRegionResult *result)
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
Definition: vector.h:39
void libmv_apiMarkerToMarker(const libmv_Marker &libmv_marker, Marker *marker)
Definition: tracksN.cc:28
void libmv_markerToApiMarker(const Marker &marker, libmv_Marker *libmv_marker)
Definition: tracksN.cc:52
#define LIBMV_OBJECT_NEW(type,...)
Definition: utildefines.h:42
#define LIBMV_OBJECT_DELETE(what, type)
Definition: utildefines.h:45