posetracker.cpp
Go to the documentation of this file.
1 
30 #include "posetracker.h"
31 #include "ippe.h"
32 #include <set>
33 #include "levmarq.h"
34 #include <opencv2/calib3d.hpp>
35 
36 namespace aruco
37 {
38 namespace aruco_private
39 {
40 cv::Mat impl__aruco_getRTMatrix(const cv::Mat& _rvec, const cv::Mat& _tvec)
41 {
42  assert(_rvec.type() == CV_32F && _rvec.total() == 3);
43  assert(_tvec.type() == CV_32F && _tvec.total() == 3);
44 
45  cv::Mat Matrix(4, 4, CV_32F);
46  float* rt_44 = Matrix.ptr<float>(0);
47 
48  // makes a fast conversion to the 4x4 array passed
49  float rx = _rvec.ptr<float>(0)[0];
50  float ry = _rvec.ptr<float>(0)[1];
51  float rz = _rvec.ptr<float>(0)[2];
52  float tx = _tvec.ptr<float>(0)[0];
53  float ty = _tvec.ptr<float>(0)[1];
54  float tz = _tvec.ptr<float>(0)[2];
55  float nsqa = rx * rx + ry * ry + rz * rz;
56  float a = std::sqrt(nsqa);
57  float i_a = a ? 1. / a : 0;
58  float rnx = rx * i_a;
59  float rny = ry * i_a;
60  float rnz = rz * i_a;
61  float cos_a = cos(a);
62  float sin_a = sin(a);
63  float _1_cos_a = 1. - cos_a;
64  rt_44[0] = cos_a + rnx * rnx * _1_cos_a;
65  rt_44[1] = rnx * rny * _1_cos_a - rnz * sin_a;
66  rt_44[2] = rny * sin_a + rnx * rnz * _1_cos_a;
67  rt_44[3] = tx;
68  rt_44[4] = rnz * sin_a + rnx * rny * _1_cos_a;
69  rt_44[5] = cos_a + rny * rny * _1_cos_a;
70  rt_44[6] = -rnx * sin_a + rny * rnz * _1_cos_a;
71  rt_44[7] = ty;
72  rt_44[8] = -rny * sin_a + rnx * rnz * _1_cos_a;
73  rt_44[9] = rnx * sin_a + rny * rnz * _1_cos_a;
74  rt_44[10] = cos_a + rnz * rnz * _1_cos_a;
75  rt_44[11] = tz;
76  rt_44[12] = rt_44[13] = rt_44[14] = 0;
77  rt_44[15] = 1;
78  return Matrix;
79 }
80 
81 void impl__aruco_getRTfromMatrix44(const cv::Mat& M, cv::Mat& R, cv::Mat& T)
82 {
83  assert(M.cols == M.rows && M.cols == 4);
84  assert(M.type() == CV_32F || M.type() == CV_64F);
85 
86  // extract the rotation part
87  cv::Mat r33 = cv::Mat(M, cv::Rect(0, 0, 3, 3));
88  cv::SVD svd(r33);
89  cv::Mat Rpure = svd.u * svd.vt;
90  cv::Rodrigues(Rpure, R);
91  T.create(1, 3, M.type());
92  if (M.type() == CV_32F)
93  for (int i = 0; i < 3; i++)
94  T.ptr<float>(0)[i] = M.at<float>(i, 3);
95  else
96  for (int i = 0; i < 3; i++)
97  T.ptr<double>(0)[i] = M.at<double>(i, 3);
98 }
99 
100 double reprj_error(const std::vector<cv::Point3f>& objPoints,
101  const std::vector<cv::Point2f> points2d, const CameraParameters& imp,
102  const cv::Mat& rt44)
103 {
104  std::vector<cv::Point2f> prepj;
105  cv::Mat rv, tv;
106  impl__aruco_getRTfromMatrix44(rt44, rv, tv);
107  cv::projectPoints(objPoints, rv, tv, imp.CameraMatrix, imp.Distorsion, prepj);
108  double sum = 0;
109  int nvalid = 0;
110  for (size_t i = 0; i < prepj.size(); i++)
111  {
112  if (!std::isnan(objPoints[i].x))
113  {
114  sum += cv::norm(points2d[i] - prepj[i]);
115  nvalid++;
116  }
117  }
118  return sum / double(nvalid);
119 }
120 
125 float rigidBodyTransformation_Horn1987(const std::vector<cv::Point3f>& POrg,
126  const std::vector<cv::Point3f>& PDst, cv::Mat& RT_4x4)
127 {
128  struct Quaternion
129  {
130  Quaternion(float q0, float q1, float q2, float q3)
131  {
132  q[0] = q0;
133  q[1] = q1;
134  q[2] = q2;
135  q[3] = q3;
136  }
137  cv::Mat getRotation() const
138  {
139  cv::Mat R(3, 3, CV_32F);
140  R.at<float>(0, 0) = q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3];
141  R.at<float>(0, 1) = 2.f * (q[1] * q[2] - q[0] * q[3]);
142  R.at<float>(0, 2) = 2.f * (q[1] * q[3] + q[0] * q[2]);
143 
144  R.at<float>(1, 0) = 2.f * (q[1] * q[2] + q[0] * q[3]);
145  R.at<float>(1, 1) = q[0] * q[0] + q[2] * q[2] - q[1] * q[1] - q[3] * q[3];
146  R.at<float>(1, 2) = 2.f * (q[2] * q[3] - q[0] * q[1]);
147 
148  R.at<float>(2, 0) = 2.f * (q[1] * q[3] - q[0] * q[2]);
149  R.at<float>(2, 1) = 2.f * (q[2] * q[3] + q[0] * q[1]);
150  R.at<float>(2, 2) = q[0] * q[0] + q[3] * q[3] - q[1] * q[1] - q[2] * q[2];
151  return R;
152  }
153  float q[4];
154  };
155 
156  assert(POrg.size() == PDst.size());
157 
158  cv::Mat _org(POrg.size(), 3, CV_32F, (float*)&POrg[0]);
159  cv::Mat _dst(PDst.size(), 3, CV_32F, (float*)&PDst[0]);
160 
161  // _org = _org.reshape(1);
162  // _dst = _dst.reshape(1);
163  cv::Mat Mu_s = cv::Mat::zeros(1, 3, CV_32F);
164  cv::Mat Mu_m = cv::Mat::zeros(1, 3, CV_32F);
165  // cout << _s << endl << _m << endl;
166 
167  // calculate means
168  for (int i = 0; i < _org.rows; i++)
169  {
170  Mu_s += _org(cv::Range(i, i + 1), cv::Range(0, 3));
171  Mu_m += _dst(cv::Range(i, i + 1), cv::Range(0, 3));
172  }
173 
174  // now, divide
175  for (int i = 0; i < 3; i++)
176  {
177  Mu_s.ptr<float>(0)[i] /= float(_org.rows);
178  Mu_m.ptr<float>(0)[i] /= float(_dst.rows);
179  }
180 
181  // cout << "Mu_s = " << Mu_s << endl;
182  // cout << "Mu_m = " << Mu_m << endl;
183 
184  cv::Mat Mu_st = Mu_s.t() * Mu_m;
185  // cout << "Mu_st = " << Mu_st << endl;
186  cv::Mat Var_sm = cv::Mat::zeros(3, 3, CV_32F);
187  for (int i = 0; i < _org.rows; i++)
188  Var_sm += (_org(cv::Range(i, i + 1), cv::Range(0, 3)).t() *
189  _dst(cv::Range(i, i + 1), cv::Range(0, 3))) -
190  Mu_st;
191  // cout << "Var_sm=" << Var_sm << endl;
192  for (int i = 0; i < 3; i++)
193  for (int j = 0; j < 3; j++)
194  Var_sm.at<float>(i, j) /= float(_org.rows);
195  // cout << "Var_sm = " << Var_sm << endl;
196 
197  cv::Mat AA = Var_sm - Var_sm.t();
198  // cout << "AA = " << AA << endl;
199  cv::Mat A(3, 1, CV_32F);
200  A.at<float>(0, 0) = AA.at<float>(1, 2);
201  A.at<float>(1, 0) = AA.at<float>(2, 0);
202  A.at<float>(2, 0) = AA.at<float>(0, 1);
203  // cout << "A =" << A << endl;
204  cv::Mat Q_Var_sm(4, 4, CV_32F);
205  Q_Var_sm.at<float>(0, 0) = static_cast<float>(trace(Var_sm)[0]);
206  for (int i = 1; i < 4; i++)
207  {
208  Q_Var_sm.at<float>(0, i) = A.ptr<float>(0)[i - 1];
209  Q_Var_sm.at<float>(i, 0) = A.ptr<float>(0)[i - 1];
210  }
211  cv::Mat q33 = Var_sm + Var_sm.t() - (trace(Var_sm)[0] * cv::Mat::eye(3, 3, CV_32F));
212 
213  cv::Mat Q33 = Q_Var_sm(cv::Range(1, 4), cv::Range(1, 4));
214  q33.copyTo(Q33);
215  // cout << "Q_Var_sm" << endl << Q_Var_sm << endl;
216  cv::Mat eigenvalues, eigenvectors;
217  eigen(Q_Var_sm, eigenvalues, eigenvectors);
218  // cout << "EEI = " << eigenvalues << endl;
219  // cout << "V = " << (eigenvectors.type() == CV_32F) << " " << eigenvectors << endl;
220 
221  Quaternion rot(eigenvectors.at<float>(0, 0), eigenvectors.at<float>(0, 1),
222  eigenvectors.at<float>(0, 2), eigenvectors.at<float>(0, 3));
223  cv::Mat RR = rot.getRotation();
224  // cout << "RESULT = " << endl << RR << endl;
225  cv::Mat T = Mu_m.t() - RR * Mu_s.t();
226  // cout << "T = " << T << endl;
227 
228  RT_4x4 = cv::Mat::eye(4, 4, CV_32F);
229  cv::Mat r33 = RT_4x4(cv::Range(0, 3), cv::Range(0, 3));
230  RR.copyTo(r33);
231  for (int i = 0; i < 3; i++)
232  RT_4x4.at<float>(i, 3) = T.ptr<float>(0)[i];
233  // cout << "RESS = " << RT << endl;
234 
235  // compute the average transform error
236  float err = 0;
237  float* matrix = RT_4x4.ptr<float>(0);
238  for (size_t i = 0; i < POrg.size(); i++)
239  {
240  cv::Point3f org = POrg[i];
241  cv::Point3f dest_est;
242  dest_est.x = matrix[0] * org.x + matrix[1] * org.y + matrix[2] * org.z + matrix[3];
243  dest_est.y = matrix[4] * org.x + matrix[5] * org.y + matrix[6] * org.z + matrix[7];
244  dest_est.z = matrix[8] * org.x + matrix[9] * org.y + matrix[10] * org.z + matrix[11];
245  cv::Point3f dest_real = PDst[i];
246  err += static_cast<float>(cv::norm(dest_est - dest_real));
247  }
248 
249  return err / float(POrg.size());
250  ;
251 }
252 
253 } // namespace aruco_private
254 
255 inline double hubber(double e, double _delta)
256 {
257  double dsqr = _delta * _delta;
258  if (e <= dsqr)
259  {
260  // inlier
261  return e;
262  }
263  else
264  {
265  // outlier
266  double sqrte = sqrt(e); // absolute value of the error
267  return 2 * sqrte * _delta - dsqr; // rho(e) = 2 * delta * e^(1/2) - delta^2
268  }
269 }
270 
271 inline double hubberMono(double e)
272 {
273  if (e <= 5.991)
274  {
275  // inlier
276  return e;
277  }
278  else
279  // outlier
280  return 4.895303872 * sqrt(e) - 5.991; // rho(e) = 2 * delta * e^(1/2) - delta^2
281 }
282 
283 inline double getHubberMonoWeight(double SqErr, double Information)
284 {
285  return sqrt(hubberMono(Information * SqErr) / SqErr);
286 }
287 template <typename T>
288 double __aruco_solve_pnp(const std::vector<cv::Point3f>& p3d,
289  const std::vector<cv::Point2f>& p2d, const cv::Mat& cam_matrix,
290  const cv::Mat& dist, cv::Mat& r_io, cv::Mat& t_io)
291 {
292  assert(r_io.type() == CV_32F);
293  assert(t_io.type() == CV_32F);
294  assert(t_io.total() == r_io.total());
295  assert(t_io.total() == 3);
296  auto toSol = [](const cv::Mat& r, const cv::Mat& t)
297  {
298  typename LevMarq<T>::eVector sol(6);
299  for (int i = 0; i < 3; i++)
300  {
301  sol(i) = r.ptr<float>(0)[i];
302  sol(i + 3) = t.ptr<float>(0)[i];
303  }
304  return sol;
305  };
306  auto fromSol = [](const typename LevMarq<T>::eVector& sol, cv::Mat& r, cv::Mat& t)
307  {
308  r.create(1, 3, CV_32F);
309  t.create(1, 3, CV_32F);
310  for (int i = 0; i < 3; i++)
311  {
312  r.ptr<float>(0)[i] = sol(i);
313  t.ptr<float>(0)[i] = sol(i + 3);
314  }
315  };
316 
317  cv::Mat Jacb;
318  auto err_f = [&](const typename LevMarq<T>::eVector& sol, typename LevMarq<T>::eVector& err)
319  {
320  std::vector<cv::Point2f> p2d_rej;
321  cv::Mat r, t;
322  fromSol(sol, r, t);
323  cv::projectPoints(p3d, r, t, cam_matrix, dist, p2d_rej, Jacb);
324  err.resize(p3d.size() * 2);
325  int err_idx = 0;
326  for (size_t i = 0; i < p3d.size(); i++)
327  {
328  cv::Point2f errP = p2d_rej[i] - p2d[i];
329 
330  double SqErr = (errP.x * errP.x + errP.y * errP.y);
331 
332  float robuse_weight = getHubberMonoWeight(SqErr, 1);
333  err(err_idx++) = robuse_weight * errP.x; // p2d_rej[i].x - p2d[i].x;
334  err(err_idx++) = robuse_weight * errP.y; // p2d_rej[i].y - p2d[i].y;
335  }
336  };
337  auto jac_f = [&](const typename LevMarq<T>::eVector& sol,
338  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>& J)
339  {
340  (void)(sol);
341  J.resize(p3d.size() * 2, 6);
342  for (size_t i = 0; i < p3d.size() * 2; i++)
343  {
344  double* jacb = Jacb.ptr<double>(i);
345  for (int j = 0; j < 6; j++)
346  J(i, j) = jacb[j];
347  }
348  };
349 
350  LevMarq<T> solver;
351  solver.setParams(100, 0.01, 0.01);
352 
353  // solver.verbose() = true;
354  typename LevMarq<T>::eVector sol = toSol(r_io, t_io);
355  auto err = solver.solve(sol, err_f, jac_f);
356 
357  fromSol(sol, r_io, t_io);
358  return err;
359 }
360 
361 double __aruco_solve_pnp(const std::vector<cv::Point3f>& p3d,
362  const std::vector<cv::Point2f>& p2d, const cv::Mat& cam_matrix,
363  const cv::Mat& dist, cv::Mat& r_io, cv::Mat& t_io)
364 {
365 #ifdef DOUBLE_PRECISION_PNP
366  return __aruco_solve_pnp<double>(p3d, p2d, cam_matrix, dist, r_io, t_io);
367 #else
368  return __aruco_solve_pnp<float>(p3d, p2d, cam_matrix, dist, r_io, t_io);
369 #endif
370 }
371 
373  float _msize, float minerrorRatio)
374 {
375  if (_rvec.empty())
376  {
377  // if no previous data, use from scratch
378  cv::Mat rv, tv;
379  auto solutions = solvePnP_(Marker::get3DPoints(_msize), m, _cam_params.CameraMatrix,
380  _cam_params.Distorsion);
381  double errorRatio = solutions[1].second / solutions[0].second;
382  if (errorRatio < minerrorRatio)
383  return false;
384 
385  // // is the error ratio big enough
386  // cv::solvePnP(Marker::get3DPoints(_msize), m, _cam_params.CameraMatrix,
387  // _cam_params.Distorsion, rv, tv);
388  // __aruco_solve_pnp(Marker::get3DPoints(_msize), m, _cam_params.CameraMatrix,
389  // _cam_params.Distorsion, _rvec, _tvec);
390  // rv.convertTo(_rvec, CV_32F);
391  // tv.convertTo(_tvec, CV_32F);
392  // aruco_private::impl__aruco_getRTfromMatrix44(solutions[0].first, _rvec, _tvec);
393  }
394  else
395  {
396  __aruco_solve_pnp(Marker::get3DPoints(_msize), m, _cam_params.CameraMatrix,
397  _cam_params.Distorsion, _rvec, _tvec);
398  }
399 
400  _rvec.convertTo(m.Rvec, CV_32F);
401  _tvec.convertTo(m.Tvec, CV_32F);
402  m.ssize = _msize;
403  return true;
404 }
405 
407 {
408  _isValid = false;
409  _initial_err = -1;
411 }
412 
414  const MarkerMap& msconf, float markerSize)
415 {
416  _msconf = msconf;
417  _cam_params = cam_params;
418  if (!cam_params.isValid())
419  throw cv::Exception(9001, "Invalid camera parameters",
420  "MarkerMapPoseTracker::setParams", __FILE__, __LINE__);
421  if (_msconf.mInfoType == MarkerMap::PIX && markerSize <= 0)
422  throw cv::Exception(9001, "You should indicate the markersize since the MarkerMap is in pixels",
423  "MarkerMapPoseTracker::setParams", __FILE__, __LINE__);
425  throw cv::Exception(9001, "Invalid MarkerMap", "MarkerMapPoseTracker::setParams",
426  __FILE__, __LINE__);
428  _msconf = _msconf.convertToMeters(markerSize);
429 
430  _isValid = true;
431 
432  // create a map for fast access to elements
433  _map_mm.clear();
434  for (auto m : msconf)
435  _map_mm.insert(std::make_pair(m.id, m));
436 
437  // now, compute the marker_m2g map
438  for (auto m : _map_mm)
439  {
440  const Marker3DInfo& m3dinfo = m.second;
441  auto p3d_marker = Marker::get3DPoints(m3dinfo.getMarkerSize());
442 
443  // compute the transform going from global to marker to using Horn
444  cv::Mat RT;
446  marker_m2g[m.first] = RT;
447  }
448 }
449 
450 cv::Mat MarkerMapPoseTracker::relocalization(const std::vector<Marker>& v_m)
451 {
452  // get the markers in v_m that are in the map
453  std::vector<Marker> mapMarkers;
454  for (auto marker : v_m)
455  {
456  if (_map_mm.find(marker.id) != _map_mm.end())
457  mapMarkers.push_back(marker);
458  }
459 
460  if (mapMarkers.size() == 0)
461  return cv::Mat();
462  struct minfo
463  {
464  int id;
465  cv::Mat rt_f2m;
466  double err;
467  };
468  struct se3
469  {
470  float rt[6];
471  };
472 
473  cv::Mat pose_f2g_out; // result
474 
475  // estimate the markers locations and see if there is at least one good enough
476  std::vector<minfo> good_marker_locations;
477  std::vector<minfo> all_marker_locations;
478 
479  for (const Marker& marker : mapMarkers)
480  {
481  // for each visible marker
482  auto mpi = solvePnP_(_map_mm[marker.id].getMarkerSize(), marker,
484  minfo mi;
485  mi.id = marker.id;
486  mi.err = mpi[0].second;
487  mi.rt_f2m = mpi[0].first;
488  all_marker_locations.push_back(mi);
489  if (mpi[1].second / mpi[0].second > aruco_minerrratio_valid)
490  good_marker_locations.push_back(mi);
491  mi.rt_f2m = mpi[1].first;
492  mi.err = mpi[1].second;
493  all_marker_locations.push_back(mi);
494  }
495 
496  // try using more than one marker approach
497  if (mapMarkers.size() >= 2)
498  {
499  // collect all the markers 3D locations
500  std::vector<cv::Point2f> markerPoints2d;
501  std::vector<cv::Point3f> markerPoints3d;
502  for (const Marker& marker : mapMarkers)
503  {
504  markerPoints2d.insert(markerPoints2d.end(), marker.begin(), marker.end());
505  auto p3d = _map_mm[marker.id].points;
506  markerPoints3d.insert(markerPoints3d.end(), p3d.begin(), p3d.end());
507  }
508 
509  // take the all poses and select the one that minimizes the global reproj error
510  for (auto& ml : all_marker_locations)
511  {
512  auto pose = ml.rt_f2m * marker_m2g[ml.id];
513  // now, compute the repj error of all markers using this info
514  ml.err = aruco_private::reprj_error(markerPoints3d, markerPoints2d, _cam_params, pose);
515  }
516  // sort and get the best
517  std::sort(all_marker_locations.begin(), all_marker_locations.end(),
518  [](const minfo& a, const minfo& b) { return a.err < b.err; });
519  _initial_err = all_marker_locations.front().err;
520  auto& best = all_marker_locations.front();
521  pose_f2g_out = best.rt_f2m * marker_m2g[best.id];
522  }
523 
524  if (pose_f2g_out.empty() && good_marker_locations.size() > 0)
525  {
526  std::sort(good_marker_locations.begin(), good_marker_locations.end(),
527  [](const minfo& a, const minfo& b) { return a.err < b.err; });
528  auto best = good_marker_locations[0];
529 
530  // estimate current location
531  pose_f2g_out = best.rt_f2m * marker_m2g[best.id];
532  }
533  return pose_f2g_out;
534 }
535 
536 bool MarkerMapPoseTracker::estimatePose(const std::vector<Marker>& v_m)
537 {
538  std::vector<cv::Point2f> p2d;
539  std::vector<cv::Point3f> p3d;
540  for (auto marker : v_m)
541  {
542  if (_map_mm.find(marker.id) != _map_mm.end())
543  {
544  // is the marker part of the map?
545  for (auto p : marker)
546  p2d.push_back(p);
547  for (auto p : _map_mm[marker.id].points)
548  p3d.push_back(p);
549  }
550  }
551 
552  if (p2d.size() == 0)
553  {
554  // no points in the vector
555  _rvec = cv::Mat();
556  _tvec = cv::Mat();
557  return false;
558  }
559  else
560  {
561  if (_rvec.empty())
562  {
563  // requires relocalization since past pose is ALL_DICTS
564  // relocalization provides an initial position that will be further refined
565  auto InitialPose = relocalization(v_m);
566  if (InitialPose.empty())
567  {
568  return false;
569  }
570 
572  }
573 
574  // refine
576 
577  return true;
578  }
579 }
580 
582 {
583  if (_rvec.empty() || _tvec.empty())
584  return cv::Mat();
586 }
587 
589 {
590  if (_rvec.empty() || _tvec.empty())
591  return cv::Mat();
593 }
594 
595 } // namespace aruco
aruco::aruco_private::impl__aruco_getRTfromMatrix44
void impl__aruco_getRTfromMatrix44(const cv::Mat &M, cv::Mat &R, cv::Mat &T)
Definition: posetracker.cpp:81
aruco::LevMarq::eVector
Eigen::Matrix< T, Eigen::Dynamic, 1 > eVector
Definition: levmarq.h:45
aruco::MarkerMap
This class defines a set of markers whose locations are attached to a common reference system,...
Definition: markermap.h:111
aruco::LevMarq::setParams
void setParams(int maxIters, double minError, double min_step_error_diff=0, double tau=1, double der_epsilon=1e-3)
setParams
Definition: levmarq.h:214
aruco::aruco_private::reprj_error
double reprj_error(const std::vector< cv::Point3f > &objPoints, const std::vector< cv::Point2f > points2d, const CameraParameters &imp, const cv::Mat &rt44)
Definition: posetracker.cpp:100
aruco::MarkerPoseTracker::getRTMatrix
cv::Mat getRTMatrix() const
Definition: posetracker.cpp:588
ippe.h
aruco::CameraParameters
Parameters of the camera.
Definition: cameraparameters.h:29
aruco::MarkerMapPoseTracker::MarkerMapPoseTracker
MarkerMapPoseTracker()
Definition: posetracker.cpp:406
aruco::Marker3DInfo::points
std::vector< cv::Point3f > points
Definition: markermap.h:36
aruco::Marker::Rvec
cv::Mat Rvec
Definition: marker.h:43
aruco::MarkerMapPoseTracker::_rvec
cv::Mat _rvec
Definition: posetracker.h:175
aruco::solvePnP_
ARUCO_EXPORT std::vector< std::pair< cv::Mat, double > > solvePnP_(float size, const std::vector< cv::Point2f > &imgPoints, cv::InputArray cameraMatrix, cv::InputArray distCoeffs)
Definition: ippe.cpp:115
aruco::CameraParameters::isValid
bool isValid() const
Definition: cameraparameters.h:63
aruco::MarkerMapPoseTracker::relocalization
cv::Mat relocalization(const std::vector< Marker > &v_m)
Definition: posetracker.cpp:450
f
f
aruco::MarkerMapPoseTracker::_msconf
MarkerMap _msconf
Definition: posetracker.h:177
aruco::CameraParameters::CameraMatrix
cv::Mat CameraMatrix
Definition: cameraparameters.h:33
aruco::MarkerMapPoseTracker::setParams
void setParams(const CameraParameters &cam_params, const MarkerMap &msconf, float markerSize=-1)
Definition: posetracker.cpp:413
aruco::MarkerMapPoseTracker::aruco_minerrratio_valid
float aruco_minerrratio_valid
Definition: posetracker.h:181
aruco::MarkerMapPoseTracker::_isValid
bool _isValid
Definition: posetracker.h:179
aruco::MarkerMapPoseTracker::_initial_err
double _initial_err
Definition: posetracker.h:185
aruco::MarkerPoseTracker::_rvec
cv::Mat _rvec
Definition: posetracker.h:101
aruco::aruco_private::impl__aruco_getRTMatrix
cv::Mat impl__aruco_getRTMatrix(const cv::Mat &_rvec, const cv::Mat &_tvec)
Definition: posetracker.cpp:40
aruco::LevMarq::solve
double solve(eVector &z, F_z_x, F_z_J)
solve non linear minimization problem ||F(z)||, where F(z)=f(z) f(z)^t
Definition: levmarq.h:343
posetracker.h
aruco::MarkerMap::NONE
@ NONE
Definition: markermap.h:183
aruco::MarkerMapPoseTracker::marker_m2g
std::map< uint32_t, cv::Mat > marker_m2g
Definition: posetracker.h:182
aruco::Marker
Definition: marker.h:35
aruco::MarkerPoseTracker::estimatePose
bool estimatePose(Marker &m, const CameraParameters &cam_params, float markerSize, float minErrorRatio=10)
estimatePose
Definition: posetracker.cpp:372
levmarq.h
aruco::hubber
double hubber(double e, double _delta)
Definition: posetracker.cpp:255
aruco::__aruco_solve_pnp
double __aruco_solve_pnp(const std::vector< cv::Point3f > &p3d, const std::vector< cv::Point2f > &p2d, const cv::Mat &cam_matrix, const cv::Mat &dist, cv::Mat &r_io, cv::Mat &t_io)
Definition: posetracker.cpp:288
aruco::MarkerPoseTracker::_tvec
cv::Mat _tvec
Definition: posetracker.h:101
aruco::Marker3DInfo::getMarkerSize
float getMarkerSize() const
Definition: markermap.h:47
aruco::aruco_private::rigidBodyTransformation_Horn1987
float rigidBodyTransformation_Horn1987(const std::vector< cv::Point3f > &POrg, const std::vector< cv::Point3f > &PDst, cv::Mat &RT_4x4)
Definition: posetracker.cpp:125
aruco::getHubberMonoWeight
double getHubberMonoWeight(double SqErr, double Information)
Definition: posetracker.cpp:283
aruco::MarkerMap::mInfoType
int mInfoType
Definition: markermap.h:195
aruco::MarkerMap::PIX
@ PIX
Definition: markermap.h:184
aruco::MarkerMapPoseTracker::estimatePose
bool estimatePose(const std::vector< Marker > &v_m)
Definition: posetracker.cpp:536
aruco
Definition: cameraparameters.h:24
aruco::MarkerMap::convertToMeters
MarkerMap convertToMeters(float markerSize) const
Definition: markermap.cpp:320
aruco::hubberMono
double hubberMono(double e)
Definition: posetracker.cpp:271
aruco::MarkerMapPoseTracker::_map_mm
std::map< int, Marker3DInfo > _map_mm
Definition: posetracker.h:178
aruco::Marker::get3DPoints
vector< cv::Point3f > get3DPoints() const
Definition: marker.h:178
aruco::MarkerMapPoseTracker::getRTMatrix
cv::Mat getRTMatrix() const
Definition: posetracker.cpp:581
aruco::MarkerMapPoseTracker::_cam_params
aruco::CameraParameters _cam_params
Definition: posetracker.h:176
aruco::CameraParameters::Distorsion
cv::Mat Distorsion
Definition: cameraparameters.h:35
aruco::Marker::Tvec
cv::Mat Tvec
Definition: marker.h:43
aruco::LevMarq
Definition: levmarq.h:42
aruco::MarkerMapPoseTracker::_tvec
cv::Mat _tvec
Definition: posetracker.h:175
aruco::Marker::ssize
float ssize
Definition: marker.h:41
aruco::Marker3DInfo
Definition: markermap.h:33


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