| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 | 
							
- #ifndef __OPENCV_CCALIB_HPP__
 
- #define __OPENCV_CCALIB_HPP__
 
- #include <opencv2/core.hpp>
 
- #include <opencv2/features2d.hpp>
 
- #include <opencv2/imgproc.hpp>
 
- #include <opencv2/calib3d.hpp>
 
- #include <vector>
 
- namespace cv{ namespace ccalib{
 
- class CV_EXPORTS CustomPattern : public Algorithm
 
- {
 
- public:
 
- 	CustomPattern();
 
- 	virtual ~CustomPattern();
 
- 	bool create(InputArray pattern, const Size2f boardSize, OutputArray output = noArray());
 
- 	bool findPattern(InputArray image, OutputArray matched_features, OutputArray pattern_points, const double ratio = 0.7,
 
- 					 const double proj_error = 8.0, const bool refine_position = false, OutputArray out = noArray(),
 
- 					 OutputArray H = noArray(), OutputArray pattern_corners = noArray());
 
- 	bool isInitialized();
 
- 	void getPatternPoints(std::vector<KeyPoint>& original_points);
 
-     
 
- 	double getPixelSize();
 
-     
 
- 	bool setFeatureDetector(Ptr<FeatureDetector> featureDetector);
 
- 	bool setDescriptorExtractor(Ptr<DescriptorExtractor> extractor);
 
- 	bool setDescriptorMatcher(Ptr<DescriptorMatcher> matcher);
 
- 	Ptr<FeatureDetector> getFeatureDetector();
 
- 	Ptr<DescriptorExtractor> getDescriptorExtractor();
 
- 	Ptr<DescriptorMatcher> getDescriptorMatcher();
 
- 	double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints,
 
- 				Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
 
- 				OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0,
 
- 				TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
 
-     
 
- 	bool findRt(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
 
-                 OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
 
- 	bool findRt(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
 
-                 OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
 
-     
 
- 	bool findRtRANSAC(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
 
- 				OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
 
- 				float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
 
- 	bool findRtRANSAC(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
 
- 				OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
 
- 				float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
 
-         
 
- 	void drawOrientation(InputOutputArray image, InputArray tvec, InputArray rvec, InputArray cameraMatrix,
 
- 						 InputArray distCoeffs, double axis_length = 3, int axis_width = 2);
 
-     
 
- private:
 
- 	Mat img_roi;
 
- 	std::vector<Point2f> obj_corners;
 
- 	double pxSize;
 
- 	bool initialized;
 
- 	Ptr<FeatureDetector> detector;
 
- 	Ptr<DescriptorExtractor> descriptorExtractor;
 
- 	Ptr<DescriptorMatcher> descriptorMatcher;
 
- 	std::vector<KeyPoint> keypoints;
 
- 	std::vector<Point3f> points3d;
 
- 	Mat descriptor;
 
- 	bool init(Mat& image, const float pixel_size, OutputArray output = noArray());
 
- 	bool findPatternPass(const Mat& image, std::vector<Point2f>& matched_features, std::vector<Point3f>& pattern_points,
 
- 						 Mat& H, std::vector<Point2f>& scene_corners, const double pratio, const double proj_error,
 
- 						 const bool refine_position = false, const Mat& mask = Mat(), OutputArray output = noArray());
 
- 	void scaleFoundPoints(const double squareSize, const std::vector<KeyPoint>& corners, std::vector<Point3f>& pts3d);
 
- 	void check_matches(std::vector<Point2f>& matched, const std::vector<Point2f>& pattern, std::vector<DMatch>& good, std::vector<Point3f>& pattern_3d, const Mat& H);
 
- 	void keypoints2points(const std::vector<KeyPoint>& in, std::vector<Point2f>& out);
 
- 	void updateKeypointsPos(std::vector<KeyPoint>& in, const std::vector<Point2f>& new_pos);
 
- 	void refinePointsPos(const Mat& img, std::vector<Point2f>& p);
 
- 	void refineKeypointsPos(const Mat& img, std::vector<KeyPoint>& kp);
 
- };
 
- }} 
 
- #endif
 
 
  |