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
00050 namespace cv3 {
00051
00052
00053
00054
00090 bool solvePnPRansac( cv::InputArray objectPoints, cv::InputArray imagePoints,
00091 cv::InputArray cameraMatrix, cv::InputArray distCoeffs,
00092 cv::OutputArray rvec, cv::OutputArray tvec,
00093 bool useExtrinsicGuess = false, int iterationsCount = 100,
00094 float reprojectionError = 8.0, double confidence = 0.99,
00095 cv::OutputArray inliers = cv::noArray(), int flags = CV_ITERATIVE );
00096
00097 int RANSACUpdateNumIters( double p, double ep, int modelPoints, int maxIters );
00098
00099 class LMSolver : public cv::Algorithm
00100 {
00101 public:
00102 class Callback
00103 {
00104 public:
00105 virtual ~Callback() {}
00106 virtual bool compute(cv::InputArray param, cv::OutputArray err, cv::OutputArray J) const = 0;
00107 };
00108
00109 virtual void setCallback(const cv::Ptr<LMSolver::Callback>& cb) = 0;
00110 virtual int run(cv::InputOutputArray _param0) const = 0;
00111 };
00112
00113 cv::Ptr<LMSolver> createLMSolver(const cv::Ptr<LMSolver::Callback>& cb, int maxIters);
00114
00115 class PointSetRegistrator : public cv::Algorithm
00116 {
00117 public:
00118 class Callback
00119 {
00120 public:
00121 virtual ~Callback() {}
00122 virtual int runKernel(cv::InputArray m1, cv::InputArray m2, cv::OutputArray model) const = 0;
00123 virtual void computeError(cv::InputArray m1, cv::InputArray m2, cv::InputArray model, cv::OutputArray err) const = 0;
00124 virtual bool checkSubset(cv::InputArray, cv::InputArray, int) const { return true; }
00125 };
00126
00127 virtual void setCallback(const cv::Ptr<PointSetRegistrator::Callback>& cb) = 0;
00128 virtual bool run(cv::InputArray m1, cv::InputArray m2, cv::OutputArray model, cv::OutputArray mask) const = 0;
00129 };
00130
00131 cv::Ptr<PointSetRegistrator> createRANSACPointSetRegistrator(const cv::Ptr<PointSetRegistrator::Callback>& cb,
00132 int modelPoints, double threshold,
00133 double confidence=0.99, int maxIters=1000 );
00134
00135 cv::Ptr<PointSetRegistrator> createLMeDSPointSetRegistrator(const cv::Ptr<PointSetRegistrator::Callback>& cb,
00136 int modelPoints, double confidence=0.99, int maxIters=1000 );
00137
00138 template<typename T> inline int compressElems( T* ptr, const uchar* mask, int mstep, int count )
00139 {
00140 int i, j;
00141 for( i = j = 0; i < count; i++ )
00142 if( mask[i*mstep] )
00143 {
00144 if( i > j )
00145 ptr[j] = ptr[i];
00146 j++;
00147 }
00148 return j;
00149 }
00150
00151 }
00152
00153 #endif