Visual Servoing Platform  version 3.5.1 under development (2022-12-02)
vpMbtDistanceKltPoints.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Klt polygon, containing points of interest.
33  *
34  * Authors:
35  * Romain Tallonneau
36  * Aurelien Yol
37  *
38  *****************************************************************************/
39 
40 #include <visp3/core/vpPolygon.h>
41 #include <visp3/mbt/vpMbtDistanceKltPoints.h>
42 #include <visp3/me/vpMeTracker.h>
43 
44 #if defined(VISP_HAVE_MODULE_KLT) && (defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100))
45 
46 #if defined(VISP_HAVE_CLIPPER)
47 #include <clipper.hpp> // clipper private library
48 #endif
49 
50 #if defined(__APPLE__) && defined(__MACH__) // Apple OSX and iOS (Darwin)
51 #include <TargetConditionals.h> // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro
52 #endif
53 
59  : H(), N(), N_cur(), invd0(1.), cRc0_0n(), initPoints(std::map<int, vpImagePoint>()),
60  curPoints(std::map<int, vpImagePoint>()), curPointsInd(std::map<int, int>()), nbPointsCur(0), nbPointsInit(0),
61  minNbPoint(4), enoughPoints(false), dt(1.), d0(1.), cam(), isTrackedKltPoints(true), polygon(NULL),
62  hiddenface(NULL), useScanLine(false)
63 {
64 }
65 
71 
81 void vpMbtDistanceKltPoints::init(const vpKltOpencv &_tracker, const vpImage<bool> *mask)
82 {
83  // extract ids of the points in the face
84  nbPointsInit = 0;
85  nbPointsCur = 0;
86  initPoints = std::map<int, vpImagePoint>();
87  curPoints = std::map<int, vpImagePoint>();
88  curPointsInd = std::map<int, int>();
89  std::vector<vpImagePoint> roi;
90  polygon->getRoiClipped(cam, roi);
91 
92  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
93  long id;
94  float x_tmp, y_tmp;
95  _tracker.getFeature((int)i, id, x_tmp, y_tmp);
96 
97  bool add = false;
98 
99  // Add points inside visibility mask only
100  if (vpMeTracker::inMask(mask, (unsigned int)y_tmp, (unsigned int)x_tmp)) {
101  if (useScanLine) {
102  if ((unsigned int)y_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getHeight() &&
103  (unsigned int)x_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getWidth() &&
104  hiddenface->getMbScanLineRenderer().getPrimitiveIDs()[(unsigned int)y_tmp][(unsigned int)x_tmp] ==
105  polygon->getIndex())
106  add = true;
107  } else if (vpPolygon::isInside(roi, y_tmp, x_tmp)) {
108  add = true;
109  }
110  }
111 
112  if (add) {
113 #if TARGET_OS_IPHONE
114  initPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
115  curPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
116  curPointsInd[(int)id] = (int)i;
117 #else
118  initPoints[id] = vpImagePoint(y_tmp, x_tmp);
119  curPoints[id] = vpImagePoint(y_tmp, x_tmp);
120  curPointsInd[id] = (int)i;
121 #endif
122  }
123  }
124 
125  nbPointsInit = (unsigned int)initPoints.size();
126  nbPointsCur = (unsigned int)curPoints.size();
127 
128  if (nbPointsCur >= minNbPoint)
129  enoughPoints = true;
130  else
131  enoughPoints = false;
132 
133  // initialisation of the value for the computation in SE3
135 
136  d0 = plan.getD();
137  N = plan.getNormal();
138 
139  N.normalize();
140  N_cur = N;
141  invd0 = 1.0 / d0;
142 }
143 
155 {
156  long id;
157  float x, y;
158  nbPointsCur = 0;
159  curPoints = std::map<int, vpImagePoint>();
160  curPointsInd = std::map<int, int>();
161 
162  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
163  _tracker.getFeature((int)i, id, x, y);
164  if (isTrackedFeature((int)id) && vpMeTracker::inMask(mask, (unsigned int)y, (unsigned int)x)) {
165 #if TARGET_OS_IPHONE
166  curPoints[(int)id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
167  curPointsInd[(int)id] = (int)i;
168 #else
169  curPoints[id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
170  curPointsInd[id] = (int)i;
171 #endif
172  }
173  }
174 
175  nbPointsCur = (unsigned int)curPoints.size();
176 
177  if (nbPointsCur >= minNbPoint)
178  enoughPoints = true;
179  else
180  enoughPoints = false;
181 
182  return nbPointsCur;
183 }
184 
196 {
197  unsigned int index_ = 0;
198 
199  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
200  for (; iter != curPoints.end(); ++iter) {
201  int id(iter->first);
202  double i_cur(iter->second.get_i()), j_cur(iter->second.get_j());
203 
204  double x_cur(0), y_cur(0);
205  vpPixelMeterConversion::convertPoint(cam, j_cur, i_cur, x_cur, y_cur);
206 
207  vpImagePoint iP0 = initPoints[id];
208  double x0(0), y0(0);
209  vpPixelMeterConversion::convertPoint(cam, iP0, x0, y0);
210 
211  double x0_transform,
212  y0_transform; // equivalent x and y in the first image (reference)
213  computeP_mu_t(x0, y0, x0_transform, y0_transform, H);
214 
215  double invZ = compute_1_over_Z(x_cur, y_cur);
216 
217  _J[2 * index_][0] = -invZ;
218  _J[2 * index_][1] = 0;
219  _J[2 * index_][2] = x_cur * invZ;
220  _J[2 * index_][3] = x_cur * y_cur;
221  _J[2 * index_][4] = -(1 + x_cur * x_cur);
222  _J[2 * index_][5] = y_cur;
223 
224  _J[2 * index_ + 1][0] = 0;
225  _J[2 * index_ + 1][1] = -invZ;
226  _J[2 * index_ + 1][2] = y_cur * invZ;
227  _J[2 * index_ + 1][3] = (1 + y_cur * y_cur);
228  _J[2 * index_ + 1][4] = -y_cur * x_cur;
229  _J[2 * index_ + 1][5] = -x_cur;
230 
231  _R[2 * index_] = (x0_transform - x_cur);
232  _R[2 * index_ + 1] = (y0_transform - y_cur);
233  index_++;
234  }
235 }
236 
237 double vpMbtDistanceKltPoints::compute_1_over_Z(double x, double y)
238 {
239  double num = cRc0_0n[0] * x + cRc0_0n[1] * y + cRc0_0n[2];
240  double den = -(d0 - dt);
241  return num / den;
242 }
243 
256 inline void vpMbtDistanceKltPoints::computeP_mu_t(double x_in, double y_in, double &x_out, double &y_out,
257  const vpMatrix &_cHc0)
258 {
259  double p_mu_t_2 = x_in * _cHc0[2][0] + y_in * _cHc0[2][1] + _cHc0[2][2];
260 
261  if (fabs(p_mu_t_2) < std::numeric_limits<double>::epsilon()) {
262  x_out = 0.0;
263  y_out = 0.0;
264  throw vpException(vpException::divideByZeroError, "the depth of the point is calculated to zero");
265  }
266 
267  x_out = (x_in * _cHc0[0][0] + y_in * _cHc0[0][1] + _cHc0[0][2]) / p_mu_t_2;
268  y_out = (x_in * _cHc0[1][0] + y_in * _cHc0[1][1] + _cHc0[1][2]) / p_mu_t_2;
269 }
270 
285 {
286  vpRotationMatrix cRc0;
287  vpTranslationVector ctransc0;
288 
289  _cTc0.extract(cRc0);
290  _cTc0.extract(ctransc0);
291  vpMatrix cHc0 = _cHc0.convert();
292 
293  // vpGEMM(cRc0, 1.0, invd0, cRc0, -1.0, _cHc0, VP_GEMM_A_T);
294  vpGEMM(ctransc0, N, -invd0, cRc0, 1.0, cHc0, VP_GEMM_B_T);
295  cHc0 /= cHc0[2][2];
296 
297  H = cHc0;
298 
299  // vpQuaternionVector NQuat(N[0], N[1], N[2], 0.0);
300  // vpQuaternionVector RotQuat(cRc0);
301  // vpQuaternionVector RotQuatConj(-RotQuat.x(), -RotQuat.y(),
302  // -RotQuat.z(), RotQuat.w()); vpQuaternionVector partial = RotQuat *
303  // NQuat; vpQuaternionVector resQuat = (partial * RotQuatConj);
304  //
305  // cRc0_0n = vpColVector(3);
306  // cRc0_0n[0] = resQuat.x();
307  // cRc0_0n[1] = resQuat.y();
308  // cRc0_0n[2] = resQuat.z();
309 
310  cRc0_0n = cRc0 * N;
311 
312  // vpPlane p(corners[0], corners[1], corners[2]);
313  // vpColVector Ncur = p.getNormal();
314  // Ncur.normalize();
315  N_cur = cRc0_0n;
316  dt = 0.0;
317  for (unsigned int i = 0; i < 3; i += 1) {
318  dt += ctransc0[i] * (N_cur[i]);
319  }
320 }
321 
329 bool vpMbtDistanceKltPoints::isTrackedFeature(int _id)
330 {
331  // std::map<int, vpImagePoint>::const_iterator iter = initPoints.begin();
332  // while(iter != initPoints.end()){
333  // if(iter->first == _id){
334  // return true;
335  // }
336  // iter++;
337  // }
338 
339  std::map<int, vpImagePoint>::iterator iter = initPoints.find(_id);
340  if (iter != initPoints.end())
341  return true;
342 
343  return false;
344 }
345 
356 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
357  cv::Mat &mask,
358 #else
359  IplImage *mask,
360 #endif
361  unsigned char nb, unsigned int shiftBorder)
362 {
363 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
364  int width = mask.cols;
365  int height = mask.rows;
366 #else
367  int width = mask->width;
368  int height = mask->height;
369 #endif
370 
371  int i_min, i_max, j_min, j_max;
372  std::vector<vpImagePoint> roi;
373  polygon->getRoiClipped(cam, roi);
374 
375  double shiftBorder_d = (double)shiftBorder;
376 
377 #if defined(VISP_HAVE_CLIPPER)
378  std::vector<vpImagePoint> roi_offset;
379 
380  ClipperLib::Path path;
381  for (std::vector<vpImagePoint>::const_iterator it = roi.begin(); it != roi.end(); ++it) {
382  path.push_back(ClipperLib::IntPoint((ClipperLib::cInt)it->get_u(), (ClipperLib::cInt)it->get_v()));
383  }
384 
385  ClipperLib::Paths solution;
386  ClipperLib::ClipperOffset co;
387  co.AddPath(path, ClipperLib::jtRound, ClipperLib::etClosedPolygon);
388  co.Execute(solution, -shiftBorder_d);
389 
390  // Keep biggest polygon by area
391  if (!solution.empty()) {
392  size_t index_max = 0;
393 
394  if (solution.size() > 1) {
395  double max_area = 0;
396  vpPolygon polygon_area;
397 
398  for (size_t i = 0; i < solution.size(); i++) {
399  std::vector<vpImagePoint> corners;
400 
401  for (size_t j = 0; j < solution[i].size(); j++) {
402  corners.push_back(vpImagePoint((double)(solution[i][j].Y), (double)(solution[i][j].X)));
403  }
404 
405  polygon_area.buildFrom(corners);
406  if (polygon_area.getArea() > max_area) {
407  max_area = polygon_area.getArea();
408  index_max = i;
409  }
410  }
411  }
412 
413  for (size_t i = 0; i < solution[index_max].size(); i++) {
414  roi_offset.push_back(vpImagePoint((double)(solution[index_max][i].Y), (double)(solution[index_max][i].X)));
415  }
416  } else {
417  roi_offset = roi;
418  }
419 
420  vpPolygon polygon_test(roi_offset);
421  vpImagePoint imPt;
422 #endif
423 
424 #if defined(VISP_HAVE_CLIPPER)
425  vpPolygon3D::getMinMaxRoi(roi_offset, i_min, i_max, j_min, j_max);
426 #else
427  vpPolygon3D::getMinMaxRoi(roi, i_min, i_max, j_min, j_max);
428 #endif
429 
430  /* check image boundaries */
431  if (i_min > height) { // underflow
432  i_min = 0;
433  }
434  if (i_max > height) {
435  i_max = height;
436  }
437  if (j_min > width) { // underflow
438  j_min = 0;
439  }
440  if (j_max > width) {
441  j_max = width;
442  }
443 
444 #if (VISP_HAVE_OPENCV_VERSION >= 0x020408)
445  for (int i = i_min; i < i_max; i++) {
446  double i_d = (double)i;
447 
448  for (int j = j_min; j < j_max; j++) {
449  double j_d = (double)j;
450 
451 #if defined(VISP_HAVE_CLIPPER)
452  imPt.set_ij(i_d, j_d);
453  if (polygon_test.isInside(imPt)) {
454  mask.ptr<uchar>(i)[j] = nb;
455  }
456 #else
457  if (shiftBorder != 0) {
458  if (vpPolygon::isInside(roi, i_d, j_d) && vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d + shiftBorder_d) &&
459  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d + shiftBorder_d) &&
460  vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d - shiftBorder_d) &&
461  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d - shiftBorder_d)) {
462  mask.at<unsigned char>(i, j) = nb;
463  }
464  } else {
465  if (vpPolygon::isInside(roi, i, j)) {
466  mask.at<unsigned char>(i, j) = nb;
467  }
468  }
469 #endif
470  }
471  }
472 #else
473  unsigned char *ptrData = (unsigned char *)mask->imageData + i_min * mask->widthStep + j_min;
474  for (int i = i_min; i < i_max; i++) {
475  double i_d = (double)i;
476  for (int j = j_min; j < j_max; j++) {
477  double j_d = (double)j;
478  if (shiftBorder != 0) {
479  if (vpPolygon::isInside(roi, i_d, j_d) && vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d + shiftBorder_d) &&
480  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d + shiftBorder_d) &&
481  vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d - shiftBorder_d) &&
482  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d - shiftBorder_d)) {
483  *(ptrData++) = nb;
484  } else {
485  ptrData++;
486  }
487  } else {
488  if (vpPolygon::isInside(roi, i, j)) {
489  *(ptrData++) = nb;
490  } else {
491  ptrData++;
492  }
493  }
494  }
495  ptrData += mask->widthStep - j_max + j_min;
496  }
497 #endif
498 }
499 
508 void vpMbtDistanceKltPoints::removeOutliers(const vpColVector &_w, const double &threshold_outlier)
509 {
510  std::map<int, vpImagePoint> tmp;
511  std::map<int, int> tmp2;
512  unsigned int nbSupp = 0;
513  unsigned int k = 0;
514 
515  nbPointsCur = 0;
516  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
517  for (; iter != curPoints.end(); ++iter) {
518  if (_w[k] > threshold_outlier && _w[k + 1] > threshold_outlier) {
519  // if(_w[k] > threshold_outlier || _w[k+1] > threshold_outlier){
520  tmp[iter->first] = vpImagePoint(iter->second.get_i(), iter->second.get_j());
521  tmp2[iter->first] = curPointsInd[iter->first];
522  nbPointsCur++;
523  } else {
524  nbSupp++;
525  initPoints.erase(iter->first);
526  }
527 
528  k += 2;
529  }
530 
531  if (nbSupp != 0) {
532  curPoints = tmp;
533  curPointsInd = tmp2;
534  if (nbPointsCur >= minNbPoint)
535  enoughPoints = true;
536  else
537  enoughPoints = false;
538  }
539 }
540 
547 {
548  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
549  for (; iter != curPoints.end(); ++iter) {
550  int id(iter->first);
551  vpImagePoint iP;
552  iP.set_i(static_cast<double>(iter->second.get_i()));
553  iP.set_j(static_cast<double>(iter->second.get_j()));
554 
556 
557  iP.set_i(vpMath::round(iP.get_i() + 7));
558  iP.set_j(vpMath::round(iP.get_j() + 7));
559  std::stringstream ss;
560  ss << id;
561  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
562  }
563 }
564 
571 {
572  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
573  for (; iter != curPoints.end(); ++iter) {
574  int id(iter->first);
575  vpImagePoint iP;
576  iP.set_i(static_cast<double>(iter->second.get_i()));
577  iP.set_j(static_cast<double>(iter->second.get_j()));
578 
580 
581  iP.set_i(vpMath::round(iP.get_i() + 7));
582  iP.set_j(vpMath::round(iP.get_j() + 7));
583  std::stringstream ss;
584  ss << id;
585  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
586  }
587 }
588 
590  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
591  bool displayFullModel)
592 {
593  std::vector<std::vector<double> > models = getModelForDisplay(camera, displayFullModel);
594 
595  for (size_t i = 0; i < models.size(); i++) {
596  vpImagePoint ip1(models[i][1], models[i][2]);
597  vpImagePoint ip2(models[i][3], models[i][4]);
598 
599  vpDisplay::displayLine(I, ip1, ip2, col, thickness);
600  }
601 }
602 
604  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
605  bool displayFullModel)
606 {
607  std::vector<std::vector<double> > models = getModelForDisplay(camera, displayFullModel);
608 
609  for (size_t i = 0; i < models.size(); i++) {
610  vpImagePoint ip1(models[i][1], models[i][2]);
611  vpImagePoint ip2(models[i][3], models[i][4]);
612 
613  vpDisplay::displayLine(I, ip1, ip2, col, thickness);
614  }
615 }
616 
622 std::vector<std::vector<double> > vpMbtDistanceKltPoints::getFeaturesForDisplay()
623 {
624  std::vector<std::vector<double> > features;
625 
626  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
627  for (; iter != curPoints.end(); ++iter) {
628  int id(iter->first);
629  vpImagePoint iP;
630  iP.set_i(static_cast<double>(iter->second.get_i()));
631  iP.set_j(static_cast<double>(iter->second.get_j()));
632 
633  vpImagePoint iP2;
634  iP2.set_i(vpMath::round(iP.get_i() + 7));
635  iP2.set_j(vpMath::round(iP.get_j() + 7));
636 
637 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
638  std::vector<double> params = {1, // KLT
639  iP.get_i(), iP.get_j(), iP2.get_i(), iP2.get_j(), static_cast<double>(id)};
640 #else
641  std::vector<double> params;
642  params.push_back(1); // KLT
643  params.push_back(iP.get_i());
644  params.push_back(iP.get_j());
645  params.push_back(iP2.get_i());
646  params.push_back(iP2.get_j());
647  params.push_back(static_cast<double>(id));
648 #endif
649  features.push_back(params);
650  }
651 
652  return features;
653 }
654 
663 std::vector<std::vector<double> > vpMbtDistanceKltPoints::getModelForDisplay(const vpCameraParameters &camera,
664  bool displayFullModel)
665 {
666  std::vector<std::vector<double> > models;
667 
668  if ((polygon->isVisible() && isTrackedKltPoints) || displayFullModel) {
669  std::vector<std::pair<vpPoint, unsigned int> > roi;
671 
672  for (unsigned int j = 0; j < roi.size(); j += 1) {
673  if (((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::NEAR_CLIPPING) == 0) &&
674  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::FAR_CLIPPING) == 0) &&
675  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::DOWN_CLIPPING) == 0) &&
676  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::UP_CLIPPING) == 0) &&
677  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::LEFT_CLIPPING) == 0) &&
678  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::RIGHT_CLIPPING) == 0)) {
679 
680  vpImagePoint ip1, ip2;
681  std::vector<std::pair<vpPoint, vpPoint> > linesLst;
682 
683  if (useScanLine && !displayFullModel)
684  hiddenface->computeScanLineQuery(roi[j].first, roi[(j + 1) % roi.size()].first, linesLst, true);
685  else
686  linesLst.push_back(std::make_pair(roi[j].first, roi[(j + 1) % roi.size()].first));
687 
688  for (unsigned int i = 0; i < linesLst.size(); i++) {
689  linesLst[i].first.project();
690  linesLst[i].second.project();
691  vpMeterPixelConversion::convertPoint(camera, linesLst[i].first.get_x(), linesLst[i].first.get_y(), ip1);
692  vpMeterPixelConversion::convertPoint(camera, linesLst[i].second.get_x(), linesLst[i].second.get_y(), ip2);
693 
694 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
695  std::vector<double> params = {0, // 0 for line parameters
696  ip1.get_i(), ip1.get_j(), ip2.get_i(), ip2.get_j()};
697 #else
698  std::vector<double> params;
699  params.push_back(0); // 0 for line parameters
700  params.push_back(ip1.get_i());
701  params.push_back(ip1.get_j());
702  params.push_back(ip2.get_i());
703  params.push_back(ip2.get_j());
704 #endif
705  models.push_back(params);
706  }
707  }
708  }
709  }
710 
711  return models;
712 }
713 
714 #elif !defined(VISP_BUILD_SHARED_LIBS)
715 // Work around to avoid warning: libvisp_mbt.a(vpMbtDistanceKltPoints.cpp.o)
716 // has no symbols
717 void dummy_vpMbtDistanceKltPoints(){};
718 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
vpColVector & normalize()
Class to define RGB colors available for display functionnalities.
Definition: vpColor.h:158
static const vpColor red
Definition: vpColor.h:217
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emited by ViSP classes.
Definition: vpException.h:72
@ divideByZeroError
Division by zero.
Definition: vpException.h:94
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
Implementation of an homography and operations on homographies.
Definition: vpHomography.h:175
vpMatrix convert() const
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:89
void set_j(double jj)
Definition: vpImagePoint.h:309
double get_j() const
Definition: vpImagePoint.h:132
void set_ij(double ii, double jj)
Definition: vpImagePoint.h:320
void set_i(double ii)
Definition: vpImagePoint.h:298
double get_i() const
Definition: vpImagePoint.h:121
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:79
int getNbFeatures() const
Get the number of current features.
Definition: vpKltOpencv.h:120
void getFeature(const int &index, long &id, float &x, float &y) const
static int round(double x)
Definition: vpMath.h:318
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
vpMbScanLine & getMbScanLineRenderer()
void computeScanLineQuery(const vpPoint &a, const vpPoint &b, std::vector< std::pair< vpPoint, vpPoint > > &lines, const bool &displayResults=false)
void updateMask(cv::Mat &mask, unsigned char _nb=255, unsigned int _shiftBorder=0)
void displayPrimitive(const vpImage< unsigned char > &_I)
bool useScanLine
Use scanline rendering.
void computeInteractionMatrixAndResidu(vpColVector &_R, vpMatrix &_J)
std::vector< std::vector< double > > getFeaturesForDisplay()
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void init(const vpKltOpencv &_tracker, const vpImage< bool > *mask=NULL)
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker, const vpImage< bool > *mask=NULL)
std::vector< std::vector< double > > getModelForDisplay(const vpCameraParameters &cam, bool displayFullModel=false)
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpMbtPolygon * polygon
Pointer to the polygon that define a face.
void removeOutliers(const vpColVector &weight, const double &threshold_outlier)
void computeHomography(const vpHomogeneousMatrix &_cTc0, vpHomography &cHc0)
virtual bool isVisible(const vpHomogeneousMatrix &cMo, double alpha, const bool &modulo=false, const vpCameraParameters &cam=vpCameraParameters(), unsigned int width=0, unsigned int height=0)
int getIndex() const
Definition: vpMbtPolygon.h:101
static bool inMask(const vpImage< bool > *mask, unsigned int i, unsigned int j)
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
This class defines the container for a plane geometrical structure.
Definition: vpPlane.h:59
double getD() const
Definition: vpPlane.h:111
vpColVector getNormal() const
Definition: vpPlane.cpp:248
vpPoint & getPoint(const unsigned int _index)
void getRoiClipped(const vpCameraParameters &cam, std::vector< vpImagePoint > &roi)
void getPolygonClipped(std::vector< std::pair< vpPoint, unsigned int > > &poly)
static void getMinMaxRoi(const std::vector< vpImagePoint > &roi, int &i_min, int &i_max, int &j_min, int &j_max)
Defines a generic 2D polygon.
Definition: vpPolygon.h:106
double getArea() const
Definition: vpPolygon.h:164
void buildFrom(const std::vector< vpImagePoint > &corners, const bool create_convex_hull=false)
Definition: vpPolygon.cpp:198
bool isInside(const vpImagePoint &iP, const PointInPolygonMethod &method=PnPolyRayCasting) const
Definition: vpPolygon.cpp:401
Implementation of a rotation matrix and operations on such kind of matrices.
Class that consider the case of a translation vector.