Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef RTABMAP_CORELIB_SRC_OPENCV_SOLVEPNP_H_
00045 #define RTABMAP_CORELIB_SRC_OPENCV_SOLVEPNP_H_
00046
00047 #include <opencv2/core/core.hpp>
00048 #include <opencv2/calib3d/calib3d.hpp>
00049 #if CV_MAJOR_VERSION >= 3
00050 #include <opencv2/calib3d/calib3d_c.h>
00051 #endif
00052
00053 namespace cv3 {
00054
00055
00056
00057
00093 bool solvePnPRansac( cv::InputArray objectPoints, cv::InputArray imagePoints,
00094 cv::InputArray cameraMatrix, cv::InputArray distCoeffs,
00095 cv::OutputArray rvec, cv::OutputArray tvec,
00096 bool useExtrinsicGuess = false, int iterationsCount = 100,
00097 float reprojectionError = 8.0, double confidence = 0.99,
00098 cv::OutputArray inliers = cv::noArray(), int flags = CV_ITERATIVE );
00099
00100 int RANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters );
00101
00102 class LMSolver : public cv::Algorithm
00103 {
00104 public:
00105 class Callback
00106 {
00107 public:
00108 virtual ~Callback() {}
00109 virtual bool compute(cv::InputArray param, cv::OutputArray err, cv::OutputArray J) const = 0;
00110 };
00111
00112 virtual void setCallback(const cv::Ptr<LMSolver::Callback>& cb) = 0;
00113 virtual int run(cv::InputOutputArray _param0) const = 0;
00114 };
00115
00116 cv::Ptr<LMSolver> createLMSolver(const cv::Ptr<LMSolver::Callback>& cb, int maxIters);
00117
00118 class PointSetRegistrator : public cv::Algorithm
00119 {
00120 public:
00121 class Callback
00122 {
00123 public:
00124 virtual ~Callback() {}
00125 virtual int runKernel(cv::InputArray m1, cv::InputArray m2, cv::OutputArray model) const = 0;
00126 virtual void computeError(cv::InputArray m1, cv::InputArray m2, cv::InputArray model, cv::OutputArray err) const = 0;
00127 virtual bool checkSubset(cv::InputArray, cv::InputArray, int) const { return true; }
00128 };
00129
00130 virtual void setCallback(const cv::Ptr<PointSetRegistrator::Callback>& cb) = 0;
00131 virtual bool run(cv::InputArray m1, cv::InputArray m2, cv::OutputArray model, cv::OutputArray mask) const = 0;
00132 };
00133
00134 cv::Ptr<PointSetRegistrator> createRANSACPointSetRegistrator(const cv::Ptr<PointSetRegistrator::Callback>& cb,
00135 int modelPoints, double threshold,
00136 double confidence=0.99, int maxIters=1000 );
00137
00138 cv::Ptr<PointSetRegistrator> createLMeDSPointSetRegistrator(const cv::Ptr<PointSetRegistrator::Callback>& cb,
00139 int modelPoints, double confidence=0.99, int maxIters=1000 );
00140
00141 template<typename T> inline int compressElems( T* ptr, const uchar* mask, int mstep, int count )
00142 {
00143 int i, j;
00144 for( i = j = 0; i < count; i++ )
00145 if( mask[i*mstep] )
00146 {
00147 if( i > j )
00148 ptr[j] = ptr[i];
00149 j++;
00150 }
00151 return j;
00152 }
00153
00154 }
00155
00156 #endif