123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #ifndef __OPENCV_RANDOMPATTERN_HPP__
- #define __OPENCV_RANDOMPATTERN_HPP__
- #include "opencv2/features2d.hpp"
- #include "opencv2/highgui.hpp"
- namespace cv { namespace randpattern {
- class CV_EXPORTS RandomPatternCornerFinder
- {
- public:
-
- RandomPatternCornerFinder(float patternWidth, float patternHeight,
- int nminiMatch = 20, int depth = CV_32F, int verbose = 0, int showExtraction = 0,
- Ptr<FeatureDetector> detector = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.005f),
- Ptr<DescriptorExtractor> descriptor = AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0, 3, 0.005f),
- Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-L1"));
-
- void loadPattern(cv::Mat patternImage);
-
- void computeObjectImagePoints(std::vector<cv::Mat> inputImages);
-
-
- std::vector<cv::Mat> computeObjectImagePointsForSingle(cv::Mat inputImage);
-
- std::vector<cv::Mat> getObjectPoints();
-
- std::vector<cv::Mat> getImagePoints();
- private:
- std::vector<cv::Mat> _objectPonits, _imagePoints;
- float _patternWidth, _patternHeight;
- cv::Size _patternImageSize;
- int _nminiMatch;
- int _depth;
- int _verbose;
- Ptr<FeatureDetector> _detector;
- Ptr<DescriptorExtractor> _descriptor;
- Ptr<DescriptorMatcher> _matcher;
- Mat _descriptorPattern;
- std::vector<cv::KeyPoint> _keypointsPattern;
- Mat _patternImage;
- int _showExtraction;
- void keyPoints2MatchedLocation(const std::vector<cv::KeyPoint>& imageKeypoints,
- const std::vector<cv::KeyPoint>& patternKeypoints, const std::vector<cv::DMatch> matchces,
- cv::Mat& matchedImagelocation, cv::Mat& matchedPatternLocation);
- void getFilteredLocation(cv::Mat& imageKeypoints, cv::Mat& patternKeypoints, const cv::Mat mask);
- void getObjectImagePoints(const cv::Mat& imageKeypoints, const cv::Mat& patternKeypoints);
- void crossCheckMatching( cv::Ptr<DescriptorMatcher>& descriptorMatcher,
- const Mat& descriptors1, const Mat& descriptors2,
- std::vector<DMatch>& filteredMatches12, int knn=1 );
- void drawCorrespondence(const Mat& image1, const std::vector<cv::KeyPoint> keypoint1,
- const Mat& image2, const std::vector<cv::KeyPoint> keypoint2, const std::vector<cv::DMatch> matchces,
- const Mat& mask1, const Mat& mask2, const int step);
- };
- class CV_EXPORTS RandomPatternGenerator
- {
- public:
-
- RandomPatternGenerator(int imageWidth, int imageHeight);
-
- void generatePattern();
-
- cv::Mat getPattern();
- private:
- cv::Mat _pattern;
- int _imageWidth, _imageHeight;
- };
- }}
- #endif
|