#include "opencv2/opencv.hpp"
#include "opencv2/xfeatures2d.hpp"
-
+
using namespace cv::xfeatures2d;
...
- initModule_nonfree(); // to load SURF/SIFT etc.
-
Ptr<Feature2D> sift = SIFT::create();
FileStorage fs("sift_params.xml", FileStorage::READ);
}
else // else modify the parameters and store them; user can later edit the file to use different parameters
{
- sift->set("contrastThreshold", 0.01f); // lower the contrast threshold, compared to the default value
+ sift->setContrastThreshold(0.01f); // lower the contrast threshold, compared to the default value
{
WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);
Mat image = imread("myimage.png", 0), descriptors;
vector<KeyPoint> keypoints;
- (*sift)(image, noArray(), keypoints, descriptors);
+ sift->detectAndCompute(image, noArray(), keypoints, descriptors);
Algorithm::name
---------------
Ptr<DescriptorExtractor> wrapped;
};
-class CV_EXPORTS_AS(GenericDescriptorMatcher) javaGenericDescriptorMatcher
-{
-public:
- CV_WRAP void add( const std::vector<Mat>& images,
- std::vector<std::vector<KeyPoint> >& keypoints )
- { return wrapped->add(images, keypoints); }
-
- CV_WRAP const std::vector<Mat>& getTrainImages() const
- { return wrapped->getTrainImages(); }
-
- CV_WRAP const std::vector<std::vector<KeyPoint> >& getTrainKeypoints() const
- { return wrapped->getTrainKeypoints(); }
-
- CV_WRAP void clear()
- { return wrapped->clear(); }
-
- CV_WRAP bool isMaskSupported()
- { return wrapped->isMaskSupported(); }
-
- CV_WRAP void train()
- { return wrapped->train(); }
-
- CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector<KeyPoint>& queryKeypoints,
- const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints ) const
- { return wrapped->classify(queryImage, queryKeypoints, trainImage, trainKeypoints); }
-
- CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector<KeyPoint>& queryKeypoints )
- { return wrapped->classify(queryImage, queryKeypoints); }
-
- CV_WRAP void match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
- CV_OUT std::vector<DMatch>& matches, const Mat& mask=Mat() ) const
- { return wrapped->match(queryImage, queryKeypoints, trainImage, trainKeypoints, matches, mask); }
-
- CV_WRAP void knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
- CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
- const Mat& mask=Mat(), bool compactResult=false ) const
- { return wrapped->knnMatch(queryImage, queryKeypoints, trainImage, trainKeypoints,
- matches, k, mask, compactResult); }
-
- CV_WRAP void radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- const Mat& trainImage, std::vector<KeyPoint>& trainKeypoints,
- CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
- const Mat& mask=Mat(), bool compactResult=false ) const
- { return wrapped->radiusMatch(queryImage, queryKeypoints, trainImage, trainKeypoints,
- matches, maxDistance, mask, compactResult); }
-
- CV_WRAP void match( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- CV_OUT std::vector<DMatch>& matches, const std::vector<Mat>& masks=std::vector<Mat>() )
- { return wrapped->match(queryImage, queryKeypoints, matches, masks); }
-
- CV_WRAP void knnMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
- const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false )
- { return wrapped->knnMatch(queryImage, queryKeypoints, matches, k, masks, compactResult); }
-
- CV_WRAP void radiusMatch( const Mat& queryImage, std::vector<KeyPoint>& queryKeypoints,
- CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
- const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false )
- { return wrapped->radiusMatch(queryImage, queryKeypoints, matches, maxDistance, masks, compactResult); }
-
- CV_WRAP bool empty() const
- { return wrapped->empty(); }
-
-
- enum
- {
- ONEWAY = 1,
- FERN = 2
- };
-
- CV_WRAP_AS(clone) javaGenericDescriptorMatcher* jclone( bool emptyTrainData=false ) const
- {
- return new javaGenericDescriptorMatcher(wrapped->clone(emptyTrainData));
- }
-
- //supported: OneWay, Fern
- //unsupported: Vector
- CV_WRAP static javaGenericDescriptorMatcher* create( int matcherType )
- {
- String name;
-
- switch(matcherType)
- {
- case ONEWAY:
- name = "ONEWAY";
- break;
- case FERN:
- name = "FERN";
- break;
- default:
- CV_Error( Error::StsBadArg, "Specified generic descriptor matcher type is not supported." );
- break;
- }
-
- return new javaGenericDescriptorMatcher(GenericDescriptorMatcher::create(name));
- }
-
- CV_WRAP void write( const String& fileName ) const
- {
- FileStorage fs(fileName, FileStorage::WRITE);
- wrapped->write(fs);
- }
-
- CV_WRAP void read( const String& fileName )
- {
- FileStorage fs(fileName, FileStorage::READ);
- wrapped->read(fs.root());
- }
-
-private:
- javaGenericDescriptorMatcher(Ptr<GenericDescriptorMatcher> _wrapped) : wrapped(_wrapped)
- {}
-
- Ptr<GenericDescriptorMatcher> wrapped;
-};
-
#if 0
//DO NOT REMOVE! The block is required for sources parser
enum