Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpMbtFaceDepthNormal.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  * Manage depth normal features for a particular face.
33  *
34  *****************************************************************************/
35 
36 #include <visp3/core/vpCPUFeatures.h>
37 #include <visp3/mbt/vpMbtFaceDepthNormal.h>
38 #include <visp3/mbt/vpMbtTukeyEstimator.h>
39 
40 #ifdef VISP_HAVE_PCL
41 #include <pcl/common/centroid.h>
42 #include <pcl/filters/extract_indices.h>
43 #include <pcl/segmentation/sac_segmentation.h>
44 #endif
45 
46 #if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
47 #include <emmintrin.h>
48 #define VISP_HAVE_SSE2 1
49 #endif
50 
51 #define USE_SSE_CODE 1
52 #if VISP_HAVE_SSE2 && USE_SSE_CODE
53 #define USE_SSE 1
54 #else
55 #define USE_SSE 0
56 #endif
57 
59  : m_cam(), m_clippingFlag(vpPolygon3D::NO_CLIPPING), m_distFarClip(100), m_distNearClip(0.001), m_hiddenFace(NULL),
60  m_planeObject(), m_polygon(NULL), m_useScanLine(false), m_faceActivated(false),
61  m_faceCentroidMethod(GEOMETRIC_CENTROID), m_faceDesiredCentroid(), m_faceDesiredNormal(),
62  m_featureEstimationMethod(ROBUST_FEATURE_ESTIMATION), m_isTrackedDepthNormalFace(true), m_isVisible(false),
63  m_listOfFaceLines(), m_planeCamera(),
64  m_pclPlaneEstimationMethod(2), // SAC_MSAC, see pcl/sample_consensus/method_types.h
65  m_pclPlaneEstimationRansacMaxIter(200), m_pclPlaneEstimationRansacThreshold(0.001), m_polygonLines()
66 {
67 }
68 
70 {
71  for (size_t i = 0; i < m_listOfFaceLines.size(); i++) {
72  delete m_listOfFaceLines[i];
73  }
74 }
75 
90  std::string name)
91 {
92  // Build a PolygonLine to be able to easily display the lines model
93  PolygonLine polygon_line;
94 
95  // Add polygon
96  polygon_line.m_poly.setNbPoint(2);
97  polygon_line.m_poly.addPoint(0, P1);
98  polygon_line.m_poly.addPoint(1, P2);
99 
100  polygon_line.m_poly.setClipping(m_clippingFlag);
101  polygon_line.m_poly.setNearClippingDistance(m_distNearClip);
102  polygon_line.m_poly.setFarClippingDistance(m_distFarClip);
103 
104  polygon_line.m_p1 = &polygon_line.m_poly.p[0];
105  polygon_line.m_p2 = &polygon_line.m_poly.p[1];
106 
107  m_polygonLines.push_back(polygon_line);
108 
109  // suppress line already in the model
110  bool already_here = false;
112 
113  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
114  ++it) {
115  l = *it;
116  if ((samePoint(*(l->p1), P1) && samePoint(*(l->p2), P2)) || (samePoint(*(l->p1), P2) && samePoint(*(l->p2), P1))) {
117  already_here = true;
118  l->addPolygon(polygon);
119  l->hiddenface = faces;
121  }
122  }
123 
124  if (!already_here) {
125  l = new vpMbtDistanceLine;
126 
128  l->buildFrom(P1, P2);
129  l->addPolygon(polygon);
130  l->hiddenface = faces;
132 
133  l->setIndex((unsigned int)m_listOfFaceLines.size());
134  l->setName(name);
135 
138 
139  if ((m_clippingFlag & vpPolygon3D::NEAR_CLIPPING) == vpPolygon3D::NEAR_CLIPPING)
141 
142  if ((m_clippingFlag & vpPolygon3D::FAR_CLIPPING) == vpPolygon3D::FAR_CLIPPING)
144 
145  m_listOfFaceLines.push_back(l);
146  }
147 }
148 
149 #ifdef VISP_HAVE_PCL
150 bool vpMbtFaceDepthNormal::computeDesiredFeatures(const vpHomogeneousMatrix &cMo, const unsigned int width,
151  const unsigned int height,
152  const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud,
153  vpColVector &desired_features, const unsigned int stepX,
154  const unsigned int stepY
155 #if DEBUG_DISPLAY_DEPTH_NORMAL
156  ,
157  vpImage<unsigned char> &debugImage,
158  std::vector<std::vector<vpImagePoint> > &roiPts_vec
159 #endif
160  , const vpImage<bool> *mask
161 )
162 {
163  m_faceActivated = false;
164 
165  if (width == 0 || height == 0)
166  return false;
167 
168  std::vector<vpImagePoint> roiPts;
169  vpColVector desired_normal(3);
170 
171  computeROI(cMo, width, height, roiPts
172 #if DEBUG_DISPLAY_DEPTH_NORMAL
173  ,
174  roiPts_vec
175 #endif
176  );
177 
178  if (roiPts.size() <= 2) {
179 #ifndef NDEBUG
180  std::cerr << "Error: roiPts.size() <= 2 in computeDesiredFeatures" << std::endl;
181 #endif
182  return false;
183  }
184 
185  vpPolygon polygon_2d(roiPts);
186  vpRect bb = polygon_2d.getBoundingBox();
187 
188  unsigned int top = (unsigned int)std::max(0.0, bb.getTop());
189  unsigned int bottom = (unsigned int)std::min((double)height, std::max(0.0, bb.getBottom()));
190  unsigned int left = (unsigned int)std::max(0.0, bb.getLeft());
191  unsigned int right = (unsigned int)std::min((double)width, std::max(0.0, bb.getRight()));
192 
193  bb.setTop(top);
194  bb.setBottom(bottom);
195  bb.setLeft(left);
196  bb.setRight(right);
197 
198  // Keep only 3D points inside the projected polygon face
199  pcl::PointCloud<pcl::PointXYZ>::Ptr point_cloud_face(new pcl::PointCloud<pcl::PointXYZ>);
200  std::vector<double> point_cloud_face_vec, point_cloud_face_custom;
201 
203  point_cloud_face_custom.reserve((size_t)(3 * bb.getWidth() * bb.getHeight()));
204  point_cloud_face_vec.reserve((size_t)(3 * bb.getWidth() * bb.getHeight()));
206  point_cloud_face_vec.reserve((size_t)(3 * bb.getWidth() * bb.getHeight()));
208  point_cloud_face->reserve((size_t)(bb.getWidth() * bb.getHeight()));
209  }
210 
211  bool checkSSE2 = vpCPUFeatures::checkSSE2();
212 #if !USE_SSE
213  checkSSE2 = false;
214 #else
215  bool push = false;
216  double prev_x, prev_y, prev_z;
217 #endif
218 
219  double x = 0.0, y = 0.0;
220  for (unsigned int i = top; i < bottom; i += stepY) {
221  for (unsigned int j = left; j < right; j += stepX) {
222  if (vpMeTracker::inMask(mask, i, j) && pcl::isFinite((*point_cloud)(j, i)) && (*point_cloud)(j, i).z > 0 &&
223  (m_useScanLine ? (i < m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs().getHeight() &&
224  j < m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs().getWidth() &&
225  m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs()[i][j] == m_polygon->getIndex())
226  : polygon_2d.isInside(vpImagePoint(i, j)))) {
227 
229  point_cloud_face->push_back((*point_cloud)(j, i));
232  point_cloud_face_vec.push_back((*point_cloud)(j, i).x);
233  point_cloud_face_vec.push_back((*point_cloud)(j, i).y);
234  point_cloud_face_vec.push_back((*point_cloud)(j, i).z);
235 
237  // Add point for custom method for plane equation estimation
239 
240  if (checkSSE2) {
241 #if USE_SSE
242  if (!push) {
243  push = true;
244  prev_x = x;
245  prev_y = y;
246  prev_z = (*point_cloud)(j, i).z;
247  } else {
248  push = false;
249  point_cloud_face_custom.push_back(prev_x);
250  point_cloud_face_custom.push_back(x);
251 
252  point_cloud_face_custom.push_back(prev_y);
253  point_cloud_face_custom.push_back(y);
254 
255  point_cloud_face_custom.push_back(prev_z);
256  point_cloud_face_custom.push_back((*point_cloud)(j, i).z);
257  }
258 #endif
259  } else {
260  point_cloud_face_custom.push_back(x);
261  point_cloud_face_custom.push_back(y);
262  point_cloud_face_custom.push_back((*point_cloud)(j, i).z);
263  }
264  }
265  }
266 
267 #if DEBUG_DISPLAY_DEPTH_NORMAL
268  debugImage[i][j] = 255;
269 #endif
270  }
271  }
272  }
273 
274 #if USE_SSE
275  if (checkSSE2 && push) {
276  point_cloud_face_custom.push_back(prev_x);
277  point_cloud_face_custom.push_back(prev_y);
278  point_cloud_face_custom.push_back(prev_z);
279  }
280 #endif
281 
282  if (point_cloud_face->empty() && point_cloud_face_custom.empty() && point_cloud_face_vec.empty()) {
283  return false;
284  }
285 
286  // Face centroid computed by the different methods
287  vpColVector centroid_point(3);
288 
290  if (!computeDesiredFeaturesPCL(point_cloud_face, desired_features, desired_normal, centroid_point)) {
291  return false;
292  }
294  computeDesiredFeaturesSVD(point_cloud_face_vec, cMo, desired_features, desired_normal, centroid_point);
296  computeDesiredFeaturesRobustFeatures(point_cloud_face_custom, point_cloud_face_vec, cMo, desired_features,
297  desired_normal, centroid_point);
298  } else {
299  throw vpException(vpException::badValue, "Unknown feature estimation method!");
300  }
301 
302  computeDesiredNormalAndCentroid(cMo, desired_normal, centroid_point);
303 
304  m_faceActivated = true;
305 
306  return true;
307 }
308 #endif
309 
310 bool vpMbtFaceDepthNormal::computeDesiredFeatures(const vpHomogeneousMatrix &cMo, const unsigned int width,
311  const unsigned int height,
312  const std::vector<vpColVector> &point_cloud,
313  vpColVector &desired_features, const unsigned int stepX,
314  const unsigned int stepY
315 #if DEBUG_DISPLAY_DEPTH_NORMAL
316  ,
317  vpImage<unsigned char> &debugImage,
318  std::vector<std::vector<vpImagePoint> > &roiPts_vec
319 #endif
320  , const vpImage<bool> *mask
321 )
322 {
323  m_faceActivated = false;
324 
325  if (width == 0 || height == 0)
326  return false;
327 
328  std::vector<vpImagePoint> roiPts;
329  vpColVector desired_normal(3);
330 
331  computeROI(cMo, width, height, roiPts
332 #if DEBUG_DISPLAY_DEPTH_NORMAL
333  ,
334  roiPts_vec
335 #endif
336  );
337 
338  if (roiPts.size() <= 2) {
339 #ifndef NDEBUG
340  std::cerr << "Error: roiPts.size() <= 2 in computeDesiredFeatures" << std::endl;
341 #endif
342  return false;
343  }
344 
345  vpPolygon polygon_2d(roiPts);
346  vpRect bb = polygon_2d.getBoundingBox();
347 
348  unsigned int top = (unsigned int)std::max(0.0, bb.getTop());
349  unsigned int bottom = (unsigned int)std::min((double)height, std::max(0.0, bb.getBottom()));
350  unsigned int left = (unsigned int)std::max(0.0, bb.getLeft());
351  unsigned int right = (unsigned int)std::min((double)width, std::max(0.0, bb.getRight()));
352 
353  bb.setTop(top);
354  bb.setBottom(bottom);
355  bb.setLeft(left);
356  bb.setRight(right);
357 
358  // Keep only 3D points inside the projected polygon face
359  std::vector<double> point_cloud_face, point_cloud_face_custom;
360 
361  point_cloud_face.reserve((size_t)(3 * bb.getWidth() * bb.getHeight()));
363  point_cloud_face_custom.reserve((size_t)(3 * bb.getWidth() * bb.getHeight()));
364  }
365 
366  bool checkSSE2 = vpCPUFeatures::checkSSE2();
367 #if !USE_SSE
368  checkSSE2 = false;
369 #else
370  bool push = false;
371  double prev_x, prev_y, prev_z;
372 #endif
373 
374  double x = 0.0, y = 0.0;
375  for (unsigned int i = top; i < bottom; i += stepY) {
376  for (unsigned int j = left; j < right; j += stepX) {
377  if (vpMeTracker::inMask(mask, i, j) && point_cloud[i * width + j][2] > 0 &&
378  (m_useScanLine ? (i < m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs().getHeight() &&
379  j < m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs().getWidth() &&
380  m_hiddenFace->getMbScanLineRenderer().getPrimitiveIDs()[i][j] == m_polygon->getIndex())
381  : polygon_2d.isInside(vpImagePoint(i, j)))) {
382  // Add point
383  point_cloud_face.push_back(point_cloud[i * width + j][0]);
384  point_cloud_face.push_back(point_cloud[i * width + j][1]);
385  point_cloud_face.push_back(point_cloud[i * width + j][2]);
386 
388  // Add point for custom method for plane equation estimation
390 
391  if (checkSSE2) {
392 #if USE_SSE
393  if (!push) {
394  push = true;
395  prev_x = x;
396  prev_y = y;
397  prev_z = point_cloud[i * width + j][2];
398  } else {
399  push = false;
400  point_cloud_face_custom.push_back(prev_x);
401  point_cloud_face_custom.push_back(x);
402 
403  point_cloud_face_custom.push_back(prev_y);
404  point_cloud_face_custom.push_back(y);
405 
406  point_cloud_face_custom.push_back(prev_z);
407  point_cloud_face_custom.push_back(point_cloud[i * width + j][2]);
408  }
409 #endif
410  } else {
411  point_cloud_face_custom.push_back(x);
412  point_cloud_face_custom.push_back(y);
413  point_cloud_face_custom.push_back(point_cloud[i * width + j][2]);
414  }
415  }
416 
417 #if DEBUG_DISPLAY_DEPTH_NORMAL
418  debugImage[i][j] = 255;
419 #endif
420  }
421  }
422  }
423 
424 #if USE_SSE
425  if (checkSSE2 && push) {
426  point_cloud_face_custom.push_back(prev_x);
427  point_cloud_face_custom.push_back(prev_y);
428  point_cloud_face_custom.push_back(prev_z);
429  }
430 #endif
431 
432  if (point_cloud_face.empty() && point_cloud_face_custom.empty()) {
433  return false;
434  }
435 
436  // Face centroid computed by the different methods
437  vpColVector centroid_point(3);
438 
439 #ifdef VISP_HAVE_PCL
441  pcl::PointCloud<pcl::PointXYZ>::Ptr point_cloud_face_pcl(new pcl::PointCloud<pcl::PointXYZ>);
442  point_cloud_face_pcl->reserve(point_cloud_face.size() / 3);
443 
444  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
445  point_cloud_face_pcl->push_back(
446  pcl::PointXYZ(point_cloud_face[3 * i], point_cloud_face[3 * i + 1], point_cloud_face[3 * i + 2]));
447  }
448 
449  computeDesiredFeaturesPCL(point_cloud_face_pcl, desired_features, desired_normal, centroid_point);
450  } else
451 #endif
453  computeDesiredFeaturesSVD(point_cloud_face, cMo, desired_features, desired_normal, centroid_point);
455  computeDesiredFeaturesRobustFeatures(point_cloud_face_custom, point_cloud_face, cMo, desired_features,
456  desired_normal, centroid_point);
457  } else {
458  throw vpException(vpException::badValue, "Unknown feature estimation method!");
459  }
460 
461  computeDesiredNormalAndCentroid(cMo, desired_normal, centroid_point);
462 
463  m_faceActivated = true;
464 
465  return true;
466 }
467 
468 #ifdef VISP_HAVE_PCL
469 bool vpMbtFaceDepthNormal::computeDesiredFeaturesPCL(const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &point_cloud_face,
470  vpColVector &desired_features, vpColVector &desired_normal,
471  vpColVector &centroid_point)
472 {
473  try {
474  // Compute plane equation for this subset of point cloud
475  pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients);
476  pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
477  // Create the segmentation object
478  pcl::SACSegmentation<pcl::PointXYZ> seg;
479  // Optional
480  seg.setOptimizeCoefficients(true);
481  // Mandatory
482  seg.setModelType(pcl::SACMODEL_PLANE);
483  seg.setMethodType(m_pclPlaneEstimationMethod);
484  seg.setDistanceThreshold(m_pclPlaneEstimationRansacThreshold);
485  seg.setMaxIterations(m_pclPlaneEstimationRansacMaxIter);
486 
487  seg.setInputCloud(point_cloud_face);
488  seg.segment(*inliers, *coefficients);
489 
490  pcl::PointCloud<pcl::PointXYZ>::Ptr point_cloud_face_extracted(new pcl::PointCloud<pcl::PointXYZ>);
491  // Create the filtering object
492  pcl::ExtractIndices<pcl::PointXYZ> extract;
493 
494  // Extract the inliers
495  extract.setInputCloud(point_cloud_face);
496  extract.setIndices(inliers);
497  extract.setNegative(false);
498  extract.filter(*point_cloud_face_extracted);
499 
500  pcl::PointXYZ centroid_point_pcl;
501  if (pcl::computeCentroid(*point_cloud_face_extracted, centroid_point_pcl)) {
502  pcl::PointXYZ face_normal;
503  computeNormalVisibility(coefficients->values[0], coefficients->values[1], coefficients->values[2],
504  centroid_point_pcl, face_normal);
505 
506  desired_features.resize(3, false);
507  desired_features[0] = -coefficients->values[0] / coefficients->values[3];
508  desired_features[1] = -coefficients->values[1] / coefficients->values[3];
509  desired_features[2] = -coefficients->values[2] / coefficients->values[3];
510 
511  desired_normal[0] = face_normal.x;
512  desired_normal[1] = face_normal.y;
513  desired_normal[2] = face_normal.z;
514 
515  centroid_point[0] = centroid_point_pcl.x;
516  centroid_point[1] = centroid_point_pcl.y;
517  centroid_point[2] = centroid_point_pcl.z;
518  } else {
519  std::cerr << "Cannot compute centroid!" << std::endl;
520  return false;
521  }
522  } catch (const pcl::PCLException &e) {
523  std::cerr << "Catch a PCL exception: " << e.what() << std::endl;
524  throw;
525  }
526 
527  return true;
528 }
529 #endif
530 
531 void vpMbtFaceDepthNormal::computeDesiredFeaturesRobustFeatures(const std::vector<double> &point_cloud_face_custom,
532  const std::vector<double> &point_cloud_face,
533  const vpHomogeneousMatrix &cMo,
534  vpColVector &desired_features,
535  vpColVector &desired_normal,
536  vpColVector &centroid_point)
537 {
538  std::vector<double> weights;
539  double den = 0.0;
540  estimateFeatures(point_cloud_face_custom, cMo, desired_features, weights);
541 
542  // Compute face centroid
543  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
544  centroid_point[0] += weights[i] * point_cloud_face[3 * i];
545  centroid_point[1] += weights[i] * point_cloud_face[3 * i + 1];
546  centroid_point[2] += weights[i] * point_cloud_face[3 * i + 2];
547 
548  den += weights[i];
549  }
550 
551  centroid_point[0] /= den;
552  centroid_point[1] /= den;
553  centroid_point[2] /= den;
554 
555  computeNormalVisibility(-desired_features[0], -desired_features[1], -desired_features[2], centroid_point,
556  desired_normal);
557 }
558 
559 void vpMbtFaceDepthNormal::computeDesiredFeaturesSVD(const std::vector<double> &point_cloud_face,
560  const vpHomogeneousMatrix &cMo, vpColVector &desired_features,
561  vpColVector &desired_normal, vpColVector &centroid_point)
562 {
563  vpColVector plane_equation_SVD;
564  estimatePlaneEquationSVD(point_cloud_face, cMo, plane_equation_SVD, centroid_point);
565 
566  desired_features.resize(3, false);
567  desired_features[0] = -plane_equation_SVD[0] / plane_equation_SVD[3];
568  desired_features[1] = -plane_equation_SVD[1] / plane_equation_SVD[3];
569  desired_features[2] = -plane_equation_SVD[2] / plane_equation_SVD[3];
570 
571  computeNormalVisibility(-desired_features[0], -desired_features[1], -desired_features[2], centroid_point,
572  desired_normal);
573 }
574 
576  const vpColVector &desired_normal,
577  const vpColVector &centroid_point)
578 {
579  // Compute desired centroid in the object frame
580  vpColVector centroid_cam(4);
581  centroid_cam[0] = centroid_point[0];
582  centroid_cam[1] = centroid_point[1];
583  centroid_cam[2] = centroid_point[2];
584  centroid_cam[3] = 1;
585 
586  vpColVector centroid_obj = cMo.inverse() * centroid_cam;
587  m_faceDesiredCentroid.setWorldCoordinates(centroid_obj[0], centroid_obj[1], centroid_obj[2]);
588 
589  // Compute desired face normal in the object frame
590  vpColVector face_normal_cam(4);
591  face_normal_cam[0] = desired_normal[0];
592  face_normal_cam[1] = desired_normal[1];
593  face_normal_cam[2] = desired_normal[2];
594  face_normal_cam[3] = 1;
595 
596  vpColVector face_normal_obj = cMo.inverse() * face_normal_cam;
597  m_faceDesiredNormal.setWorldCoordinates(face_normal_obj[0], face_normal_obj[1], face_normal_obj[2]);
598 }
599 
600 bool vpMbtFaceDepthNormal::computePolygonCentroid(const std::vector<vpPoint> &points_, vpPoint &centroid)
601 {
602  if (points_.empty()) {
603  return false;
604  }
605 
606  if (points_.size() < 2) {
607  centroid = points_[0];
608  return true;
609  }
610 
611  std::vector<vpPoint> points = points_;
612  points.push_back(points_.front());
613 
614  double A1 = 0.0, A2 = 0.0, c_x1 = 0.0, c_x2 = 0.0, c_y = 0.0, c_z = 0.0;
615 
616  for (size_t i = 0; i < points.size() - 1; i++) {
617  // projection onto xy plane
618  c_x1 += (points[i].get_X() + points[i + 1].get_X()) *
619  (points[i].get_X() * points[i + 1].get_Y() - points[i + 1].get_X() * points[i].get_Y());
620  c_y += (points[i].get_Y() + points[i + 1].get_Y()) *
621  (points[i].get_X() * points[i + 1].get_Y() - points[i + 1].get_X() * points[i].get_Y());
622  A1 += points[i].get_X() * points[i + 1].get_Y() - points[i + 1].get_X() * points[i].get_Y();
623 
624  // projection onto xz plane
625  c_x2 += (points[i].get_X() + points[i + 1].get_X()) *
626  (points[i].get_X() * points[i + 1].get_Z() - points[i + 1].get_X() * points[i].get_Z());
627  c_z += (points[i].get_Z() + points[i + 1].get_Z()) *
628  (points[i].get_X() * points[i + 1].get_Z() - points[i + 1].get_X() * points[i].get_Z());
629  A2 += points[i].get_X() * points[i + 1].get_Z() - points[i + 1].get_X() * points[i].get_Z();
630  }
631 
632  c_x1 /= 3.0 * A1;
633  c_y /= 3.0 * A1;
634  c_x2 /= 3.0 * A2;
635  c_z /= 3.0 * A2;
636 
637  if (A1 > A2) {
638  centroid.set_X(c_x1);
639  } else {
640  centroid.set_X(c_x2);
641  }
642 
643  centroid.set_Y(c_y);
644  centroid.set_Z(c_z);
645 
646  return true;
647 }
648 
649 void vpMbtFaceDepthNormal::computeROI(const vpHomogeneousMatrix &cMo, const unsigned int width,
650  const unsigned int height, std::vector<vpImagePoint> &roiPts
651 #if DEBUG_DISPLAY_DEPTH_NORMAL
652  ,
653  std::vector<std::vector<vpImagePoint> > &roiPts_vec
654 #endif
655 )
656 {
657  if (m_useScanLine || m_clippingFlag > 2)
658  m_cam.computeFov(width, height);
659 
660  if (m_useScanLine) {
661  for (std::vector<PolygonLine>::iterator it = m_polygonLines.begin(); it != m_polygonLines.end(); ++it) {
662  it->m_p1->changeFrame(cMo);
663  it->m_p2->changeFrame(cMo);
664 
665  vpImagePoint ip1, ip2;
666 
667  it->m_poly.changeFrame(cMo);
668  it->m_poly.computePolygonClipped(m_cam);
669 
670  if (it->m_poly.polyClipped.size() == 2 &&
671  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::NEAR_CLIPPING) == 0) &&
672  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::FAR_CLIPPING) == 0) &&
673  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::DOWN_CLIPPING) == 0) &&
674  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::UP_CLIPPING) == 0) &&
675  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::LEFT_CLIPPING) == 0) &&
676  ((it->m_poly.polyClipped[1].second & it->m_poly.polyClipped[0].second & vpPolygon3D::RIGHT_CLIPPING) == 0)) {
677 
678  std::vector<std::pair<vpPoint, vpPoint> > linesLst;
679  m_hiddenFace->computeScanLineQuery(it->m_poly.polyClipped[0].first, it->m_poly.polyClipped[1].first, linesLst,
680  true);
681 
682  for (unsigned int i = 0; i < linesLst.size(); i++) {
683  linesLst[i].first.project();
684  linesLst[i].second.project();
685 
686  vpMeterPixelConversion::convertPoint(m_cam, linesLst[i].first.get_x(), linesLst[i].first.get_y(), ip1);
687  vpMeterPixelConversion::convertPoint(m_cam, linesLst[i].second.get_x(), linesLst[i].second.get_y(), ip2);
688 
689  it->m_imPt1 = ip1;
690  it->m_imPt2 = ip2;
691 
692  roiPts.push_back(ip1);
693  roiPts.push_back(ip2);
694 
695 #if DEBUG_DISPLAY_DEPTH_NORMAL
696  std::vector<vpImagePoint> roiPts_;
697  roiPts_.push_back(ip1);
698  roiPts_.push_back(ip2);
699  roiPts_vec.push_back(roiPts_);
700 #endif
701  }
702  }
703  }
704  } else {
705  // Get polygon clipped
706  m_polygon->getRoiClipped(m_cam, roiPts, cMo);
707 
708 #if DEBUG_DISPLAY_DEPTH_NORMAL
709  roiPts_vec.push_back(roiPts);
710 #endif
711  }
712 }
713 
715 
717 {
718  // Compute lines visibility, only for display
719  vpMbtDistanceLine *line;
720  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
721  ++it) {
722  line = *it;
723  bool isvisible = false;
724 
725  for (std::list<int>::const_iterator itindex = line->Lindex_polygon.begin(); itindex != line->Lindex_polygon.end();
726  ++itindex) {
727  int index = *itindex;
728  if (index == -1) {
729  isvisible = true;
730  } else {
731  if (line->hiddenface->isVisible((unsigned int)index)) {
732  isvisible = true;
733  }
734  }
735  }
736 
737  // Si la ligne n'appartient a aucune face elle est tout le temps visible
738  if (line->Lindex_polygon.empty())
739  isvisible = true; // Not sure that this can occur
740 
741  if (isvisible) {
742  line->setVisible(true);
743  } else {
744  line->setVisible(false);
745  }
746  }
747 }
748 
749 void vpMbtFaceDepthNormal::computeNormalVisibility(const double nx, const double ny, const double nz,
750  const vpHomogeneousMatrix &cMo, const vpCameraParameters &camera,
751  vpColVector &correct_normal, vpPoint &centroid)
752 {
753  vpColVector faceNormal(3);
754  faceNormal[0] = nx;
755  faceNormal[1] = ny;
756  faceNormal[2] = nz;
757  faceNormal.normalize();
758 
759  // Get polygon clipped
760  std::vector<vpImagePoint> roiPts;
761  m_polygon->getRoiClipped(camera, roiPts, cMo);
762 
763  std::vector<vpPoint> polyPts;
764  m_polygon->getPolygonClipped(polyPts);
765 
766  vpColVector e4(3);
768  computePolygonCentroid(polyPts, centroid);
769  centroid.project();
770 
771  e4[0] = -centroid.get_X();
772  e4[1] = -centroid.get_Y();
773  e4[2] = -centroid.get_Z();
774  e4.normalize();
775  } else {
776  double centroid_x = 0.0;
777  double centroid_y = 0.0;
778  double centroid_z = 0.0;
779 
780  for (size_t i = 0; i < polyPts.size(); i++) {
781  centroid_x += polyPts[i].get_X();
782  centroid_y += polyPts[i].get_Y();
783  centroid_z += polyPts[i].get_Z();
784  }
785 
786  centroid_x /= polyPts.size();
787  centroid_y /= polyPts.size();
788  centroid_z /= polyPts.size();
789 
790  e4[0] = -centroid_x;
791  e4[1] = -centroid_y;
792  e4[2] = -centroid_z;
793  e4.normalize();
794 
795  centroid.set_X(centroid_x);
796  centroid.set_Y(centroid_y);
797  centroid.set_Z(centroid_z);
798  }
799 
800  correct_normal.resize(3, false);
801  double angle = acos(vpColVector::dotProd(e4, faceNormal));
802  if (angle < M_PI_2) {
803  correct_normal = faceNormal;
804  } else {
805  correct_normal[0] = -faceNormal[0];
806  correct_normal[1] = -faceNormal[1];
807  correct_normal[2] = -faceNormal[2];
808  }
809 }
810 
811 #ifdef VISP_HAVE_PCL
812 void vpMbtFaceDepthNormal::computeNormalVisibility(const float nx, const float ny, const float nz,
813  const pcl::PointXYZ &centroid_point, pcl::PointXYZ &face_normal)
814 {
815  vpColVector faceNormal(3);
816  faceNormal[0] = nx;
817  faceNormal[1] = ny;
818  faceNormal[2] = nz;
819  faceNormal.normalize();
820 
821  vpColVector e4(3);
822  e4[0] = -centroid_point.x;
823  e4[1] = -centroid_point.y;
824  e4[2] = -centroid_point.z;
825  e4.normalize();
826 
827  double angle = acos(vpColVector::dotProd(e4, faceNormal));
828  if (angle < M_PI_2) {
829  face_normal = pcl::PointXYZ(faceNormal[0], faceNormal[1], faceNormal[2]);
830  } else {
831  face_normal = pcl::PointXYZ(-faceNormal[0], -faceNormal[1], -faceNormal[2]);
832  }
833 }
834 #endif
835 
836 void vpMbtFaceDepthNormal::computeNormalVisibility(const double nx, const double ny, const double nz,
837  const vpColVector &centroid_point, vpColVector &face_normal)
838 {
839  face_normal.resize(3, false);
840  face_normal[0] = nx;
841  face_normal[1] = ny;
842  face_normal[2] = nz;
843  face_normal.normalize();
844 
845  vpColVector e4 = -centroid_point;
846  e4.normalize();
847 
848  double angle = acos(vpColVector::dotProd(e4, face_normal));
849  if (angle >= M_PI_2) {
850  face_normal[0] = -face_normal[0];
851  face_normal[1] = -face_normal[1];
852  face_normal[2] = -face_normal[2];
853  }
854 }
855 
857 {
858  L.resize(3, 6, false, false);
859 
860  // Transform the plane equation for the current pose
863 
864  double ux = m_planeCamera.getA();
865  double uy = m_planeCamera.getB();
866  double uz = m_planeCamera.getC();
867  double D = m_planeCamera.getD();
868  double D2 = D * D;
869 
870  // Features
871  features.resize(3, false);
872  features[0] = -ux / D;
873  features[1] = -uy / D;
874  features[2] = -uz / D;
875 
876  // L_A
877  L[0][0] = ux * ux / D2;
878  L[0][1] = ux * uy / D2;
879  L[0][2] = ux * uz / D2;
880  L[0][3] = 0.0;
881  L[0][4] = uz / D;
882  L[0][5] = -uy / D;
883 
884  // L_B
885  L[1][0] = ux * uy / D2;
886  L[1][1] = uy * uy / D2;
887  L[1][2] = uy * uz / D2;
888  L[1][3] = -uz / D;
889  L[1][4] = 0.0;
890  L[1][5] = ux / D;
891 
892  // L_C
893  L[2][0] = ux * uz / D2;
894  L[2][1] = uy * uz / D2;
895  L[2][2] = uz * uz / D2;
896  L[2][3] = uy / D;
897  L[2][4] = -ux / D;
898  L[2][5] = 0.0;
899 }
900 
902  const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness,
903  const bool displayFullModel)
904 {
905  if ((m_polygon->isVisible() && m_isTrackedDepthNormalFace) || displayFullModel) {
907 
908  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
909  ++it) {
910  vpMbtDistanceLine *line = *it;
911  line->display(I, cMo, cam, col, thickness, displayFullModel);
912  }
913  }
914 }
915 
917  const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness,
918  const bool displayFullModel)
919 {
920  if ((m_polygon->isVisible() && m_isTrackedDepthNormalFace) || displayFullModel) {
922 
923  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
924  ++it) {
925  vpMbtDistanceLine *line = *it;
926  line->display(I, cMo, cam, col, thickness, displayFullModel);
927  }
928  }
929 }
930 
932  const vpCameraParameters &cam, const double scale,
933  const unsigned int thickness)
934 {
936  // Desired feature
937  vpPoint pt_centroid = m_faceDesiredCentroid;
938  pt_centroid.changeFrame(cMo);
939  pt_centroid.project();
940 
941  vpImagePoint im_centroid;
942  vpMeterPixelConversion::convertPoint(cam, pt_centroid.get_x(), pt_centroid.get_y(), im_centroid);
943 
944  vpPoint pt_normal = m_faceDesiredNormal;
945  pt_normal.changeFrame(cMo);
946  pt_normal.project();
947 
948  vpPoint pt_extremity;
949  pt_extremity.set_X(pt_centroid.get_X() + pt_normal.get_X() * scale);
950  pt_extremity.set_Y(pt_centroid.get_Y() + pt_normal.get_Y() * scale);
951  pt_extremity.set_Z(pt_centroid.get_Z() + pt_normal.get_Z() * scale);
952  pt_extremity.project();
953 
954  vpImagePoint im_extremity;
955  vpMeterPixelConversion::convertPoint(cam, pt_extremity.get_x(), pt_extremity.get_y(), im_extremity);
956 
957  vpDisplay::displayArrow(I, im_centroid, im_extremity, vpColor::blue, 4, 2, thickness);
958 
959  // Current feature
960  // Transform the plane equation for the current pose
963 
964  double ux = m_planeCamera.getA();
965  double uy = m_planeCamera.getB();
966  double uz = m_planeCamera.getC();
967 
968  vpColVector correct_normal;
969  vpCameraParameters cam_copy = cam;
970  cam_copy.computeFov(I.getWidth(), I.getHeight());
971  computeNormalVisibility(ux, uy, uz, cMo, cam_copy, correct_normal, pt_centroid);
972 
973  pt_centroid.project();
974  vpMeterPixelConversion::convertPoint(cam_copy, pt_centroid.get_x(), pt_centroid.get_y(), im_centroid);
975 
976  pt_extremity.set_X(pt_centroid.get_X() + correct_normal[0] * scale);
977  pt_extremity.set_Y(pt_centroid.get_Y() + correct_normal[1] * scale);
978  pt_extremity.set_Z(pt_centroid.get_Z() + correct_normal[2] * scale);
979  pt_extremity.project();
980 
981  vpMeterPixelConversion::convertPoint(cam_copy, pt_extremity.get_x(), pt_extremity.get_y(), im_extremity);
982 
983  vpDisplay::displayArrow(I, im_centroid, im_extremity, vpColor::red, 4, 2, thickness);
984  }
985 }
986 
988  const vpCameraParameters &cam, const double scale,
989  const unsigned int thickness)
990 {
992  // Desired feature
993  vpPoint pt_centroid = m_faceDesiredCentroid;
994  pt_centroid.changeFrame(cMo);
995  pt_centroid.project();
996 
997  vpImagePoint im_centroid;
998  vpMeterPixelConversion::convertPoint(cam, pt_centroid.get_x(), pt_centroid.get_y(), im_centroid);
999 
1000  vpPoint pt_normal = m_faceDesiredNormal;
1001  pt_normal.changeFrame(cMo);
1002  pt_normal.project();
1003 
1004  vpPoint pt_extremity;
1005  pt_extremity.set_X(pt_centroid.get_X() + pt_normal.get_X() * scale);
1006  pt_extremity.set_Y(pt_centroid.get_Y() + pt_normal.get_Y() * scale);
1007  pt_extremity.set_Z(pt_centroid.get_Z() + pt_normal.get_Z() * scale);
1008  pt_extremity.project();
1009 
1010  vpImagePoint im_extremity;
1011  vpMeterPixelConversion::convertPoint(cam, pt_extremity.get_x(), pt_extremity.get_y(), im_extremity);
1012 
1013  vpDisplay::displayArrow(I, im_centroid, im_extremity, vpColor::blue, 4, 2, thickness);
1014 
1015  // Current feature
1016  // Transform the plane equation for the current pose
1019 
1020  double ux = m_planeCamera.getA();
1021  double uy = m_planeCamera.getB();
1022  double uz = m_planeCamera.getC();
1023 
1024  vpColVector correct_normal;
1025  vpCameraParameters cam_copy = cam;
1026  cam_copy.computeFov(I.getWidth(), I.getHeight());
1027  computeNormalVisibility(ux, uy, uz, cMo, cam_copy, correct_normal, pt_centroid);
1028 
1029  pt_centroid.project();
1030  vpMeterPixelConversion::convertPoint(cam_copy, pt_centroid.get_x(), pt_centroid.get_y(), im_centroid);
1031 
1032  pt_extremity.set_X(pt_centroid.get_X() + correct_normal[0] * scale);
1033  pt_extremity.set_Y(pt_centroid.get_Y() + correct_normal[1] * scale);
1034  pt_extremity.set_Z(pt_centroid.get_Z() + correct_normal[2] * scale);
1035  pt_extremity.project();
1036 
1037  vpMeterPixelConversion::convertPoint(cam_copy, pt_extremity.get_x(), pt_extremity.get_y(), im_extremity);
1038 
1039  vpDisplay::displayArrow(I, im_centroid, im_extremity, vpColor::red, 4, 2, thickness);
1040  }
1041 }
1042 
1043 void vpMbtFaceDepthNormal::estimateFeatures(const std::vector<double> &point_cloud_face, const vpHomogeneousMatrix &cMo,
1044  vpColVector &x_estimated, std::vector<double> &w)
1045 {
1046  vpMbtTukeyEstimator<double> tukey_robust;
1047  std::vector<double> residues(point_cloud_face.size() / 3);
1048 
1049  w.resize(point_cloud_face.size() / 3, 1.0);
1050 
1051  unsigned int max_iter = 30, iter = 0;
1052  double error = 0.0, prev_error = -1.0;
1053  double A = 0.0, B = 0.0, C = 0.0;
1054 
1055  Mat33<double> ATA_3x3;
1056 
1057  bool checkSSE2 = vpCPUFeatures::checkSSE2();
1058 #if !USE_SSE
1059  checkSSE2 = false;
1060 #endif
1061 
1062  if (checkSSE2) {
1063 #if USE_SSE
1064  while (std::fabs(error - prev_error) > 1e-6 && (iter < max_iter)) {
1065  if (iter == 0) {
1066  // Transform the plane equation for the current pose
1069 
1070  double ux = m_planeCamera.getA();
1071  double uy = m_planeCamera.getB();
1072  double uz = m_planeCamera.getC();
1073  double D = m_planeCamera.getD();
1074 
1075  // Features
1076  A = -ux / D;
1077  B = -uy / D;
1078  C = -uz / D;
1079 
1080  size_t cpt = 0;
1081  if (point_cloud_face.size() / 3 >= 2) {
1082  const double *ptr_point_cloud = &point_cloud_face[0];
1083  const __m128d vA = _mm_set1_pd(A);
1084  const __m128d vB = _mm_set1_pd(B);
1085  const __m128d vC = _mm_set1_pd(C);
1086  const __m128d vones = _mm_set1_pd(1.0);
1087 
1088  double *ptr_residues = &residues[0];
1089 
1090  for (; cpt <= point_cloud_face.size() - 6; cpt += 6, ptr_point_cloud += 6, ptr_residues += 2) {
1091  const __m128d vxi = _mm_loadu_pd(ptr_point_cloud);
1092  const __m128d vyi = _mm_loadu_pd(ptr_point_cloud + 2);
1093  const __m128d vZi = _mm_loadu_pd(ptr_point_cloud + 4);
1094  const __m128d vinvZi = _mm_div_pd(vones, vZi);
1095 
1096  const __m128d tmp =
1097  _mm_add_pd(_mm_add_pd(_mm_mul_pd(vA, vxi), _mm_mul_pd(vB, vyi)), _mm_sub_pd(vC, vinvZi));
1098  _mm_storeu_pd(ptr_residues, tmp);
1099  }
1100  }
1101 
1102  for (; cpt < point_cloud_face.size(); cpt += 3) {
1103  double xi = point_cloud_face[cpt];
1104  double yi = point_cloud_face[cpt + 1];
1105  double Zi = point_cloud_face[cpt + 2];
1106 
1107  residues[cpt / 3] = (A * xi + B * yi + C - 1 / Zi);
1108  }
1109  }
1110 
1111  tukey_robust.MEstimator(residues, w, 1e-2);
1112 
1113  __m128d vsum_wi2_xi2 = _mm_setzero_pd();
1114  __m128d vsum_wi2_yi2 = _mm_setzero_pd();
1115  __m128d vsum_wi2 = _mm_setzero_pd();
1116  __m128d vsum_wi2_xi_yi = _mm_setzero_pd();
1117  __m128d vsum_wi2_xi = _mm_setzero_pd();
1118  __m128d vsum_wi2_yi = _mm_setzero_pd();
1119 
1120  __m128d vsum_wi2_xi_Zi = _mm_setzero_pd();
1121  __m128d vsum_wi2_yi_Zi = _mm_setzero_pd();
1122  __m128d vsum_wi2_Zi = _mm_setzero_pd();
1123 
1124  // Estimate A, B, C
1125  size_t cpt = 0;
1126  if (point_cloud_face.size() / 3 >= 2) {
1127  const double *ptr_point_cloud = &point_cloud_face[0];
1128  double *ptr_w = &w[0];
1129 
1130  const __m128d vones = _mm_set1_pd(1.0);
1131 
1132  for (; cpt <= point_cloud_face.size() - 6; cpt += 6, ptr_point_cloud += 6, ptr_w += 2) {
1133  const __m128d vwi2 = _mm_mul_pd(_mm_loadu_pd(ptr_w), _mm_loadu_pd(ptr_w));
1134 
1135  const __m128d vxi = _mm_loadu_pd(ptr_point_cloud);
1136  const __m128d vyi = _mm_loadu_pd(ptr_point_cloud + 2);
1137  const __m128d vZi = _mm_loadu_pd(ptr_point_cloud + 4);
1138  const __m128d vinvZi = _mm_div_pd(vones, vZi);
1139 
1140  vsum_wi2_xi2 = _mm_add_pd(vsum_wi2_xi2, _mm_mul_pd(vwi2, _mm_mul_pd(vxi, vxi)));
1141  vsum_wi2_yi2 = _mm_add_pd(vsum_wi2_yi2, _mm_mul_pd(vwi2, _mm_mul_pd(vyi, vyi)));
1142  vsum_wi2 = _mm_add_pd(vsum_wi2, vwi2);
1143  vsum_wi2_xi_yi = _mm_add_pd(vsum_wi2_xi_yi, _mm_mul_pd(vwi2, _mm_mul_pd(vxi, vyi)));
1144  vsum_wi2_xi = _mm_add_pd(vsum_wi2_xi, _mm_mul_pd(vwi2, vxi));
1145  vsum_wi2_yi = _mm_add_pd(vsum_wi2_yi, _mm_mul_pd(vwi2, vyi));
1146 
1147  const __m128d vwi2_invZi = _mm_mul_pd(vwi2, vinvZi);
1148  vsum_wi2_xi_Zi = _mm_add_pd(vsum_wi2_xi_Zi, _mm_mul_pd(vxi, vwi2_invZi));
1149  vsum_wi2_yi_Zi = _mm_add_pd(vsum_wi2_yi_Zi, _mm_mul_pd(vyi, vwi2_invZi));
1150  vsum_wi2_Zi = _mm_add_pd(vsum_wi2_Zi, vwi2_invZi);
1151  }
1152  }
1153 
1154  double vtmp[2];
1155  _mm_storeu_pd(vtmp, vsum_wi2_xi2);
1156  double sum_wi2_xi2 = vtmp[0] + vtmp[1];
1157 
1158  _mm_storeu_pd(vtmp, vsum_wi2_yi2);
1159  double sum_wi2_yi2 = vtmp[0] + vtmp[1];
1160 
1161  _mm_storeu_pd(vtmp, vsum_wi2);
1162  double sum_wi2 = vtmp[0] + vtmp[1];
1163 
1164  _mm_storeu_pd(vtmp, vsum_wi2_xi_yi);
1165  double sum_wi2_xi_yi = vtmp[0] + vtmp[1];
1166 
1167  _mm_storeu_pd(vtmp, vsum_wi2_xi);
1168  double sum_wi2_xi = vtmp[0] + vtmp[1];
1169 
1170  _mm_storeu_pd(vtmp, vsum_wi2_yi);
1171  double sum_wi2_yi = vtmp[0] + vtmp[1];
1172 
1173  _mm_storeu_pd(vtmp, vsum_wi2_xi_Zi);
1174  double sum_wi2_xi_Zi = vtmp[0] + vtmp[1];
1175 
1176  _mm_storeu_pd(vtmp, vsum_wi2_yi_Zi);
1177  double sum_wi2_yi_Zi = vtmp[0] + vtmp[1];
1178 
1179  _mm_storeu_pd(vtmp, vsum_wi2_Zi);
1180  double sum_wi2_Zi = vtmp[0] + vtmp[1];
1181 
1182  for (; cpt < point_cloud_face.size(); cpt += 3) {
1183  double wi2 = w[cpt / 3] * w[cpt / 3];
1184 
1185  double xi = point_cloud_face[cpt];
1186  double yi = point_cloud_face[cpt + 1];
1187  double Zi = point_cloud_face[cpt + 2];
1188  double invZi = 1.0 / Zi;
1189 
1190  sum_wi2_xi2 += wi2 * xi * xi;
1191  sum_wi2_yi2 += wi2 * yi * yi;
1192  sum_wi2 += wi2;
1193  sum_wi2_xi_yi += wi2 * xi * yi;
1194  sum_wi2_xi += wi2 * xi;
1195  sum_wi2_yi += wi2 * yi;
1196 
1197  sum_wi2_xi_Zi += wi2 * xi * invZi;
1198  sum_wi2_yi_Zi += wi2 * yi * invZi;
1199  sum_wi2_Zi += wi2 * invZi;
1200  }
1201 
1202  ATA_3x3[0] = sum_wi2_xi2;
1203  ATA_3x3[1] = sum_wi2_xi_yi;
1204  ATA_3x3[2] = sum_wi2_xi;
1205  ATA_3x3[3] = sum_wi2_xi_yi;
1206  ATA_3x3[4] = sum_wi2_yi2;
1207  ATA_3x3[5] = sum_wi2_yi;
1208  ATA_3x3[6] = sum_wi2_xi;
1209  ATA_3x3[7] = sum_wi2_yi;
1210  ATA_3x3[8] = sum_wi2;
1211 
1212  Mat33<double> minv = ATA_3x3.inverse();
1213 
1214  A = minv[0] * sum_wi2_xi_Zi + minv[1] * sum_wi2_yi_Zi + minv[2] * sum_wi2_Zi;
1215  B = minv[3] * sum_wi2_xi_Zi + minv[4] * sum_wi2_yi_Zi + minv[5] * sum_wi2_Zi;
1216  C = minv[6] * sum_wi2_xi_Zi + minv[7] * sum_wi2_yi_Zi + minv[8] * sum_wi2_Zi;
1217 
1218  cpt = 0;
1219 
1220  // Compute error
1221  prev_error = error;
1222  error = 0.0;
1223 
1224  __m128d verror = _mm_set1_pd(0.0);
1225  if (point_cloud_face.size() / 3 >= 2) {
1226  const double *ptr_point_cloud = &point_cloud_face[0];
1227  const __m128d vA = _mm_set1_pd(A);
1228  const __m128d vB = _mm_set1_pd(B);
1229  const __m128d vC = _mm_set1_pd(C);
1230  const __m128d vones = _mm_set1_pd(1.0);
1231 
1232  double *ptr_residues = &residues[0];
1233 
1234  for (; cpt <= point_cloud_face.size() - 6; cpt += 6, ptr_point_cloud += 6, ptr_residues += 2) {
1235  const __m128d vxi = _mm_loadu_pd(ptr_point_cloud);
1236  const __m128d vyi = _mm_loadu_pd(ptr_point_cloud + 2);
1237  const __m128d vZi = _mm_loadu_pd(ptr_point_cloud + 4);
1238  const __m128d vinvZi = _mm_div_pd(vones, vZi);
1239 
1240  const __m128d tmp = _mm_add_pd(_mm_add_pd(_mm_mul_pd(vA, vxi), _mm_mul_pd(vB, vyi)), _mm_sub_pd(vC, vinvZi));
1241  verror = _mm_add_pd(verror, _mm_mul_pd(tmp, tmp));
1242 
1243  _mm_storeu_pd(ptr_residues, tmp);
1244  }
1245  }
1246 
1247  _mm_storeu_pd(vtmp, verror);
1248  error = vtmp[0] + vtmp[1];
1249 
1250  for (size_t idx = cpt; idx < point_cloud_face.size(); idx += 3) {
1251  double xi = point_cloud_face[idx];
1252  double yi = point_cloud_face[idx + 1];
1253  double Zi = point_cloud_face[idx + 2];
1254 
1255  error += vpMath::sqr(A * xi + B * yi + C - 1 / Zi);
1256  residues[idx / 3] = (A * xi + B * yi + C - 1 / Zi);
1257  }
1258 
1259  error /= point_cloud_face.size() / 3;
1260 
1261  iter++;
1262  } // while ( std::fabs(error - prev_error) > 1e-6 && (iter < max_iter) )
1263 #endif
1264  } else {
1265  while (std::fabs(error - prev_error) > 1e-6 && (iter < max_iter)) {
1266  if (iter == 0) {
1267  // Transform the plane equation for the current pose
1270 
1271  double ux = m_planeCamera.getA();
1272  double uy = m_planeCamera.getB();
1273  double uz = m_planeCamera.getC();
1274  double D = m_planeCamera.getD();
1275 
1276  // Features
1277  A = -ux / D;
1278  B = -uy / D;
1279  C = -uz / D;
1280 
1281  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1282  double xi = point_cloud_face[3 * i];
1283  double yi = point_cloud_face[3 * i + 1];
1284  double Zi = point_cloud_face[3 * i + 2];
1285 
1286  residues[i] = (A * xi + B * yi + C - 1 / Zi);
1287  }
1288  }
1289 
1290  tukey_robust.MEstimator(residues, w, 1e-2);
1291 
1292  // Estimate A, B, C
1293  double sum_wi2_xi2 = 0.0, sum_wi2_yi2 = 0.0, sum_wi2 = 0.0;
1294  double sum_wi2_xi_yi = 0.0, sum_wi2_xi = 0.0, sum_wi2_yi = 0.0;
1295 
1296  double sum_wi2_xi_Zi = 0.0, sum_wi2_yi_Zi = 0.0, sum_wi2_Zi = 0.0;
1297 
1298  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1299  double wi2 = w[i] * w[i];
1300 
1301  double xi = point_cloud_face[3 * i];
1302  double yi = point_cloud_face[3 * i + 1];
1303  double Zi = point_cloud_face[3 * i + 2];
1304  double invZi = 1 / Zi;
1305 
1306  sum_wi2_xi2 += wi2 * xi * xi;
1307  sum_wi2_yi2 += wi2 * yi * yi;
1308  sum_wi2 += wi2;
1309  sum_wi2_xi_yi += wi2 * xi * yi;
1310  sum_wi2_xi += wi2 * xi;
1311  sum_wi2_yi += wi2 * yi;
1312 
1313  sum_wi2_xi_Zi += wi2 * xi * invZi;
1314  sum_wi2_yi_Zi += wi2 * yi * invZi;
1315  sum_wi2_Zi += wi2 * invZi;
1316  }
1317 
1318  ATA_3x3[0] = sum_wi2_xi2;
1319  ATA_3x3[1] = sum_wi2_xi_yi;
1320  ATA_3x3[2] = sum_wi2_xi;
1321  ATA_3x3[3] = sum_wi2_xi_yi;
1322  ATA_3x3[4] = sum_wi2_yi2;
1323  ATA_3x3[5] = sum_wi2_yi;
1324  ATA_3x3[6] = sum_wi2_xi;
1325  ATA_3x3[7] = sum_wi2_yi;
1326  ATA_3x3[8] = sum_wi2;
1327 
1328  Mat33<double> minv = ATA_3x3.inverse();
1329 
1330  A = minv[0] * sum_wi2_xi_Zi + minv[1] * sum_wi2_yi_Zi + minv[2] * sum_wi2_Zi;
1331  B = minv[3] * sum_wi2_xi_Zi + minv[4] * sum_wi2_yi_Zi + minv[5] * sum_wi2_Zi;
1332  C = minv[6] * sum_wi2_xi_Zi + minv[7] * sum_wi2_yi_Zi + minv[8] * sum_wi2_Zi;
1333 
1334  prev_error = error;
1335  error = 0.0;
1336 
1337  // Compute error
1338  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1339  double xi = point_cloud_face[3 * i];
1340  double yi = point_cloud_face[3 * i + 1];
1341  double Zi = point_cloud_face[3 * i + 2];
1342 
1343  error += vpMath::sqr(A * xi + B * yi + C - 1 / Zi);
1344  residues[i] = (A * xi + B * yi + C - 1 / Zi);
1345  }
1346 
1347  error /= point_cloud_face.size() / 3;
1348 
1349  iter++;
1350  } // while ( std::fabs(error - prev_error) > 1e-6 && (iter < max_iter) )
1351  }
1352 
1353  x_estimated.resize(3, false);
1354  x_estimated[0] = A;
1355  x_estimated[1] = B;
1356  x_estimated[2] = C;
1357 }
1358 
1359 void vpMbtFaceDepthNormal::estimatePlaneEquationSVD(const std::vector<double> &point_cloud_face,
1360  const vpHomogeneousMatrix &cMo,
1361  vpColVector &plane_equation_estimated, vpColVector &centroid)
1362 {
1363  const unsigned int max_iter = 10;
1364  double prev_error = 1e3;
1365  double error = 1e3 - 1;
1366 
1367  std::vector<double> weights(point_cloud_face.size() / 3, 1.0);
1368  std::vector<double> residues(point_cloud_face.size() / 3);
1369  vpMatrix M((unsigned int)(point_cloud_face.size() / 3), 3);
1370  vpMbtTukeyEstimator<double> tukey;
1371  vpColVector normal;
1372 
1373  for (unsigned int iter = 0; iter < max_iter && std::fabs(error - prev_error) > 1e-6; iter++) {
1374  if (iter != 0) {
1375  tukey.MEstimator(residues, weights, 1e-4);
1376  } else {
1377  // Transform the plane equation for the current pose
1380 
1381  double A = m_planeCamera.getA();
1382  double B = m_planeCamera.getB();
1383  double C = m_planeCamera.getC();
1384  double D = m_planeCamera.getD();
1385 
1386  // Compute distance point to estimated plane
1387  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1388  residues[i] = std::fabs(A * point_cloud_face[3 * i] + B * point_cloud_face[3 * i + 1] +
1389  C * point_cloud_face[3 * i + 2] + D) /
1390  sqrt(A * A + B * B + C * C);
1391  }
1392 
1393  tukey.MEstimator(residues, weights, 1e-4);
1394  plane_equation_estimated.resize(4, false);
1395  }
1396 
1397  // Compute centroid
1398  double centroid_x = 0.0, centroid_y = 0.0, centroid_z = 0.0;
1399  double total_w = 0.0;
1400 
1401  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1402  centroid_x += weights[i] * point_cloud_face[3 * i];
1403  centroid_y += weights[i] * point_cloud_face[3 * i + 1];
1404  centroid_z += weights[i] * point_cloud_face[3 * i + 2];
1405  total_w += weights[i];
1406  }
1407 
1408  centroid_x /= total_w;
1409  centroid_y /= total_w;
1410  centroid_z /= total_w;
1411 
1412  // Minimization
1413  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1414  M[(unsigned int)i][0] = weights[i] * (point_cloud_face[3 * i] - centroid_x);
1415  M[(unsigned int)i][1] = weights[i] * (point_cloud_face[3 * i + 1] - centroid_y);
1416  M[(unsigned int)i][2] = weights[i] * (point_cloud_face[3 * i + 2] - centroid_z);
1417  }
1418 
1419  vpMatrix J = M.t() * M;
1420 
1421  vpColVector W;
1422  vpMatrix V;
1423  J.svd(W, V);
1424 
1425  double smallestSv = W[0];
1426  unsigned int indexSmallestSv = 0;
1427  for (unsigned int i = 1; i < W.size(); i++) {
1428  if (W[i] < smallestSv) {
1429  smallestSv = W[i];
1430  indexSmallestSv = i;
1431  }
1432  }
1433 
1434  normal = V.getCol(indexSmallestSv);
1435 
1436  // Compute plane equation
1437  double A = normal[0], B = normal[1], C = normal[2];
1438  double D = -(A * centroid_x + B * centroid_y + C * centroid_z);
1439 
1440  // Update plane equation
1441  plane_equation_estimated[0] = A;
1442  plane_equation_estimated[1] = B;
1443  plane_equation_estimated[2] = C;
1444  plane_equation_estimated[3] = D;
1445 
1446  // Compute error points to estimated plane
1447  prev_error = error;
1448  error = 0.0;
1449  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1450  residues[i] = std::fabs(A * point_cloud_face[3 * i] + B * point_cloud_face[3 * i + 1] +
1451  C * point_cloud_face[3 * i + 2] + D) /
1452  sqrt(A * A + B * B + C * C);
1453  error += residues[i] * residues[i];
1454  }
1455  error /= sqrt(error / total_w);
1456  }
1457 
1458  // Update final weights
1459  tukey.MEstimator(residues, weights, 1e-4);
1460 
1461  // Update final centroid
1462  centroid.resize(3, false);
1463  double total_w = 0.0;
1464 
1465  for (size_t i = 0; i < point_cloud_face.size() / 3; i++) {
1466  centroid[0] += weights[i] * point_cloud_face[3 * i];
1467  centroid[1] += weights[i] * point_cloud_face[3 * i + 1];
1468  centroid[2] += weights[i] * point_cloud_face[3 * i + 2];
1469  total_w += weights[i];
1470  }
1471 
1472  centroid[0] /= total_w;
1473  centroid[1] /= total_w;
1474  centroid[2] /= total_w;
1475 
1476  // Compute final plane equation
1477  double A = normal[0], B = normal[1], C = normal[2];
1478  double D = -(A * centroid[0] + B * centroid[1] + C * centroid[2]);
1479 
1480  // Update final plane equation
1481  plane_equation_estimated[0] = A;
1482  plane_equation_estimated[1] = B;
1483  plane_equation_estimated[2] = C;
1484  plane_equation_estimated[3] = D;
1485 }
1486 
1496 bool vpMbtFaceDepthNormal::samePoint(const vpPoint &P1, const vpPoint &P2) const
1497 {
1498  double dx = fabs(P1.get_oX() - P2.get_oX());
1499  double dy = fabs(P1.get_oY() - P2.get_oY());
1500  double dz = fabs(P1.get_oZ() - P2.get_oZ());
1501 
1502  if (dx <= std::numeric_limits<double>::epsilon() && dy <= std::numeric_limits<double>::epsilon() &&
1503  dz <= std::numeric_limits<double>::epsilon())
1504  return true;
1505  else
1506  return false;
1507 }
1508 
1510 {
1511  m_cam = camera;
1512 
1513  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
1514  ++it) {
1515  (*it)->setCameraParameters(camera);
1516  }
1517 }
1518 
1520 {
1521  m_useScanLine = v;
1522 
1523  for (std::vector<vpMbtDistanceLine *>::const_iterator it = m_listOfFaceLines.begin(); it != m_listOfFaceLines.end();
1524  ++it) {
1525  (*it)->useScanLine = v;
1526  }
1527 }
vpFeatureEstimationType m_featureEstimationMethod
Method to estimate the desired features.
void svd(vpColVector &w, vpMatrix &V)
Definition: vpMatrix.cpp:1792
Used to indicate that a value is not in the allowed range.
Definition: vpException.h:97
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void getRoiClipped(const vpCameraParameters &cam, std::vector< vpImagePoint > &roi)
double getTop() const
Definition: vpRect.h:175
Implements a 3D polygon with render functionnalities like clipping.
Definition: vpPolygon3D.h:59
void setVisible(bool _isvisible)
unsigned int getWidth() const
Definition: vpImage.h:239
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
Implementation of an homogeneous matrix and operations on such kind of matrices.
std::list< int > Lindex_polygon
Index of the faces which contain the line.
void setFarClippingDistance(const double &dist)
Definition: vpPolygon3D.h:194
int m_pclPlaneEstimationMethod
PCL plane estimation method.
static void convertPoint(const vpCameraParameters &cam, const double &x, const double &y, double &u, double &v)
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true, const bool recopy_=true)
Definition: vpArray2D.h:171
unsigned int m_clippingFlag
Flags specifying which clipping to used.
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
void setLeft(double pos)
Definition: vpRect.h:257
int m_pclPlaneEstimationRansacMaxIter
PCL pane estimation max number of iterations.
vpPoint * p1
The first extremity.
void computeDesiredFeaturesRobustFeatures(const std::vector< double > &point_cloud_face_custom, const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
double get_oY() const
Get the point Y coordinate in the object frame.
Definition: vpPoint.cpp:422
error that can be emited by ViSP classes.
Definition: vpException.h:71
vpMbScanLine & getMbScanLineRenderer()
Manage the line of a polygon used in the model-based tracker.
double getHeight() const
Definition: vpRect.h:149
static void convertPoint(const vpCameraParameters &cam, const double &u, const double &v, double &x, double &y)
unsigned int size() const
Return the number of elements of the 2D array.
Definition: vpArray2D.h:158
double get_y() const
Get the point y coordinate in the image plane.
Definition: vpPoint.cpp:431
double m_distNearClip
Distance for near clipping.
double getRight() const
Definition: vpRect.h:162
void addLine(vpPoint &p1, vpPoint &p2, vpMbHiddenFaces< vpMbtPolygon > *const faces, int polygon=-1, std::string name="")
void set_X(const double X)
Set the point X coordinate in the camera frame.
Definition: vpPoint.cpp:452
vpMbtPolygon & getPolygon()
bool m_useScanLine
Scan line visibility.
vpCameraParameters m_cam
Camera intrinsic parameters.
static bool inMask(const vpImage< bool > *mask, const unsigned int i, const unsigned int j)
static const vpColor red
Definition: vpColor.h:180
Class that defines what is a point.
Definition: vpPoint.h:58
void computeROI(const vpHomogeneousMatrix &cMo, const unsigned int width, const unsigned int height, std::vector< vpImagePoint > &roiPts)
bool isInside(const vpImagePoint &iP, const PointInPolygonMethod &method=PnPolyRayCasting) const
Definition: vpPolygon.cpp:317
void setScanLineVisibilityTest(const bool v)
bool computePolygonCentroid(const std::vector< vpPoint > &points, vpPoint &centroid)
void setCameraParameters(const vpCameraParameters &camera)
bool computeDesiredFeatures(const vpHomogeneousMatrix &cMo, const unsigned int width, const unsigned int height, const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud, vpColVector &desired_features, const unsigned int stepX, const unsigned int stepY, const vpImage< bool > *mask=NULL)
bool m_faceActivated
True if the face should be considered by the tracker.
vpMbtPolygon * m_polygon
Polygon defining the face.
Defines a generic 2D polygon.
Definition: vpPolygon.h:103
double getBottom() const
Definition: vpRect.h:94
vpRect getBoundingBox() const
Definition: vpPolygon.h:177
double getWidth() const
Definition: vpRect.h:197
vpColVector & normalize()
void set_Z(const double Z)
Set the point Z coordinate in the camera frame.
Definition: vpPoint.cpp:456
void setTop(double pos)
Definition: vpRect.h:292
void computeInteractionMatrix(const vpHomogeneousMatrix &cMo, vpMatrix &L, vpColVector &features)
vpPoint * p2
The second extremity.
void changeFrame(const vpHomogeneousMatrix &cMo)
Definition: vpPlane.cpp:354
static void displayArrow(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
static double sqr(double x)
Definition: vpMath.h:108
bool computeDesiredFeaturesPCL(const pcl::PointCloud< pcl::PointXYZ >::ConstPtr &point_cloud_face, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
VISP_EXPORT bool checkSSE2()
int getIndex() const
Definition: vpMbtPolygon.h:101
void getPolygonClipped(std::vector< std::pair< vpPoint, unsigned int > > &poly)
vpMbHiddenFaces< vpMbtPolygon > * m_hiddenFace
Pointer to the list of faces.
Generic class defining intrinsic camera parameters.
vpColVector getCol(const unsigned int j) const
Definition: vpMatrix.cpp:3798
double get_oZ() const
Get the point Z coordinate in the object frame.
Definition: vpPoint.cpp:424
void setIndex(const unsigned int i)
void set_Y(const double Y)
Set the point Y coordinate in the camera frame.
Definition: vpPoint.cpp:454
double get_x() const
Get the point x coordinate in the image plane.
Definition: vpPoint.cpp:429
vpPoint m_faceDesiredNormal
Face (normalized) normal (computed from the sensor)
virtual bool isVisible(const vpHomogeneousMatrix &cMo, const double alpha, const bool &modulo=false, const vpCameraParameters &cam=vpCameraParameters(), const vpImage< unsigned char > &I=vpImage< unsigned char >())
double m_distFarClip
Distance for near clipping.
double get_Y() const
Get the point Y coordinate in the camera frame.
Definition: vpPoint.cpp:413
std::vector< vpMbtDistanceLine * > m_listOfFaceLines
void displayFeature(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const double scale=0.05, const unsigned int thickness=1)
void setClipping(const unsigned int &flags)
Definition: vpPolygon3D.h:187
bool samePoint(const vpPoint &P1, const vpPoint &P2) const
std::vector< PolygonLine > m_polygonLines
double get_Z() const
Get the point Z coordinate in the camera frame.
Definition: vpPoint.cpp:415
vpFaceCentroidType m_faceCentroidMethod
Method to compute the face centroid for the current features.
void setName(const std::string &line_name)
void setCameraParameters(const vpCameraParameters &camera)
double get_oX() const
Get the point X coordinate in the object frame.
Definition: vpPoint.cpp:420
vpMatrix t() const
Definition: vpMatrix.cpp:375
void computeScanLineQuery(const vpPoint &a, const vpPoint &b, std::vector< std::pair< vpPoint, vpPoint > > &lines, const bool &displayResults=false)
void setWorldCoordinates(const double oX, const double oY, const double oZ)
Definition: vpPoint.cpp:113
void estimatePlaneEquationSVD(const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &plane_equation_estimated, vpColVector &centroid)
void computeDesiredFeaturesSVD(const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &desired_features, vpColVector &desired_normal, vpColVector &centroid_point)
void computeDesiredNormalAndCentroid(const vpHomogeneousMatrix &cMo, const vpColVector &desired_normal, const vpColVector &centroid_point)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
static double dotProd(const vpColVector &a, const vpColVector &b)
void setRight(double pos)
Definition: vpRect.h:283
vpHomogeneousMatrix inverse() const
vpMbHiddenFaces< vpMbtPolygon > * hiddenface
Pointer to the list of faces.
double getB() const
Definition: vpPlane.h:104
bool isVisible(const unsigned int i)
double getA() const
Definition: vpPlane.h:102
void addPolygon(const int &index)
void setNearClippingDistance(const double &dist)
Definition: vpPolygon3D.h:207
unsigned int getHeight() const
Definition: vpImage.h:178
vpPoint m_faceDesiredCentroid
Desired centroid (computed from the sensor)
Defines a rectangle in the plane.
Definition: vpRect.h:78
double getC() const
Definition: vpPlane.h:106
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
Compute the geometric centroid.
vpPlane m_planeObject
Plane equation described in the object frame.
void changeFrame(const vpHomogeneousMatrix &cMo, vpColVector &_cP)
Definition: vpPoint.cpp:233
void estimateFeatures(const std::vector< double > &point_cloud_face, const vpHomogeneousMatrix &cMo, vpColVector &x_estimated, std::vector< double > &weights)
double get_X() const
Get the point X coordinate in the camera frame.
Definition: vpPoint.cpp:411
double getLeft() const
Definition: vpRect.h:156
void setBottom(double pos)
Definition: vpRect.h:224
void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &col, const unsigned int thickness=1, const bool displayFullModel=false)
bool useScanLine
Use scanline rendering.
void buildFrom(vpPoint &_p1, vpPoint &_p2)
double getD() const
Definition: vpPlane.h:108
static const vpColor blue
Definition: vpColor.h:186
void computeNormalVisibility(const double nx, const double ny, const double nz, const vpColVector &centroid_point, vpColVector &face_normal)
double m_pclPlaneEstimationRansacThreshold
PCL plane estimation RANSAC threshold.
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:244
void computeFov(const unsigned int &w, const unsigned int &h)