Blender  V3.3
libmv/autotrack/tracks.h
Go to the documentation of this file.
1 // Copyright (c) 2014 libmv authors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 //
21 // Author: mierle@gmail.com (Keir Mierle)
22 
23 #ifndef LIBMV_AUTOTRACK_TRACKS_H_
24 #define LIBMV_AUTOTRACK_TRACKS_H_
25 
26 #include "libmv/autotrack/marker.h"
27 #include "libmv/base/vector.h"
28 
29 namespace mv {
30 
31 using libmv::vector;
32 
33 // The Tracks container stores correspondences between frames.
34 class Tracks {
35  public:
36  Tracks() {}
37  Tracks(const Tracks& other);
38 
39  // Create a tracks object with markers already initialized. Copies markers.
40  explicit Tracks(const vector<Marker>& markers);
41 
42  // All getters append to the output argument vector.
43  bool GetMarker(int clip, int frame, int track, Marker* marker) const;
44  void GetMarkersForTrack(int track, vector<Marker>* markers) const;
45  void GetMarkersForTrackInClip(int clip,
46  int track,
47  vector<Marker>* markers) const;
48  void GetMarkersInFrame(int clip, int frame, vector<Marker>* markers) const;
49 
50  // Get the markers in frame1 and frame2 which have a common track.
51  //
52  // This is not the same as the union of the markers in frame1 and
53  // frame2; each marker is for a track that appears in both images.
54  void GetMarkersForTracksInBothImages(int clip1,
55  int frame1,
56  int clip2,
57  int frame2,
58  vector<Marker>* markers) const;
59 
60  void AddMarker(const Marker& marker);
61 
62  // Moves the contents of *markers over top of the existing markers. This
63  // destroys *markers in the process (but avoids copies).
64  void SetMarkers(vector<Marker>* markers);
65  bool RemoveMarker(int clip, int frame, int track);
66  void RemoveMarkersForTrack(int track);
67 
68  int MaxClip() const;
69  int MaxFrame(int clip) const;
70  int MaxTrack() const;
71  int NumMarkers() const;
72 
73  const vector<Marker>& markers() const { return markers_; }
74 
75  private:
76  vector<Marker> markers_;
77 
78  // TODO(keir): Consider adding access-map data structures to avoid all the
79  // linear lookup penalties for the accessors.
80 };
81 
82 } // namespace mv
83 
84 #endif // LIBMV_AUTOTRACK_TRACKS_H_
void AddMarker(const Marker &marker)
bool RemoveMarker(int clip, int frame, int track)
void RemoveMarkersForTrack(int track)
void GetMarkersInFrame(int clip, int frame, vector< Marker > *markers) const
void SetMarkers(vector< Marker > *markers)
int MaxFrame(int clip) const
void GetMarkersForTracksInBothImages(int clip1, int frame1, int clip2, int frame2, vector< Marker > *markers) const
void GetMarkersForTrackInClip(int clip, int track, vector< Marker > *markers) const
void GetMarkersForTrack(int track, vector< Marker > *markers) const
const vector< Marker > & markers() const
int NumMarkers() const
bool GetMarker(int clip, int frame, int track, Marker *marker) const
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector