49#include <visp3/core/vpHomogeneousMatrix.h>
50#include <visp3/core/vpPoint.h>
51#include <visp3/core/vpRGBa.h>
52#include <visp3/vision/vpHomography.h>
53#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
54#include <visp3/core/vpList.h>
56#include <visp3/core/vpThread.h>
61#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
65#include <visp3/core/vpUniRand.h>
106 CHECK_DEGENERATE_POINTS
121 std::vector<vpPoint> c3d;
123 bool computeCovariance;
128 unsigned int ransacNbInlierConsensus;
132 std::vector<vpPoint> ransacInliers;
134 std::vector<unsigned int> ransacInlierIndex;
136 double ransacThreshold;
139 double distanceToPlaneForCoplanarityTest;
144 std::vector<vpPoint> listOfPoints;
146 bool useParallelRansac;
148 int nbParallelRansacThreads;
157 RansacFunctor(
const vpHomogeneousMatrix &cMo_,
unsigned int ransacNbInlierConsensus_,
const int ransacMaxTrials_,
158 double ransacThreshold_,
unsigned int initial_seed_,
bool checkDegeneratePoints_,
159 const std::vector<vpPoint> &listOfUniquePoints_,
bool (*func_)(
const vpHomogeneousMatrix &))
160 : m_best_consensus(), m_checkDegeneratePoints(checkDegeneratePoints_), m_cMo(cMo_), m_foundSolution(
false),
161 m_func(func_), m_listOfUniquePoints(listOfUniquePoints_), m_nbInliers(0), m_ransacMaxTrials(ransacMaxTrials_),
162 m_ransacNbInlierConsensus(ransacNbInlierConsensus_), m_ransacThreshold(ransacThreshold_),
163 m_uniRand(initial_seed_)
167 void operator()() { m_foundSolution = poseRansacImpl(); }
170 bool getResult()
const {
return m_foundSolution; }
172 std::vector<unsigned int> getBestConsensus()
const {
return m_best_consensus; }
176 unsigned int getNbInliers()
const {
return m_nbInliers; }
179 std::vector<unsigned int> m_best_consensus;
180 bool m_checkDegeneratePoints;
182 bool m_foundSolution;
184 std::vector<vpPoint> m_listOfUniquePoints;
185 unsigned int m_nbInliers;
186 int m_ransacMaxTrials;
187 unsigned int m_ransacNbInlierConsensus;
188 double m_ransacThreshold;
191 bool poseRansacImpl();
202 vpPose(
const std::vector<vpPoint> &lP);
204 void addPoint(
const vpPoint &P);
205 void addPoints(
const std::vector<vpPoint> &lP);
210 bool coplanar(
int &coplanar_plane_type);
223 void setDistanceToPlaneForCoplanarityTest(
double d);
239 if (t > std::numeric_limits<double>::epsilon()) {
269 if (!computeCovariance)
270 vpTRACE(
"Warning : The covariance matrix has not been computed. See "
271 "setCovarianceComputation() to do it.");
273 return covarianceMatrix;
327 std::vector<vpPoint> vectorOfPoints(listP.begin(), listP.end());
328 return vectorOfPoints;
338 static int computeRansacIterations(
double probability,
double epsilon,
const int sampleSize = 4,
339 int maxIterations = 2000);
341 static void findMatch(std::vector<vpPoint> &p2D, std::vector<vpPoint> &p3D,
342 const unsigned int &numberOfInlierToReachAConsensus,
const double &threshold,
344 const int &maxNbTrials = 10000,
bool useParallelRansac =
true,
unsigned int nthreads = 0,
347 static bool computePlanarObjectPoseFromRGBD(
const vpImage<float> &depthMap,
const std::vector<vpImagePoint> &corners,
350 double *confidence_index = NULL);
352 static bool computePlanarObjectPoseFromRGBD(
const vpImage<float> &depthMap,
353 const std::vector<std::vector<vpImagePoint> > &corners,
355 const std::vector<std::vector<vpPoint> > &point3d,
357 bool coplanar_points =
true);
359#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
364 vp_deprecated
void init();
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionnalities.
static const vpColor none
error that can be emited by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
Class used for pose computation from N points (pose from point only). Some of the algorithms implemen...
std::vector< vpPoint > getPoints() const
void setRansacMaxTrials(const int &rM)
void setRansacNbInliersToReachConsensus(const unsigned int &nbC)
vpMatrix getCovarianceMatrix() const
std::vector< unsigned int > getRansacInlierIndex() const
bool getUseParallelRansac() const
void setCovarianceComputation(const bool &flag)
unsigned int npt
Number of point used in pose computation.
int getNbParallelRansacThreads() const
std::vector< vpPoint > getRansacInliers() const
std::list< vpPoint > listP
Array of point (use here class vpPoint)
void setRansacFilterFlag(const RANSAC_FILTER_FLAGS &flag)
void setVvsIterMax(int nb)
@ PREFILTER_DEGENERATE_POINTS
unsigned int getRansacNbInliers() const
void setUseParallelRansac(bool use)
double lambda
parameters use for the virtual visual servoing approach
void setVvsEpsilon(const double eps)
void setNbParallelRansacThreads(int nb)
double residual
Residual in meter.
void setRansacThreshold(const double &t)
Class for generating random numbers with uniform probability density.