SfmTrack.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include <gtsam/sfm/SfmTrack.h>
20 
21 #include <iostream>
22 
23 namespace gtsam {
24 
25 void SfmTrack::print(const std::string& s) const {
26  std::cout << "Track with " << measurements.size();
27  std::cout << " measurements of point " << p << std::endl;
28 }
29 
30 bool SfmTrack::equals(const SfmTrack& sfmTrack, double tol) const {
31  // check the 3D point
32  if (!p.isApprox(sfmTrack.p)) {
33  return false;
34  }
35 
36  // check the RGB values
37  if (r != sfmTrack.r || g != sfmTrack.g || b != sfmTrack.b) {
38  return false;
39  }
40 
41  // compare size of vectors for measurements and siftIndices
42  if (numberMeasurements() != sfmTrack.numberMeasurements() ||
43  siftIndices.size() != sfmTrack.siftIndices.size()) {
44  return false;
45  }
46 
47  // compare measurements (order sensitive)
48  for (size_t idx = 0; idx < numberMeasurements(); ++idx) {
50  SfmMeasurement otherMeasurement = sfmTrack.measurements[idx];
51 
52  if (measurement.first != otherMeasurement.first ||
53  !measurement.second.isApprox(otherMeasurement.second)) {
54  return false;
55  }
56  }
57 
58  // compare sift indices (order sensitive)
59  for (size_t idx = 0; idx < siftIndices.size(); ++idx) {
60  SiftIndex index = siftIndices[idx];
61  SiftIndex otherIndex = sfmTrack.siftIndices[idx];
62 
63  if (index.first != otherIndex.first || index.second != otherIndex.second) {
64  return false;
65  }
66  }
67 
68  return true;
69 }
70 
71 } // namespace gtsam
gtsam::SfmTrack2d::measurement
const SfmMeasurement & measurement(size_t idx) const
Get the measurement (camera index, Point2) at pose index idx
Definition: SfmTrack.h:72
gtsam::SfmTrack::print
void print(const std::string &s="") const
print
Definition: SfmTrack.cpp:25
s
RealScalar s
Definition: level1_cplx_impl.h:126
gtsam::SfmTrack2d::measurements
std::vector< SfmMeasurement > measurements
The 2D image projections (id,(u,v))
Definition: SfmTrack.h:44
gtsam::SfmTrack::b
float b
RGB color of the 3D point.
Definition: SfmTrack.h:127
gtsam::SfmTrack
Definition: SfmTrack.h:125
gtsam::SfmTrack::equals
bool equals(const SfmTrack &sfmTrack, double tol=1e-9) const
assert equality up to a tolerance
Definition: SfmTrack.cpp:30
gtsam::SiftIndex
std::pair< size_t, size_t > SiftIndex
Sift index for SfmTrack.
Definition: SfmTrack.h:35
gtsam::SfmTrack::r
float r
Definition: SfmTrack.h:127
gtsam::SfmTrack::g
float g
Definition: SfmTrack.h:127
gtsam::SfmTrack2d::siftIndices
std::vector< SiftIndex > siftIndices
The feature descriptors (optional)
Definition: SfmTrack.h:47
gtsam
traits
Definition: SFMdata.h:40
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::SfmTrack::p
Point3 p
3D position of the point
Definition: SfmTrack.h:126
gtsam::SfmTrack2d::numberMeasurements
size_t numberMeasurements() const
Total number of measurements in this track.
Definition: SfmTrack.h:69
SfmTrack.h
A simple data structure for a track in Structure from Motion.
gtsam::SfmMeasurement
std::pair< size_t, Point2 > SfmMeasurement
A measurement with its camera index.
Definition: SfmTrack.h:32


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:18