gtsam
Loading...
Searching...
No Matches
StereoPoint2.h
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
18
19#pragma once
20
22#include <gtsam/base/VectorSpace.h>
23#if GTSAM_ENABLE_BOOST_SERIALIZATION
24#include <boost/serialization/nvp.hpp>
25#endif
26
27namespace gtsam {
28
34class GTSAM_EXPORT StereoPoint2 {
35private:
36
37 double uL_, uR_, v_;
38
39public:
40 inline constexpr static auto dimension = 3;
43
46 uL_(0), uR_(0), v_(0) {
47 }
48
52 StereoPoint2(double uL, double uR, double v) :
53 uL_(uL), uR_(uR), v_(v) {
54 }
55
57 explicit StereoPoint2(const Vector3& v) :
58 uL_(v(0)), uR_(v(1)), v_(v(2)) {}
59
63
65 void print(const std::string& s = "") const;
66
68 bool equals(const StereoPoint2& q, double tol = 1e-9) const {
69 return (std::abs(uL_ - q.uL_) < tol && std::abs(uR_ - q.uR_) < tol
70 && std::abs(v_ - q.v_) < tol);
71 }
72
76
78 inline static StereoPoint2 Identity() {
79 return StereoPoint2();
80 }
81
84 return StereoPoint2(-uL_, -uR_, -v_);
85 }
86
88 inline StereoPoint2 operator +(const Vector3& v) const {
89 return StereoPoint2(uL_ + v[0], uR_ + v[1], v_ + v[2]);
90 }
91
93 inline StereoPoint2 operator +(const StereoPoint2& b) const {
94 return StereoPoint2(uL_ + b.uL_, uR_ + b.uR_, v_ + b.v_);
95 }
96
98 inline StereoPoint2 operator -(const StereoPoint2& b) const {
99 return StereoPoint2(uL_ - b.uL_, uR_ - b.uR_, v_ - b.v_);
100 }
101
105
107 inline bool operator ==(const StereoPoint2& q) const {return uL_== q.uL_ && uR_==q.uR_ && v_ == q.v_;}
108
110 inline double uL() const {return uL_;}
111
113 inline double uR() const {return uR_;}
114
116 inline double v() const {return v_;}
117
119 Vector3 vector() const {
120 return Vector3(uL_, uR_, v_);
121 }
122
124 Point2 point2() const {
125 return Point2(uL_, v_);
126 }
127
129 Point2 right() const {
130 return Point2(uR_, v_);
131 }
132
134 GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &os, const StereoPoint2& p);
135
136private:
137
141
142#if GTSAM_ENABLE_BOOST_SERIALIZATION
144 friend class boost::serialization::access;
145 template<class ARCHIVE>
146 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
147 ar & BOOST_SERIALIZATION_NVP(uL_);
148 ar & BOOST_SERIALIZATION_NVP(uR_);
149 ar & BOOST_SERIALIZATION_NVP(v_);
150 }
151#endif
152
154
155};
156
157typedef std::vector<StereoPoint2> StereoPoint2Vector;
158
159template<>
160struct traits<StereoPoint2> : public internal::VectorSpace<StereoPoint2> {};
161
162template<>
163struct traits<const StereoPoint2> : public internal::VectorSpace<StereoPoint2> {};
164}
2D Point
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
Vector2 Point2
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point2 to Vector2...
Definition Point2.h:32
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
VectorSpace provides both Testable and VectorSpaceTraits.
Definition VectorSpace.h:221
A 2D stereo point, v will be same for rectified images.
Definition StereoPoint2.h:34
double uR() const
get uR
Definition StereoPoint2.h:113
StereoPoint2(const Vector3 &v)
construct from 3D vector
Definition StereoPoint2.h:57
Point2 right() const
convenient function to get a Point2 from the right image
Definition StereoPoint2.h:129
Vector3 vector() const
convert to vector
Definition StereoPoint2.h:119
double uL() const
get uL
Definition StereoPoint2.h:110
StereoPoint2(double uL, double uR, double v)
uL and uR represent the x-axis value of left and right frame coordinates respectively.
Definition StereoPoint2.h:52
bool equals(const StereoPoint2 &q, double tol=1e-9) const
equals
Definition StereoPoint2.h:68
StereoPoint2 operator-() const
inverse
Definition StereoPoint2.h:83
double v() const
get v
Definition StereoPoint2.h:116
Point2 point2() const
convenient function to get a Point2 from the left image
Definition StereoPoint2.h:124
static StereoPoint2 Identity()
identity
Definition StereoPoint2.h:78
StereoPoint2()
default constructor
Definition StereoPoint2.h:45