Visual Servoing Platform  version 3.6.1 under development (2024-05-27)
vpMbtDistanceKltPoints.cpp
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 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 https://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 *****************************************************************************/
35 
36 #include <visp3/core/vpPolygon.h>
37 #include <visp3/mbt/vpMbtDistanceKltPoints.h>
38 #include <visp3/me/vpMeTracker.h>
39 
40 #if defined(VISP_HAVE_MODULE_KLT) && defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC) && defined(HAVE_OPENCV_VIDEO)
41 
42 #if defined(VISP_HAVE_CLIPPER)
43 #include <clipper.hpp> // clipper private library
44 #endif
45 
46 #if defined(__APPLE__) && defined(__MACH__) // Apple OSX and iOS (Darwin)
47 #include <TargetConditionals.h> // To detect OSX or IOS using TARGET_OS_IPHONE or TARGET_OS_IOS macro
48 #endif
49 
55  : H(), N(), N_cur(), invd0(1.), cRc0_0n(), initPoints(std::map<int, vpImagePoint>()),
56  curPoints(std::map<int, vpImagePoint>()), curPointsInd(std::map<int, int>()), nbPointsCur(0), nbPointsInit(0),
57  minNbPoint(4), enoughPoints(false), dt(1.), d0(1.), cam(), isTrackedKltPoints(true), polygon(nullptr),
58  hiddenface(nullptr), useScanLine(false)
59 { }
60 
66 
76 void vpMbtDistanceKltPoints::init(const vpKltOpencv &_tracker, const vpImage<bool> *mask)
77 {
78  // extract ids of the points in the face
79  nbPointsInit = 0;
80  nbPointsCur = 0;
81  initPoints = std::map<int, vpImagePoint>();
82  curPoints = std::map<int, vpImagePoint>();
83  curPointsInd = std::map<int, int>();
84  std::vector<vpImagePoint> roi;
85  polygon->getRoiClipped(cam, roi);
86 
87  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
88  long id;
89  float x_tmp, y_tmp;
90  _tracker.getFeature((int)i, id, x_tmp, y_tmp);
91 
92  bool add = false;
93 
94  // Add points inside visibility mask only
95  if (vpMeTracker::inRoiMask(mask, (unsigned int)y_tmp, (unsigned int)x_tmp)) {
96  if (useScanLine) {
97  if ((unsigned int)y_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getHeight() &&
98  (unsigned int)x_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getWidth() &&
99  hiddenface->getMbScanLineRenderer().getPrimitiveIDs()[(unsigned int)y_tmp][(unsigned int)x_tmp] ==
100  polygon->getIndex())
101  add = true;
102  }
103  else if (vpPolygon::isInside(roi, y_tmp, x_tmp)) {
104  add = true;
105  }
106  }
107 
108  if (add) {
109 #ifdef TARGET_OS_IPHONE
110  initPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
111  curPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
112  curPointsInd[(int)id] = (int)i;
113 #else
114  initPoints[id] = vpImagePoint(y_tmp, x_tmp);
115  curPoints[id] = vpImagePoint(y_tmp, x_tmp);
116  curPointsInd[id] = (int)i;
117 #endif
118  }
119  }
120 
121  nbPointsInit = (unsigned int)initPoints.size();
122  nbPointsCur = (unsigned int)curPoints.size();
123 
124  if (nbPointsCur >= minNbPoint)
125  enoughPoints = true;
126  else
127  enoughPoints = false;
128 
129  // initialisation of the value for the computation in SE3
131 
132  d0 = plan.getD();
133  N = plan.getNormal();
134 
135  N.normalize();
136  N_cur = N;
137  invd0 = 1.0 / d0;
138 }
139 
151 {
152  long id;
153  float x, y;
154  nbPointsCur = 0;
155  curPoints = std::map<int, vpImagePoint>();
156  curPointsInd = std::map<int, int>();
157 
158  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
159  _tracker.getFeature((int)i, id, x, y);
160  if (isTrackedFeature((int)id) && vpMeTracker::inRoiMask(mask, (unsigned int)y, (unsigned int)x)) {
161 #ifdef TARGET_OS_IPHONE
162  curPoints[(int)id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
163  curPointsInd[(int)id] = (int)i;
164 #else
165  curPoints[id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
166  curPointsInd[id] = (int)i;
167 #endif
168  }
169  }
170 
171  nbPointsCur = (unsigned int)curPoints.size();
172 
173  if (nbPointsCur >= minNbPoint)
174  enoughPoints = true;
175  else
176  enoughPoints = false;
177 
178  return nbPointsCur;
179 }
180 
192 {
193  unsigned int index_ = 0;
194 
195  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
196  for (; iter != curPoints.end(); ++iter) {
197  int id(iter->first);
198  double i_cur(iter->second.get_i()), j_cur(iter->second.get_j());
199 
200  double x_cur(0), y_cur(0);
201  vpPixelMeterConversion::convertPoint(cam, j_cur, i_cur, x_cur, y_cur);
202 
203  vpImagePoint iP0 = initPoints[id];
204  double x0(0), y0(0);
205  vpPixelMeterConversion::convertPoint(cam, iP0, x0, y0);
206 
207  double x0_transform,
208  y0_transform; // equivalent x and y in the first image (reference)
209  computeP_mu_t(x0, y0, x0_transform, y0_transform, H);
210 
211  double invZ = compute_1_over_Z(x_cur, y_cur);
212 
213  _J[2 * index_][0] = -invZ;
214  _J[2 * index_][1] = 0;
215  _J[2 * index_][2] = x_cur * invZ;
216  _J[2 * index_][3] = x_cur * y_cur;
217  _J[2 * index_][4] = -(1 + x_cur * x_cur);
218  _J[2 * index_][5] = y_cur;
219 
220  _J[2 * index_ + 1][0] = 0;
221  _J[2 * index_ + 1][1] = -invZ;
222  _J[2 * index_ + 1][2] = y_cur * invZ;
223  _J[2 * index_ + 1][3] = (1 + y_cur * y_cur);
224  _J[2 * index_ + 1][4] = -y_cur * x_cur;
225  _J[2 * index_ + 1][5] = -x_cur;
226 
227  _R[2 * index_] = (x0_transform - x_cur);
228  _R[2 * index_ + 1] = (y0_transform - y_cur);
229  index_++;
230  }
231 }
232 
233 double vpMbtDistanceKltPoints::compute_1_over_Z(double x, double y)
234 {
235  double num = cRc0_0n[0] * x + cRc0_0n[1] * y + cRc0_0n[2];
236  double den = -(d0 - dt);
237  return num / den;
238 }
239 
252 inline void vpMbtDistanceKltPoints::computeP_mu_t(double x_in, double y_in, double &x_out, double &y_out,
253  const vpMatrix &_cHc0)
254 {
255  double p_mu_t_2 = x_in * _cHc0[2][0] + y_in * _cHc0[2][1] + _cHc0[2][2];
256 
257  if (fabs(p_mu_t_2) < std::numeric_limits<double>::epsilon()) {
258  x_out = 0.0;
259  y_out = 0.0;
260  throw vpException(vpException::divideByZeroError, "the depth of the point is calculated to zero");
261  }
262 
263  x_out = (x_in * _cHc0[0][0] + y_in * _cHc0[0][1] + _cHc0[0][2]) / p_mu_t_2;
264  y_out = (x_in * _cHc0[1][0] + y_in * _cHc0[1][1] + _cHc0[1][2]) / p_mu_t_2;
265 }
266 
281 {
282  vpRotationMatrix cRc0;
283  vpTranslationVector ctransc0;
284 
285  _cTc0.extract(cRc0);
286  _cTc0.extract(ctransc0);
287  vpMatrix cHc0 = _cHc0.convert();
288 
289  // vpGEMM(cRc0, 1.0, invd0, cRc0, -1.0, _cHc0, VP_GEMM_A_T);
290  vpGEMM(ctransc0, N, -invd0, cRc0, 1.0, cHc0, VP_GEMM_B_T);
291  cHc0 /= cHc0[2][2];
292 
293  H = cHc0;
294 
295  // vpQuaternionVector NQuat(N[0], N[1], N[2], 0.0);
296  // vpQuaternionVector RotQuat(cRc0);
297  // vpQuaternionVector RotQuatConj(-RotQuat.x(), -RotQuat.y(),
298  // -RotQuat.z(), RotQuat.w()); vpQuaternionVector partial = RotQuat *
299  // NQuat; vpQuaternionVector resQuat = (partial * RotQuatConj);
300  //
301  // cRc0_0n = vpColVector(3);
302  // cRc0_0n[0] = resQuat.x();
303  // cRc0_0n[1] = resQuat.y();
304  // cRc0_0n[2] = resQuat.z();
305 
306  cRc0_0n = cRc0 * N;
307 
308  // vpPlane p(corners[0], corners[1], corners[2]);
309  // vpColVector Ncur = p.getNormal();
310  // Ncur.normalize();
311  N_cur = cRc0_0n;
312  dt = 0.0;
313  for (unsigned int i = 0; i < 3; i += 1) {
314  dt += ctransc0[i] * (N_cur[i]);
315  }
316 }
317 
325 bool vpMbtDistanceKltPoints::isTrackedFeature(int _id)
326 {
327  // std::map<int, vpImagePoint>::const_iterator iter = initPoints.begin();
328  // while(iter != initPoints.end()){
329  // if(iter->first == _id){
330  // return true;
331  // }
332  // iter++;
333  // }
334 
335  std::map<int, vpImagePoint>::iterator iter = initPoints.find(_id);
336  if (iter != initPoints.end())
337  return true;
338 
339  return false;
340 }
341 
352  cv::Mat &mask,
353  unsigned char nb, unsigned int shiftBorder)
354 {
355  int width = mask.cols;
356  int height = mask.rows;
357 
358  int i_min, i_max, j_min, j_max;
359  std::vector<vpImagePoint> roi;
360  polygon->getRoiClipped(cam, roi);
361 
362  double shiftBorder_d = (double)shiftBorder;
363 
364 #if defined(VISP_HAVE_CLIPPER)
365  std::vector<vpImagePoint> roi_offset;
366 
367  ClipperLib::Path path;
368  for (std::vector<vpImagePoint>::const_iterator it = roi.begin(); it != roi.end(); ++it) {
369  path.push_back(ClipperLib::IntPoint((ClipperLib::cInt)it->get_u(), (ClipperLib::cInt)it->get_v()));
370  }
371 
372  ClipperLib::Paths solution;
373  ClipperLib::ClipperOffset co;
374  co.AddPath(path, ClipperLib::jtRound, ClipperLib::etClosedPolygon);
375  co.Execute(solution, -shiftBorder_d);
376 
377  // Keep biggest polygon by area
378  if (!solution.empty()) {
379  size_t index_max = 0;
380 
381  if (solution.size() > 1) {
382  double max_area = 0;
383  vpPolygon polygon_area;
384 
385  for (size_t i = 0; i < solution.size(); i++) {
386  std::vector<vpImagePoint> corners;
387 
388  for (size_t j = 0; j < solution[i].size(); j++) {
389  corners.push_back(vpImagePoint((double)(solution[i][j].Y), (double)(solution[i][j].X)));
390  }
391 
392  polygon_area.build(corners);
393  if (polygon_area.getArea() > max_area) {
394  max_area = polygon_area.getArea();
395  index_max = i;
396  }
397  }
398  }
399 
400  for (size_t i = 0; i < solution[index_max].size(); i++) {
401  roi_offset.push_back(vpImagePoint((double)(solution[index_max][i].Y), (double)(solution[index_max][i].X)));
402  }
403  }
404  else {
405  roi_offset = roi;
406  }
407 
408  vpPolygon polygon_test(roi_offset);
409  vpImagePoint imPt;
410 #endif
411 
412 #if defined(VISP_HAVE_CLIPPER)
413  vpPolygon3D::getMinMaxRoi(roi_offset, i_min, i_max, j_min, j_max);
414 #else
415  vpPolygon3D::getMinMaxRoi(roi, i_min, i_max, j_min, j_max);
416 #endif
417 
418  /* check image boundaries */
419  if (i_min > height) { // underflow
420  i_min = 0;
421  }
422  if (i_max > height) {
423  i_max = height;
424  }
425  if (j_min > width) { // underflow
426  j_min = 0;
427  }
428  if (j_max > width) {
429  j_max = width;
430  }
431 
432  for (int i = i_min; i < i_max; i++) {
433  double i_d = (double)i;
434 
435  for (int j = j_min; j < j_max; j++) {
436  double j_d = (double)j;
437 
438 #if defined(VISP_HAVE_CLIPPER)
439  imPt.set_ij(i_d, j_d);
440  if (polygon_test.isInside(imPt)) {
441  mask.ptr<uchar>(i)[j] = nb;
442  }
443 #else
444  if (shiftBorder != 0) {
445  if (vpPolygon::isInside(roi, i_d, j_d) && vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d + shiftBorder_d) &&
446  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d + shiftBorder_d) &&
447  vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d - shiftBorder_d) &&
448  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d - shiftBorder_d)) {
449  mask.at<unsigned char>(i, j) = nb;
450  }
451  }
452  else {
453  if (vpPolygon::isInside(roi, i, j)) {
454  mask.at<unsigned char>(i, j) = nb;
455  }
456  }
457 #endif
458  }
459  }
460 }
461 
470 void vpMbtDistanceKltPoints::removeOutliers(const vpColVector &_w, const double &threshold_outlier)
471 {
472  std::map<int, vpImagePoint> tmp;
473  std::map<int, int> tmp2;
474  unsigned int nbSupp = 0;
475  unsigned int k = 0;
476 
477  nbPointsCur = 0;
478  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
479  for (; iter != curPoints.end(); ++iter) {
480  if (_w[k] > threshold_outlier && _w[k + 1] > threshold_outlier) {
481  // if(_w[k] > threshold_outlier || _w[k+1] > threshold_outlier){
482  tmp[iter->first] = vpImagePoint(iter->second.get_i(), iter->second.get_j());
483  tmp2[iter->first] = curPointsInd[iter->first];
484  nbPointsCur++;
485  }
486  else {
487  nbSupp++;
488  initPoints.erase(iter->first);
489  }
490 
491  k += 2;
492  }
493 
494  if (nbSupp != 0) {
495  curPoints = tmp;
496  curPointsInd = tmp2;
497  if (nbPointsCur >= minNbPoint)
498  enoughPoints = true;
499  else
500  enoughPoints = false;
501  }
502 }
503 
510 {
511  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
512  for (; iter != curPoints.end(); ++iter) {
513  int id(iter->first);
514  vpImagePoint iP;
515  iP.set_i(static_cast<double>(iter->second.get_i()));
516  iP.set_j(static_cast<double>(iter->second.get_j()));
517 
519 
520  iP.set_i(vpMath::round(iP.get_i() + 7));
521  iP.set_j(vpMath::round(iP.get_j() + 7));
522  std::stringstream ss;
523  ss << id;
524  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
525  }
526 }
527 
534 {
535  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
536  for (; iter != curPoints.end(); ++iter) {
537  int id(iter->first);
538  vpImagePoint iP;
539  iP.set_i(static_cast<double>(iter->second.get_i()));
540  iP.set_j(static_cast<double>(iter->second.get_j()));
541 
543 
544  iP.set_i(vpMath::round(iP.get_i() + 7));
545  iP.set_j(vpMath::round(iP.get_j() + 7));
546  std::stringstream ss;
547  ss << id;
548  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
549  }
550 }
551 
553  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
554  bool displayFullModel)
555 {
556  std::vector<std::vector<double> > models = getModelForDisplay(camera, displayFullModel);
557 
558  for (size_t i = 0; i < models.size(); i++) {
559  vpImagePoint ip1(models[i][1], models[i][2]);
560  vpImagePoint ip2(models[i][3], models[i][4]);
561 
562  vpDisplay::displayLine(I, ip1, ip2, col, thickness);
563  }
564 }
565 
567  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
568  bool displayFullModel)
569 {
570  std::vector<std::vector<double> > models = getModelForDisplay(camera, displayFullModel);
571 
572  for (size_t i = 0; i < models.size(); i++) {
573  vpImagePoint ip1(models[i][1], models[i][2]);
574  vpImagePoint ip2(models[i][3], models[i][4]);
575 
576  vpDisplay::displayLine(I, ip1, ip2, col, thickness);
577  }
578 }
579 
585 std::vector<std::vector<double> > vpMbtDistanceKltPoints::getFeaturesForDisplay()
586 {
587  std::vector<std::vector<double> > features;
588 
589  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
590  for (; iter != curPoints.end(); ++iter) {
591  int id(iter->first);
592  vpImagePoint iP;
593  iP.set_i(static_cast<double>(iter->second.get_i()));
594  iP.set_j(static_cast<double>(iter->second.get_j()));
595 
596  vpImagePoint iP2;
597  iP2.set_i(vpMath::round(iP.get_i() + 7));
598  iP2.set_j(vpMath::round(iP.get_j() + 7));
599  std::vector<double> params = { 1, // KLT
600  iP.get_i(), iP.get_j(), iP2.get_i(), iP2.get_j(), static_cast<double>(id) };
601  features.push_back(params);
602  }
603 
604  return features;
605 }
606 
615 std::vector<std::vector<double> > vpMbtDistanceKltPoints::getModelForDisplay(const vpCameraParameters &camera,
616  bool displayFullModel)
617 {
618  std::vector<std::vector<double> > models;
619 
620  if ((polygon->isVisible() && isTrackedKltPoints) || displayFullModel) {
621  std::vector<std::pair<vpPoint, unsigned int> > roi;
623 
624  for (unsigned int j = 0; j < roi.size(); j += 1) {
625  if (((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::NEAR_CLIPPING) == 0) &&
626  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::FAR_CLIPPING) == 0) &&
627  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::DOWN_CLIPPING) == 0) &&
628  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::UP_CLIPPING) == 0) &&
629  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::LEFT_CLIPPING) == 0) &&
630  ((roi[(j + 1) % roi.size()].second & roi[j].second & vpPolygon3D::RIGHT_CLIPPING) == 0)) {
631 
632  vpImagePoint ip1, ip2;
633  std::vector<std::pair<vpPoint, vpPoint> > linesLst;
634 
635  if (useScanLine && !displayFullModel)
636  hiddenface->computeScanLineQuery(roi[j].first, roi[(j + 1) % roi.size()].first, linesLst, true);
637  else
638  linesLst.push_back(std::make_pair(roi[j].first, roi[(j + 1) % roi.size()].first));
639 
640  for (unsigned int i = 0; i < linesLst.size(); i++) {
641  linesLst[i].first.project();
642  linesLst[i].second.project();
643  vpMeterPixelConversion::convertPoint(camera, linesLst[i].first.get_x(), linesLst[i].first.get_y(), ip1);
644  vpMeterPixelConversion::convertPoint(camera, linesLst[i].second.get_x(), linesLst[i].second.get_y(), ip2);
645  std::vector<double> params = { 0, // 0 for line parameters
646  ip1.get_i(), ip1.get_j(), ip2.get_i(), ip2.get_j() };
647  models.push_back(params);
648  }
649  }
650  }
651  }
652 
653  return models;
654 }
655 
656 #elif !defined(VISP_BUILD_SHARED_LIBS)
657 // Work around to avoid warning: libvisp_mbt.a(vpMbtDistanceKltPoints.cpp.o)
658 // has no symbols
659 void dummy_vpMbtDistanceKltPoints() { };
660 #endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
vpColVector & normalize()
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
static const vpColor red
Definition: vpColor.h:211
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 emitted by ViSP classes.
Definition: vpException.h:59
@ divideByZeroError
Division by zero.
Definition: vpException.h:69
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:168
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:82
void set_j(double jj)
Definition: vpImagePoint.h:305
double get_j() const
Definition: vpImagePoint.h:125
void set_ij(double ii, double jj)
Definition: vpImagePoint.h:316
void set_i(double ii)
Definition: vpImagePoint.h:294
double get_i() const
Definition: vpImagePoint.h:114
Wrapper for the KLT (Kanade-Lucas-Tomasi) feature tracker implemented in OpenCV. Thus to enable this ...
Definition: vpKltOpencv.h:73
int getNbFeatures() const
Get the number of current features.
Definition: vpKltOpencv.h:197
void getFeature(const int &index, long &id, float &x, float &y) const
static int round(double x)
Definition: vpMath.h:405
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
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)
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker, const vpImage< bool > *mask=nullptr)
std::vector< std::vector< double > > getFeaturesForDisplay()
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
void init(const vpKltOpencv &_tracker, const vpImage< bool > *mask=nullptr)
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:91
static bool inRoiMask(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:54
double getD() const
Definition: vpPlane.h:106
vpColVector getNormal() const
Definition: vpPlane.cpp:249
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:98
vpPolygon & build(const std::vector< vpImagePoint > &corners, const bool &create_convex_hull=false)
Definition: vpPolygon.cpp:241
double getArea() const
Definition: vpPolygon.h:150
bool isInside(const vpImagePoint &iP, const PointInPolygonMethod &method=PnPolyRayCasting) const
Definition: vpPolygon.cpp:448
Implementation of a rotation matrix and operations on such kind of matrices.
Class that consider the case of a translation vector.