Blender
V5.0
intern
libmv
libmv
autotrack
marker.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_MARKER_H_
24
#define LIBMV_AUTOTRACK_MARKER_H_
25
26
#include <ostream>
27
28
#include "
libmv/autotrack/quad.h
"
29
#include "
libmv/autotrack/region.h
"
30
#include "
libmv/numeric/numeric.h
"
31
32
namespace
mv
{
33
34
using
libmv::Vec2f
;
35
36
// A marker is the 2D location of a tracked region (quad) in an image.
37
// Note that some of this information could be normalized by having a
38
// collection of inter-connected structs. Instead the "fat Marker" design below
39
// trades memory for data structure simplicity.
40
struct
Marker
{
41
int
clip
;
// The clip this marker is from.
42
int
frame
;
// The frame within the clip this marker is from.
43
int
track
;
// The track this marker is from.
44
45
// The center of the marker in frame coordinates. This is typically, but not
46
// always, the same as the center of the patch.
47
Vec2f
center
;
48
49
// A frame-realtive quad defining the part of the image the marker covers.
50
// For reference markers, the pixels in the patch are the tracking pattern.
51
Quad2Df
patch
;
52
53
// Some markers are less certain than others; the weight determines the
54
// amount this marker contributes to the error. 1.0 indicates normal
55
// contribution; 0.0 indicates a zero-weight track (and will be omitted from
56
// bundle adjustment).
57
float
weight
;
58
59
enum
Source
{
60
MANUAL
,
// The user placed this marker manually.
61
DETECTED
,
// A keypoint detector found this point.
62
TRACKED
,
// The tracking algorithm placed this marker.
63
MATCHED
,
// A matching algorithm (e.g. SIFT or SURF or ORB) found this.
64
PREDICTED
,
// A motion model predicted this marker. This is needed for
65
// handling occlusions in some cases where an imaginary marker
66
// is placed to keep camera motion smooth.
67
};
68
Source
source
;
69
70
// Markers may be inliers or outliers if the tracking fails; this allows
71
// visualizing the markers in the image.
72
enum
Status
{
UNKNOWN
,
INLIER
,
OUTLIER
};
73
Status
status
;
74
75
// When doing correlation tracking, where to search in the current frame for
76
// the pattern from the reference frame, in absolute frame coordinates.
77
Region
search_region
;
78
79
// For tracked and matched markers, indicates what the reference was.
80
int
reference_clip
;
81
int
reference_frame
;
82
83
// Model related information for non-point tracks.
84
//
85
// Some tracks are on a larger object, such as a plane or a line or perhaps
86
// another primitive (a rectangular prisim). This captures the information
87
// needed to say that for example a collection of markers belongs to model #2
88
// (and model #2 is a plane).
89
enum
ModelType
{
POINT
,
PLANE
,
LINE
,
CUBE
};
90
ModelType
model_type
;
91
92
// The model ID this track (e.g. the second model, which is a plane).
93
int
model_id
;
94
95
// TODO(keir): Add a "int model_argument" to capture that e.g. a marker is on
96
// the 3rd face of a cube.
97
98
enum
Channel
{
99
CHANNEL_R
= (1 << 0),
100
CHANNEL_G
= (1 << 1),
101
CHANNEL_B
= (1 << 2),
102
};
103
104
// Channels from the original frame which this marker is unable to see.
105
int
disabled_channels
;
106
107
// Offset everything (center, patch, search) by the given delta.
108
template
<
typename
T>
109
void
Offset
(
const
T
& offset) {
110
center
+= offset.template
cast<float>
();
111
patch
.coordinates.rowwise() += offset.template
cast<int>
();
112
search_region
.Offset(offset);
113
}
114
115
// Shift the center to the given new position (and patch, search).
116
template
<
typename
T>
117
void
SetPosition
(
const
T
& new_center) {
118
Offset
(new_center -
center
);
119
}
120
};
121
122
inline
std::ostream&
operator<<
(std::ostream&
out
,
const
Marker
& marker) {
123
out
<<
"{"
<< marker.
clip
<<
", "
<< marker.
frame
<<
", "
<< marker.
track
124
<<
", ("
<< marker.
center
.x() <<
", "
<< marker.
center
.y() <<
")"
125
<<
"}"
;
126
return
out
;
127
}
128
129
}
// namespace mv
130
131
#endif
// LIBMV_AUTOTRACK_MARKER_H_
cast
#define cast
Definition
gpu_shader_compat_cxx.hh:181
out
#define out
Definition
gpu_shader_compat_cxx.hh:48
region.h
T
#define T
Definition
mball_tessellate.cc:274
libmv::Vec2f
Eigen::Vector2f Vec2f
Definition
numeric.h:128
mv
Definition
libmv/autotrack/autotrack.cc:31
mv::Quad2Df
Quad< float, 2 > Quad2Df
Definition
quad.h:53
mv::operator<<
std::ostream & operator<<(std::ostream &out, const Marker &marker)
Definition
marker.h:122
numeric.h
quad.h
mv::Marker
Definition
marker.h:40
mv::Marker::search_region
Region search_region
Definition
marker.h:77
mv::Marker::SetPosition
void SetPosition(const T &new_center)
Definition
marker.h:117
mv::Marker::disabled_channels
int disabled_channels
Definition
marker.h:105
mv::Marker::frame
int frame
Definition
marker.h:42
mv::Marker::clip
int clip
Definition
marker.h:41
mv::Marker::Offset
void Offset(const T &offset)
Definition
marker.h:109
mv::Marker::weight
float weight
Definition
marker.h:57
mv::Marker::center
Vec2f center
Definition
marker.h:47
mv::Marker::Source
Source
Definition
marker.h:59
mv::Marker::DETECTED
@ DETECTED
Definition
marker.h:61
mv::Marker::PREDICTED
@ PREDICTED
Definition
marker.h:64
mv::Marker::TRACKED
@ TRACKED
Definition
marker.h:62
mv::Marker::MATCHED
@ MATCHED
Definition
marker.h:63
mv::Marker::MANUAL
@ MANUAL
Definition
marker.h:60
mv::Marker::patch
Quad2Df patch
Definition
marker.h:51
mv::Marker::model_type
ModelType model_type
Definition
marker.h:90
mv::Marker::ModelType
ModelType
Definition
marker.h:89
mv::Marker::PLANE
@ PLANE
Definition
marker.h:89
mv::Marker::POINT
@ POINT
Definition
marker.h:89
mv::Marker::LINE
@ LINE
Definition
marker.h:89
mv::Marker::CUBE
@ CUBE
Definition
marker.h:89
mv::Marker::Status
Status
Definition
marker.h:72
mv::Marker::UNKNOWN
@ UNKNOWN
Definition
marker.h:72
mv::Marker::INLIER
@ INLIER
Definition
marker.h:72
mv::Marker::OUTLIER
@ OUTLIER
Definition
marker.h:72
mv::Marker::reference_frame
int reference_frame
Definition
marker.h:81
mv::Marker::source
Source source
Definition
marker.h:68
mv::Marker::status
Status status
Definition
marker.h:73
mv::Marker::model_id
int model_id
Definition
marker.h:93
mv::Marker::Channel
Channel
Definition
marker.h:98
mv::Marker::CHANNEL_B
@ CHANNEL_B
Definition
marker.h:101
mv::Marker::CHANNEL_G
@ CHANNEL_G
Definition
marker.h:100
mv::Marker::CHANNEL_R
@ CHANNEL_R
Definition
marker.h:99
mv::Marker::track
int track
Definition
marker.h:43
mv::Marker::reference_clip
int reference_clip
Definition
marker.h:80
mv::Region
Definition
libmv/autotrack/region.h:45
Generated on
for Blender by
doxygen
1.16.1