Visual Servoing Platform  version 3.6.1 under development (2024-04-20)
vpMbtDistanceKltCylinder.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 cylinder, containing points of interest.
33  *
34 *****************************************************************************/
35 
36 #include <visp3/core/vpPolygon.h>
37 #include <visp3/mbt/vpMbtDistanceKltCylinder.h>
38 #include <visp3/mbt/vpMbtDistanceKltPoints.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  : c0Mo(), p1Ext(), p2Ext(), cylinder(), circle1(), circle2(), initPoints(), initPoints3D(), curPoints(),
56  curPointsInd(), nbPointsCur(0), nbPointsInit(0), minNbPoint(4), enoughPoints(false), cam(),
57  isTrackedKltCylinder(true), listIndicesCylinderBBox(), hiddenface(nullptr), useScanLine(false)
58 { }
59 
65 
66 void vpMbtDistanceKltCylinder::buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r)
67 {
68  p1Ext = p1;
69  p2Ext = p2;
70 
71  vpColVector ABC(3);
72  vpColVector V1(3);
73  vpColVector V2(3);
74 
75  V1[0] = p1.get_oX();
76  V1[1] = p1.get_oY();
77  V1[2] = p1.get_oZ();
78  V2[0] = p2.get_oX();
79  V2[1] = p2.get_oY();
80  V2[2] = p2.get_oZ();
81 
82  // Get the axis of the cylinder
83  ABC = V1 - V2;
84 
85  // Build our extremity circles
86  circle1.setWorldCoordinates(ABC[0], ABC[1], ABC[2], p1.get_oX(), p1.get_oY(), p1.get_oZ(), r);
87  circle2.setWorldCoordinates(ABC[0], ABC[1], ABC[2], p2.get_oX(), p2.get_oY(), p2.get_oZ(), r);
88 
89  // Build our cylinder
90  cylinder.setWorldCoordinates(ABC[0], ABC[1], ABC[2], (p1.get_oX() + p2.get_oX()) / 2.0,
91  (p1.get_oY() + p2.get_oY()) / 2.0, (p1.get_oZ() + p2.get_oZ()) / 2.0, r);
92 }
93 
103 {
104  c0Mo = cMo;
105  cylinder.changeFrame(cMo);
106 
107  // extract ids of the points in the face
108  nbPointsInit = 0;
109  nbPointsCur = 0;
110  initPoints = std::map<int, vpImagePoint>();
111  initPoints3D = std::map<int, vpPoint>();
112  curPoints = std::map<int, vpImagePoint>();
113  curPointsInd = std::map<int, int>();
114 
115  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
116  long id;
117  float x_tmp, y_tmp;
118  _tracker.getFeature((int)i, id, x_tmp, y_tmp);
119 
120  bool add = false;
121 
122  if (useScanLine) {
123  if ((unsigned int)y_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getHeight() &&
124  (unsigned int)x_tmp < hiddenface->getMbScanLineRenderer().getPrimitiveIDs().getWidth()) {
125  for (unsigned int kc = 0; kc < listIndicesCylinderBBox.size(); kc++)
126  if (hiddenface->getMbScanLineRenderer().getPrimitiveIDs()[(unsigned int)y_tmp][(unsigned int)x_tmp] ==
128  add = true;
129  break;
130  }
131  }
132  }
133  else {
134  std::vector<vpImagePoint> roi;
135  for (unsigned int kc = 0; kc < listIndicesCylinderBBox.size(); kc++) {
136  hiddenface->getPolygon()[(size_t)listIndicesCylinderBBox[kc]]->getRoiClipped(cam, roi);
137  if (vpPolygon::isInside(roi, y_tmp, x_tmp)) {
138  add = true;
139  break;
140  }
141  roi.clear();
142  }
143  }
144 
145  if (add) {
146 
147  double xm = 0, ym = 0;
148  vpPixelMeterConversion::convertPoint(cam, x_tmp, y_tmp, xm, ym);
149  double Z = computeZ(xm, ym);
150  if (!vpMath::isNaN(Z)) {
151 #ifdef TARGET_OS_IPHONE
152  initPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
153  curPoints[(int)id] = vpImagePoint(y_tmp, x_tmp);
154  curPointsInd[(int)id] = (int)i;
155 #else
156  initPoints[id] = vpImagePoint(y_tmp, x_tmp);
157  curPoints[id] = vpImagePoint(y_tmp, x_tmp);
158  curPointsInd[id] = (int)i;
159 #endif
160  nbPointsInit++;
161  nbPointsCur++;
162 
163  vpPoint p;
164  p.setWorldCoordinates(xm * Z, ym * Z, Z);
165 #ifdef TARGET_OS_IPHONE
166  initPoints3D[(int)id] = p;
167 #else
168  initPoints3D[id] = p;
169 #endif
170  // std::cout << "Computed Z for : " << xm << "," << ym << " : " <<
171  // computeZ(xm,ym) << std::endl;
172  }
173  }
174  }
175 
176  if (nbPointsCur >= minNbPoint)
177  enoughPoints = true;
178  else
179  enoughPoints = false;
180 
181  // std::cout << "Nb detected points in cylinder : " << nbPointsCur <<
182  // std::endl;
183 }
184 
194 {
195  long id;
196  float x, y;
197  nbPointsCur = 0;
198  curPoints = std::map<int, vpImagePoint>();
199  curPointsInd = std::map<int, int>();
200 
201  for (unsigned int i = 0; i < static_cast<unsigned int>(_tracker.getNbFeatures()); i++) {
202  _tracker.getFeature((int)i, id, x, y);
203  if (isTrackedFeature((int)id)) {
204 #ifdef TARGET_OS_IPHONE
205  curPoints[(int)id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
206  curPointsInd[(int)id] = (int)i;
207 #else
208  curPoints[id] = vpImagePoint(static_cast<double>(y), static_cast<double>(x));
209  curPointsInd[id] = (int)i;
210 #endif
211  nbPointsCur++;
212  }
213  }
214 
215  if (nbPointsCur >= minNbPoint)
216  enoughPoints = true;
217  else
218  enoughPoints = false;
219 
220  return nbPointsCur;
221 }
222 
231 void vpMbtDistanceKltCylinder::removeOutliers(const vpColVector &_w, const double &threshold_outlier)
232 {
233  std::map<int, vpImagePoint> tmp;
234  std::map<int, int> tmp2;
235  unsigned int nbSupp = 0;
236  unsigned int k = 0;
237 
238  nbPointsCur = 0;
239  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
240  for (; iter != curPoints.end(); ++iter) {
241  if (_w[k] > threshold_outlier && _w[k + 1] > threshold_outlier) {
242  // if(_w[k] > threshold_outlier || _w[k+1] > threshold_outlier){
243  tmp[iter->first] = vpImagePoint(iter->second.get_i(), iter->second.get_j());
244  tmp2[iter->first] = curPointsInd[iter->first];
245  nbPointsCur++;
246  }
247  else {
248  nbSupp++;
249  initPoints.erase(iter->first);
250  }
251 
252  k += 2;
253  }
254 
255  if (nbSupp != 0) {
256  curPoints = std::map<int, vpImagePoint>();
257  curPointsInd = std::map<int, int>();
258 
259  curPoints = tmp;
260  curPointsInd = tmp2;
261  if (nbPointsCur >= minNbPoint)
262  enoughPoints = true;
263  else
264  enoughPoints = false;
265  }
266 }
267 
280  vpMatrix &_J)
281 {
282  unsigned int index_ = 0;
283 
284  cylinder.changeFrame(_cMc0 * c0Mo);
285 
286  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
287  for (; iter != curPoints.end(); ++iter) {
288  int id(iter->first);
289  double i_cur(iter->second.get_i()), j_cur(iter->second.get_j());
290 
291  double x_cur(0), y_cur(0);
292  vpPixelMeterConversion::convertPoint(cam, j_cur, i_cur, x_cur, y_cur);
293 
294  vpPoint p0 = initPoints3D[id];
295  p0.changeFrame(_cMc0);
296  p0.project();
297 
298  double x0_transform(p0.get_x()), y0_transform(p0.get_y());
299 
300  double Z = computeZ(x_cur, y_cur);
301 
302  if (vpMath::isNaN(Z) || Z < std::numeric_limits<double>::epsilon()) {
303  // std::cout << "Z is Nan : " << A << " , " << B << " , " << C << "
304  // | " << Z << " | " << x_cur << " , " << y_cur << std::endl;
305  // std::cout << std::sqrt(B*B - A*C) << " , " << B*B - A*C <<
306  // std::endl;
307 
308  _J[2 * index_][0] = 0;
309  _J[2 * index_][1] = 0;
310  _J[2 * index_][2] = 0;
311  _J[2 * index_][3] = 0;
312  _J[2 * index_][4] = 0;
313  _J[2 * index_][5] = 0;
314 
315  _J[2 * index_ + 1][0] = 0;
316  _J[2 * index_ + 1][1] = 0;
317  _J[2 * index_ + 1][2] = 0;
318  _J[2 * index_ + 1][3] = 0;
319  _J[2 * index_ + 1][4] = 0;
320  _J[2 * index_ + 1][5] = 0;
321 
322  _R[2 * index_] = (x0_transform - x_cur);
323  _R[2 * index_ + 1] = (y0_transform - y_cur);
324  index_++;
325  }
326  else {
327  double invZ = 1.0 / Z;
328 
329  _J[2 * index_][0] = -invZ;
330  _J[2 * index_][1] = 0;
331  _J[2 * index_][2] = x_cur * invZ;
332  _J[2 * index_][3] = x_cur * y_cur;
333  _J[2 * index_][4] = -(1 + x_cur * x_cur);
334  _J[2 * index_][5] = y_cur;
335 
336  _J[2 * index_ + 1][0] = 0;
337  _J[2 * index_ + 1][1] = -invZ;
338  _J[2 * index_ + 1][2] = y_cur * invZ;
339  _J[2 * index_ + 1][3] = (1 + y_cur * y_cur);
340  _J[2 * index_ + 1][4] = -y_cur * x_cur;
341  _J[2 * index_ + 1][5] = -x_cur;
342 
343  _R[2 * index_] = (x0_transform - x_cur);
344  _R[2 * index_ + 1] = (y0_transform - y_cur);
345  index_++;
346  }
347  }
348 }
349 
357 bool vpMbtDistanceKltCylinder::isTrackedFeature(int _id)
358 {
359  std::map<int, vpImagePoint>::iterator iter = initPoints.find(_id);
360  if (iter != initPoints.end())
361  return true;
362 
363  return false;
364 }
365 
376  cv::Mat &mask,
377  unsigned char nb, unsigned int shiftBorder)
378 {
379  int width = mask.cols;
380  int height = mask.rows;
381 
382  for (unsigned int kc = 0; kc < listIndicesCylinderBBox.size(); kc++) {
383  if ((*hiddenface)[(unsigned int)listIndicesCylinderBBox[kc]]->isVisible() &&
384  (*hiddenface)[(unsigned int)listIndicesCylinderBBox[kc]]->getNbPoint() > 2) {
385  int i_min, i_max, j_min, j_max;
386  std::vector<vpImagePoint> roi;
387  (*hiddenface)[(unsigned int)listIndicesCylinderBBox[kc]]->getRoiClipped(cam, roi);
388 
389  double shiftBorder_d = (double)shiftBorder;
390 #if defined(VISP_HAVE_CLIPPER)
391  std::vector<vpImagePoint> roi_offset;
392 
393  ClipperLib::Path path;
394  for (std::vector<vpImagePoint>::const_iterator it = roi.begin(); it != roi.end(); ++it) {
395  path.push_back(ClipperLib::IntPoint((ClipperLib::cInt)it->get_u(), (ClipperLib::cInt)it->get_v()));
396  }
397 
398  ClipperLib::Paths solution;
399  ClipperLib::ClipperOffset co;
400  co.AddPath(path, ClipperLib::jtRound, ClipperLib::etClosedPolygon);
401  co.Execute(solution, -shiftBorder_d);
402 
403  // Keep biggest polygon by area
404  if (!solution.empty()) {
405  size_t index_max = 0;
406 
407  if (solution.size() > 1) {
408  double max_area = 0;
409  vpPolygon polygon_area;
410 
411  for (size_t i = 0; i < solution.size(); i++) {
412  std::vector<vpImagePoint> corners;
413 
414  for (size_t j = 0; j < solution[i].size(); j++) {
415  corners.push_back(vpImagePoint((double)(solution[i][j].Y), (double)(solution[i][j].X)));
416  }
417 
418  polygon_area.buildFrom(corners);
419  if (polygon_area.getArea() > max_area) {
420  max_area = polygon_area.getArea();
421  index_max = i;
422  }
423  }
424  }
425 
426  for (size_t i = 0; i < solution[index_max].size(); i++) {
427  roi_offset.push_back(vpImagePoint((double)(solution[index_max][i].Y), (double)(solution[index_max][i].X)));
428  }
429  }
430  else {
431  roi_offset = roi;
432  }
433 
434  vpPolygon polygon_test(roi_offset);
435  vpImagePoint imPt;
436 #endif
437 
438 #if defined(VISP_HAVE_CLIPPER)
439  vpPolygon3D::getMinMaxRoi(roi_offset, i_min, i_max, j_min, j_max);
440 #else
441  vpPolygon3D::getMinMaxRoi(roi, i_min, i_max, j_min, j_max);
442 #endif
443 
444  /* check image boundaries */
445  if (i_min > height) { // underflow
446  i_min = 0;
447  }
448  if (i_max > height) {
449  i_max = height;
450  }
451  if (j_min > width) { // underflow
452  j_min = 0;
453  }
454  if (j_max > width) {
455  j_max = width;
456  }
457 
458  for (int i = i_min; i < i_max; i++) {
459  double i_d = (double)i;
460 
461  for (int j = j_min; j < j_max; j++) {
462  double j_d = (double)j;
463 
464 #if defined(VISP_HAVE_CLIPPER)
465  imPt.set_ij(i_d, j_d);
466  if (polygon_test.isInside(imPt)) {
467  mask.ptr<uchar>(i)[j] = nb;
468  }
469 #else
470  if (shiftBorder != 0) {
471  if (vpPolygon::isInside(roi, i_d, j_d) &&
472  vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d + shiftBorder_d) &&
473  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d + shiftBorder_d) &&
474  vpPolygon::isInside(roi, i_d + shiftBorder_d, j_d - shiftBorder_d) &&
475  vpPolygon::isInside(roi, i_d - shiftBorder_d, j_d - shiftBorder_d)) {
476  mask.at<unsigned char>(i, j) = nb;
477  }
478  }
479  else {
480  if (vpPolygon::isInside(roi, i, j)) {
481  mask.at<unsigned char>(i, j) = nb;
482  }
483  }
484 #endif
485  }
486  }
487  }
488  }
489 }
490 
497 {
498  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
499  for (; iter != curPoints.end(); ++iter) {
500  int id(iter->first);
501  vpImagePoint iP;
502  iP.set_i(static_cast<double>(iter->second.get_i()));
503  iP.set_j(static_cast<double>(iter->second.get_j()));
504 
506 
507  iP.set_i(vpMath::round(iP.get_i() + 7));
508  iP.set_j(vpMath::round(iP.get_j() + 7));
509  std::stringstream ss;
510  ss << id;
511  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
512  }
513 }
514 
521 {
522  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
523  for (; iter != curPoints.end(); ++iter) {
524  int id(iter->first);
525  vpImagePoint iP;
526  iP.set_i(static_cast<double>(iter->second.get_i()));
527  iP.set_j(static_cast<double>(iter->second.get_j()));
528 
530 
531  iP.set_i(vpMath::round(iP.get_i() + 7));
532  iP.set_j(vpMath::round(iP.get_j() + 7));
533  std::stringstream ss;
534  ss << id;
535  vpDisplay::displayText(_I, iP, ss.str(), vpColor::red);
536  }
537 }
538 
540  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
541  const bool /*displayFullModel*/)
542 {
543  std::vector<std::vector<double> > models = getModelForDisplay(cMo, camera);
544 
545  for (size_t i = 0; i < models.size(); i++) {
546  vpImagePoint ip1(models[i][1], models[i][2]);
547  vpImagePoint ip2(models[i][3], models[i][4]);
548  vpDisplay::displayLine(I, ip1, ip2, col, thickness);
549  }
550 }
551 
553  const vpCameraParameters &camera, const vpColor &col, unsigned int thickness,
554  const bool /*displayFullModel*/)
555 {
556  std::vector<std::vector<double> > models = getModelForDisplay(cMo, camera);
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 
571 std::vector<std::vector<double> > vpMbtDistanceKltCylinder::getFeaturesForDisplay()
572 {
573  std::vector<std::vector<double> > features;
574 
575  std::map<int, vpImagePoint>::const_iterator iter = curPoints.begin();
576  for (; iter != curPoints.end(); ++iter) {
577  int id(iter->first);
578  vpImagePoint iP;
579  iP.set_i(static_cast<double>(iter->second.get_i()));
580  iP.set_j(static_cast<double>(iter->second.get_j()));
581 
582  vpImagePoint iP2;
583  iP2.set_i(vpMath::round(iP.get_i() + 7));
584  iP2.set_j(vpMath::round(iP.get_j() + 7));
585 
586  std::vector<double> params = { 1, // KLT
587  iP.get_i(), iP.get_j(), iP2.get_i(), iP2.get_j(), static_cast<double>(id) };
588 
589  features.push_back(params);
590  }
591 
592  return features;
593 }
594 
603 std::vector<std::vector<double> > vpMbtDistanceKltCylinder::getModelForDisplay(const vpHomogeneousMatrix &cMo,
604  const vpCameraParameters &camera)
605 {
606  std::vector<std::vector<double> > models;
607 
608  // if(isvisible || displayFullModel)
609  {
610  // Perspective projection
611  circle1.changeFrame(cMo);
612  circle2.changeFrame(cMo);
613  cylinder.changeFrame(cMo);
614 
615  try {
616  circle1.projection();
617  }
618  catch (...) {
619  std::cout << "Problem projection circle 1";
620  }
621  try {
622  circle2.projection();
623  }
624  catch (...) {
625  std::cout << "Problem projection circle 2";
626  }
627 
628  cylinder.projection();
629 
630  double rho1, theta1;
631  double rho2, theta2;
632 
633  // Meters to pixels conversion
634  vpMeterPixelConversion::convertLine(camera, cylinder.getRho1(), cylinder.getTheta1(), rho1, theta1);
635  vpMeterPixelConversion::convertLine(camera, cylinder.getRho2(), cylinder.getTheta2(), rho2, theta2);
636 
637  // Determine intersections between circles and limbos
638  double i11, i12, i21, i22, j11, j12, j21, j22;
639 
640  vpCircle::computeIntersectionPoint(circle1, camera, rho1, theta1, i11, j11);
641  vpCircle::computeIntersectionPoint(circle2, camera, rho1, theta1, i12, j12);
642 
643  vpCircle::computeIntersectionPoint(circle1, camera, rho2, theta2, i21, j21);
644  vpCircle::computeIntersectionPoint(circle2, camera, rho2, theta2, i22, j22);
645 
646  // Create the image points
647  vpImagePoint ip11, ip12, ip21, ip22;
648  ip11.set_ij(i11, j11);
649  ip12.set_ij(i12, j12);
650  ip21.set_ij(i21, j21);
651  ip22.set_ij(i22, j22);
652 
653  std::vector<double> params1 = { 0, // line parameters
654  ip11.get_i(), ip11.get_j(), ip12.get_i(), ip12.get_j() };
655  models.push_back(params1);
656 
657  std::vector<double> params2 = { 0, // line parameters
658  ip21.get_i(), ip21.get_j(), ip22.get_i(), ip22.get_j() };
659 
660  models.push_back(params1);
661  models.push_back(params2);
662  }
663 
664  return models;
665 }
666 
667 // ######################
668 // Private Functions
669 // ######################
670 
671 double vpMbtDistanceKltCylinder::computeZ(const double &x, const double &y)
672 {
673  // double A = x*x + y*y + 1 -
674  // ((cylinder.getA()*x+cylinder.getB()*y+cylinder.getC()) *
675  // (cylinder.getA()*x+cylinder.getB()*y+cylinder.getC())); double B = (x *
676  // cylinder.getX() + y * cylinder.getY() + cylinder.getZ()); double C =
677  // cylinder.getX() * cylinder.getX() + cylinder.getY() * cylinder.getY() +
678  // cylinder.getZ() * cylinder.getZ() - cylinder.getR() * cylinder.getR();
679  //
680  // return (B - std::sqrt(B*B - A*C))/A;
681 
682  return cylinder.computeZ(x, y);
683 }
684 #elif !defined(VISP_BUILD_SHARED_LIBS)
685 // Work around to avoid warning:
686 // libvisp_mbt.a(vpMbtDistanceKltCylinder.cpp.o) has no symbols
687 void dummy_vpMbtDistanceKltCylinder() { };
688 #endif
Generic class defining intrinsic camera parameters.
void projection() vp_override
Definition: vpCircle.cpp:137
void setWorldCoordinates(const vpColVector &oP) vp_override
Definition: vpCircle.cpp:57
void changeFrame(const vpHomogeneousMatrix &noMo, vpColVector &noP) const vp_override
Definition: vpCircle.cpp:249
static void computeIntersectionPoint(const vpCircle &circle, const vpCameraParameters &cam, const double &rho, const double &theta, double &i, double &j)
Definition: vpCircle.cpp:399
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
static const vpColor red
Definition: vpColor.h:211
double getRho1() const
Definition: vpCylinder.h:132
void setWorldCoordinates(const vpColVector &oP) vp_override
Definition: vpCylinder.cpp:62
double getTheta1() const
Definition: vpCylinder.h:138
double computeZ(double x, double y) const
Definition: vpCylinder.cpp:336
double getTheta2() const
Definition: vpCylinder.h:151
double getRho2() const
Definition: vpCylinder.h:145
void projection() vp_override
Definition: vpCylinder.cpp:146
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const vp_override
Definition: vpCylinder.cpp:241
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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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:304
double get_j() const
Definition: vpImagePoint.h:125
void set_ij(double ii, double jj)
Definition: vpImagePoint.h:315
void set_i(double ii)
Definition: vpImagePoint.h:293
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 bool isNaN(double value)
Definition: vpMath.cpp:93
static int round(double x)
Definition: vpMath.h:403
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
vpMbScanLine & getMbScanLineRenderer()
std::vector< PolygonType * > & getPolygon()
void buildFrom(const vpPoint &p1, const vpPoint &p2, const double &r)
void removeOutliers(const vpColVector &weight, const double &threshold_outlier)
unsigned int computeNbDetectedCurrent(const vpKltOpencv &_tracker)
std::vector< std::vector< double > > getFeaturesForDisplay()
void computeInteractionMatrixAndResidu(const vpHomogeneousMatrix &cMc0, vpColVector &_R, vpMatrix &_J)
bool useScanLine
Use scanline rendering.
void updateMask(cv::Mat &mask, unsigned char _nb=255, unsigned int _shiftBorder=0)
void init(const vpKltOpencv &_tracker, const vpHomogeneousMatrix &cMo)
std::vector< std::vector< double > > getModelForDisplay(const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam)
void displayPrimitive(const vpImage< unsigned char > &_I)
std::vector< int > listIndicesCylinderBBox
Pointer to the polygon that define a face.
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, unsigned int thickness=1, bool displayFullModel=false)
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
static void convertLine(const vpCameraParameters &cam, const double &rho_m, const double &theta_m, double &rho_p, double &theta_p)
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Definition: vpPoint.h:77
double get_oX() const
Get the point oX coordinate in the object frame.
Definition: vpPoint.cpp:454
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.cpp:465
double get_oZ() const
Get the point oZ coordinate in the object frame.
Definition: vpPoint.cpp:458
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.cpp:463
double get_oY() const
Get the point oY coordinate in the object frame.
Definition: vpPoint.cpp:456
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &cP) const vp_override
Definition: vpPoint.cpp:242
void setWorldCoordinates(double oX, double oY, double oZ)
Definition: vpPoint.cpp:110
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:97
double getArea() const
Definition: vpPolygon.h:155
void buildFrom(const std::vector< vpImagePoint > &corners, const bool create_convex_hull=false)
Definition: vpPolygon.cpp:190
bool isInside(const vpImagePoint &iP, const PointInPolygonMethod &method=PnPolyRayCasting) const
Definition: vpPolygon.cpp:394