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;
158 const int ransacMaxTrials_,
double ransacThreshold_,
unsigned int initial_seed_,
159 bool checkDegeneratePoints_,
const std::vector<vpPoint> &listOfUniquePoints_,
161 #
if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
162 , std::atomic<bool> &abort
166 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
169 m_best_consensus(), m_checkDegeneratePoints(checkDegeneratePoints_), m_cMo(cMo_), m_foundSolution(
false),
170 m_func(func_), m_listOfUniquePoints(listOfUniquePoints_), m_nbInliers(0),
171 m_ransacMaxTrials(ransacMaxTrials_), m_ransacNbInlierConsensus(ransacNbInlierConsensus_),
172 m_ransacThreshold(ransacThreshold_), m_uniRand(initial_seed_)
176 void operator()() { m_foundSolution = poseRansacImpl(); }
179 bool getResult()
const {
return m_foundSolution; }
181 std::vector<unsigned int> getBestConsensus()
const {
return m_best_consensus; }
185 unsigned int getNbInliers()
const {
return m_nbInliers; }
188 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
189 std::atomic<bool> &m_abort;
191 std::vector<unsigned int> m_best_consensus;
192 bool m_checkDegeneratePoints;
194 bool m_foundSolution;
196 std::vector<vpPoint> m_listOfUniquePoints;
197 unsigned int m_nbInliers;
198 int m_ransacMaxTrials;
199 unsigned int m_ransacNbInlierConsensus;
200 double m_ransacThreshold;
203 bool poseRansacImpl();
214 vpPose(
const std::vector<vpPoint>& lP);
216 void addPoint(
const vpPoint &P);
217 void addPoints(
const std::vector<vpPoint> &lP);
222 bool coplanar(
int &coplanar_plane_type);
235 void setDistanceToPlaneForCoplanarityTest(
double d);
251 if (t > std::numeric_limits<double>::epsilon()) {
281 if (!computeCovariance)
282 vpTRACE(
"Warning : The covariance matrix has not been computed. See "
283 "setCovarianceComputation() to do it.");
285 return covarianceMatrix;
339 std::vector<vpPoint> vectorOfPoints(listP.begin(), listP.end());
340 return vectorOfPoints;
350 static int computeRansacIterations(
double probability,
double epsilon,
const int sampleSize = 4,
351 int maxIterations = 2000);
353 static void findMatch(std::vector<vpPoint> &p2D, std::vector<vpPoint> &p3D,
354 const unsigned int &numberOfInlierToReachAConsensus,
const double &threshold,
356 const int &maxNbTrials=10000,
bool useParallelRansac=
true,
unsigned int nthreads=0,
359 static bool computePlanarObjectPoseFromRGBD(
const vpImage<float> &depthMap,
const std::vector<vpImagePoint> &corners,
361 double *confidence_index = NULL);
363 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
368 vp_deprecated
void init();