posetracker.h
Go to the documentation of this file.
1 
17 #ifndef ARUCO_POSETRACKER
18 #define ARUCO_POSETRACKER
19 
20 #include "aruco_export.h"
21 #include "cameraparameters.h"
22 #include "marker.h"
23 #include "markermap.h"
24 
25 #include <map>
26 #include <opencv2/core/core.hpp>
27 
28 namespace aruco
29 {
68 {
69 public:
81  bool estimatePose(Marker& m, const CameraParameters& cam_params, float markerSize,
82  float minErrorRatio = 10 /*tau_e in paper*/);
83 
84  // returns the 4x4 transform matrix. Returns an empty matrix if last call to
85  // estimatePose returned false
86  cv::Mat getRTMatrix() const;
87  // return the rotation vector. Returns an empty matrix if last call to estimatePose
88  // returned false
89  const cv::Mat getRvec() const
90  {
91  return _rvec;
92  }
93  // return the translation vector. Returns an empty matrix if last call to estimatePose
94  // returned false
95  const cv::Mat getTvec() const
96  {
97  return _tvec;
98  }
99 
100 private:
101  cv::Mat _rvec, _tvec; // current poses
102  double solve_pnp(const std::vector<cv::Point3f>& p3d,
103  const std::vector<cv::Point2f>& p2d, const cv::Mat& cam_matrix,
104  const cv::Mat& dist, cv::Mat& r_io, cv::Mat& t_io);
105 };
110 {
111 public:
113  // Sets the parameters required for operation
114  // If the msconf has data expressed in meters, then the markerSize parameter is not
115  // required. If it is in
116  // pixels, the markersize will be used to
117  // transform to meters
118  // Throws exception if wrong configuraiton
119  void setParams(const CameraParameters& cam_params, const MarkerMap& msconf,
120  float markerSize = -1);
121  // indicates if the call to setParams has been successfull and this object is ready to
122  // call estimatePose
123  bool isValid() const
124  {
125  return _isValid;
126  }
127 
128  // resets current state
129  void reset()
130  {
131  _isValid = false;
132  _rvec = cv::Mat();
133  _tvec = cv::Mat();
134  }
135 
136  // estimates camera pose wrt the markermap
137  // returns true if pose has been obtained and false otherwise
138  bool estimatePose(const std::vector<Marker>& v_m);
139 
140  // returns the 4x4 transform matrix. Returns an empty matrix if last call to
141  // estimatePose returned false
142  cv::Mat getRTMatrix() const;
143  // return the rotation vector. Returns an empty matrix if last call to estimatePose
144  // returned false
145  const cv::Mat getRvec() const
146  {
147  return _rvec;
148  }
149  // return the translation vector. Returns an empty matrix if last call to estimatePose
150  // returned false
151  const cv::Mat getTvec() const
152  {
153  return _tvec;
154  }
155  // prevents from big jumps. If the difference between current and previous positions are
156  // greater than the value indicated
157  // assumes no good tracking and the pose will be set as null
158  void setMaxTrackingDifference(float maxTranslation, float maxAngle)
159  {
160  _maxTranslation = maxTranslation;
161  _maxAngle = maxAngle;
162  }
163 
164  void setMinErrorRatio(float minErrorRatio)
165  {
166  aruco_minerrratio_valid = minErrorRatio;
167  }
168 
169  double getInitialErr()
170  {
171  return _initial_err;
172  }
173 
174 protected:
175  cv::Mat _rvec, _tvec; // current poses
178  std::map<int, Marker3DInfo> _map_mm;
179  bool _isValid;
180  cv::Mat relocalization(const std::vector<Marker>& v_m);
181  float aruco_minerrratio_valid; /*tau_e in paper*/
182  std::map<uint32_t, cv::Mat> marker_m2g; // for each marker, the transform from the
183  // global ref system to the marker ref system
184  float _maxTranslation = -1, _maxAngle = -1;
185  double _initial_err;
186 };
187 }; // namespace aruco
188 
189 #endif
aruco::MarkerMap
This class defines a set of markers whose locations are attached to a common reference system,...
Definition: markermap.h:111
aruco::MarkerMapPoseTracker::isValid
bool isValid() const
Definition: posetracker.h:123
aruco::CameraParameters
Parameters of the camera.
Definition: cameraparameters.h:29
aruco::MarkerMapPoseTracker::reset
void reset()
Definition: posetracker.h:129
aruco::getRTMatrix
cv::Mat getRTMatrix(const cv::Mat &R_, const cv::Mat &T_, int forceType)
Definition: ippe.cpp:33
marker.h
aruco::MarkerMapPoseTracker::_msconf
MarkerMap _msconf
Definition: posetracker.h:177
aruco::MarkerPoseTracker::getRvec
const cv::Mat getRvec() const
Definition: posetracker.h:89
markermap.h
aruco::MarkerMapPoseTracker::aruco_minerrratio_valid
float aruco_minerrratio_valid
Definition: posetracker.h:181
aruco::MarkerMapPoseTracker::_isValid
bool _isValid
Definition: posetracker.h:179
aruco_export.h
aruco::MarkerMapPoseTracker::_initial_err
double _initial_err
Definition: posetracker.h:185
aruco::MarkerMapPoseTracker::getRvec
const cv::Mat getRvec() const
Definition: posetracker.h:145
aruco::MarkerMapPoseTracker::setMaxTrackingDifference
void setMaxTrackingDifference(float maxTranslation, float maxAngle)
Definition: posetracker.h:158
aruco::MarkerMapPoseTracker::marker_m2g
std::map< uint32_t, cv::Mat > marker_m2g
Definition: posetracker.h:182
aruco::Marker
Definition: marker.h:35
aruco::MarkerPoseTracker
Definition: posetracker.h:67
aruco::MarkerPoseTracker::_tvec
cv::Mat _tvec
Definition: posetracker.h:101
aruco::MarkerMapPoseTracker::setMinErrorRatio
void setMinErrorRatio(float minErrorRatio)
Definition: posetracker.h:164
aruco::MarkerMapPoseTracker
Definition: posetracker.h:109
ARUCO_EXPORT
#define ARUCO_EXPORT
Definition: aruco_export.h:30
aruco::MarkerMapPoseTracker::getTvec
const cv::Mat getTvec() const
Definition: posetracker.h:151
aruco::MarkerMapPoseTracker::getInitialErr
double getInitialErr()
Definition: posetracker.h:169
aruco
Definition: cameraparameters.h:24
aruco::MarkerMapPoseTracker::_map_mm
std::map< int, Marker3DInfo > _map_mm
Definition: posetracker.h:178
aruco::MarkerPoseTracker::getTvec
const cv::Mat getTvec() const
Definition: posetracker.h:95
cameraparameters.h
aruco::MarkerMapPoseTracker::_cam_params
aruco::CameraParameters _cam_params
Definition: posetracker.h:176
aruco::MarkerMapPoseTracker::_tvec
cv::Mat _tvec
Definition: posetracker.h:175


aruco
Author(s): Rafael Muñoz Salinas , Bence Magyar
autogenerated on Sat Sep 23 2023 02:26:45