mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
parent
dd379ec9fd
commit
be028d0774
@ -771,6 +771,15 @@ an image set.
|
||||
class CV_EXPORTS_W DescriptorMatcher : public Algorithm
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
FLANNBASED = 1,
|
||||
BRUTEFORCE = 2,
|
||||
BRUTEFORCE_L1 = 3,
|
||||
BRUTEFORCE_HAMMING = 4,
|
||||
BRUTEFORCE_HAMMINGLUT = 5,
|
||||
BRUTEFORCE_SL2 = 6
|
||||
};
|
||||
virtual ~DescriptorMatcher();
|
||||
|
||||
/** @brief Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor
|
||||
@ -868,7 +877,7 @@ public:
|
||||
query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are
|
||||
returned in the distance increasing order.
|
||||
*/
|
||||
void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors,
|
||||
CV_WRAP void radiusMatch( InputArray queryDescriptors, InputArray trainDescriptors,
|
||||
std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
InputArray mask=noArray(), bool compactResult=false ) const;
|
||||
|
||||
@ -909,6 +918,18 @@ public:
|
||||
void radiusMatch( InputArray queryDescriptors, std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
InputArrayOfArrays masks=noArray(), bool compactResult=false );
|
||||
|
||||
|
||||
CV_WRAP void write( const String& fileName ) const
|
||||
{
|
||||
FileStorage fs(fileName, FileStorage::WRITE);
|
||||
write(fs);
|
||||
}
|
||||
|
||||
CV_WRAP void read( const String& fileName )
|
||||
{
|
||||
FileStorage fs(fileName, FileStorage::READ);
|
||||
read(fs.root());
|
||||
}
|
||||
// Reads matcher object from a file node
|
||||
virtual void read( const FileNode& );
|
||||
// Writes matcher object to a file storage
|
||||
@ -920,7 +941,7 @@ public:
|
||||
that is, copies both parameters and train data. If emptyTrainData is true, the method creates an
|
||||
object copy with the current parameters but with empty train data.
|
||||
*/
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||
CV_WRAP virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const = 0;
|
||||
|
||||
/** @brief Creates a descriptor matcher of a given type with the default parameters (using default
|
||||
constructor).
|
||||
@ -934,6 +955,9 @@ public:
|
||||
- `FlannBased`
|
||||
*/
|
||||
CV_WRAP static Ptr<DescriptorMatcher> create( const String& descriptorMatcherType );
|
||||
|
||||
CV_WRAP static Ptr<DescriptorMatcher> create( int matcherType );
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Class to work with descriptors from several images as with one merged matrix.
|
||||
@ -990,8 +1014,17 @@ sets.
|
||||
class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
/** @brief Brute-force matcher constructor.
|
||||
/** @brief Brute-force matcher constructor (obsolete). Please use BFMatcher.create()
|
||||
*
|
||||
*
|
||||
*/
|
||||
CV_WRAP BFMatcher( int _normType=NORM_L2, bool _crossCheck=false );
|
||||
|
||||
virtual ~BFMatcher() {}
|
||||
|
||||
virtual bool isMaskSupported() const { return true; }
|
||||
|
||||
/* @brief Brute-force matcher create method.
|
||||
@param normType One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are
|
||||
preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and
|
||||
BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor
|
||||
@ -1002,12 +1035,9 @@ public:
|
||||
matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent
|
||||
pairs. Such technique usually produces best results with minimal number of outliers when there are
|
||||
enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
|
||||
*/
|
||||
CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
|
||||
virtual ~BFMatcher() {}
|
||||
|
||||
virtual bool isMaskSupported() const { return true; }
|
||||
|
||||
*/
|
||||
CV_WRAP static Ptr<BFMatcher> create( int _normType=NORM_L2, bool _crossCheck=false ) ;
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
protected:
|
||||
virtual void knnMatchImpl( InputArray queryDescriptors, std::vector<std::vector<DMatch> >& matches, int k,
|
||||
@ -1030,7 +1060,7 @@ matches of descriptor sets because flann::Index does not support this. :
|
||||
class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=makePtr<flann::KDTreeIndexParams>(),
|
||||
FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=makePtr<flann::KDTreeIndexParams>(),
|
||||
const Ptr<flann::SearchParams>& searchParams=makePtr<flann::SearchParams>() );
|
||||
|
||||
virtual void add( InputArrayOfArrays descriptors );
|
||||
@ -1044,6 +1074,8 @@ public:
|
||||
virtual void train();
|
||||
virtual bool isMaskSupported() const;
|
||||
|
||||
CV_WRAP static Ptr<FlannBasedMatcher> create();
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
protected:
|
||||
static void convertToDMatches( const DescriptorCollection& descriptors,
|
||||
|
@ -178,120 +178,6 @@ private:
|
||||
Ptr<FeatureDetector> wrapped;
|
||||
};
|
||||
|
||||
class CV_EXPORTS_AS(DescriptorMatcher) javaDescriptorMatcher
|
||||
{
|
||||
public:
|
||||
CV_WRAP bool isMaskSupported() const
|
||||
{ return wrapped->isMaskSupported(); }
|
||||
|
||||
CV_WRAP void add( const std::vector<Mat>& descriptors )
|
||||
{ return wrapped->add(descriptors); }
|
||||
|
||||
CV_WRAP const std::vector<Mat>& getTrainDescriptors() const
|
||||
{ return wrapped->getTrainDescriptors(); }
|
||||
|
||||
CV_WRAP void clear()
|
||||
{ return wrapped->clear(); }
|
||||
|
||||
CV_WRAP bool empty() const
|
||||
{ return wrapped->empty(); }
|
||||
|
||||
CV_WRAP void train()
|
||||
{ return wrapped->train(); }
|
||||
|
||||
CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||
CV_OUT std::vector<DMatch>& matches, const Mat& mask=Mat() ) const
|
||||
{ return wrapped->match(queryDescriptors, trainDescriptors, matches, mask); }
|
||||
|
||||
CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||
CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
|
||||
const Mat& mask=Mat(), bool compactResult=false ) const
|
||||
{ return wrapped->knnMatch(queryDescriptors, trainDescriptors, matches, k, mask, compactResult); }
|
||||
|
||||
CV_WRAP void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors,
|
||||
CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
const Mat& mask=Mat(), bool compactResult=false ) const
|
||||
{ return wrapped->radiusMatch(queryDescriptors, trainDescriptors, matches, maxDistance, mask, compactResult); }
|
||||
|
||||
CV_WRAP void match( const Mat& queryDescriptors, CV_OUT std::vector<DMatch>& matches,
|
||||
const std::vector<Mat>& masks=std::vector<Mat>() )
|
||||
{ return wrapped->match(queryDescriptors, matches, masks); }
|
||||
|
||||
CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT std::vector<std::vector<DMatch> >& matches, int k,
|
||||
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false )
|
||||
{ return wrapped->knnMatch(queryDescriptors, matches, k, masks, compactResult); }
|
||||
|
||||
CV_WRAP void radiusMatch( const Mat& queryDescriptors, CV_OUT std::vector<std::vector<DMatch> >& matches, float maxDistance,
|
||||
const std::vector<Mat>& masks=std::vector<Mat>(), bool compactResult=false )
|
||||
{ return wrapped->radiusMatch(queryDescriptors, matches, maxDistance, masks, compactResult); }
|
||||
|
||||
enum
|
||||
{
|
||||
FLANNBASED = 1,
|
||||
BRUTEFORCE = 2,
|
||||
BRUTEFORCE_L1 = 3,
|
||||
BRUTEFORCE_HAMMING = 4,
|
||||
BRUTEFORCE_HAMMINGLUT = 5,
|
||||
BRUTEFORCE_SL2 = 6
|
||||
};
|
||||
|
||||
CV_WRAP_AS(clone) javaDescriptorMatcher* jclone( bool emptyTrainData=false ) const
|
||||
{
|
||||
return new javaDescriptorMatcher(wrapped->clone(emptyTrainData));
|
||||
}
|
||||
|
||||
//supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT
|
||||
CV_WRAP static javaDescriptorMatcher* create( int matcherType )
|
||||
{
|
||||
String name;
|
||||
|
||||
switch(matcherType)
|
||||
{
|
||||
case FLANNBASED:
|
||||
name = "FlannBased";
|
||||
break;
|
||||
case BRUTEFORCE:
|
||||
name = "BruteForce";
|
||||
break;
|
||||
case BRUTEFORCE_L1:
|
||||
name = "BruteForce-L1";
|
||||
break;
|
||||
case BRUTEFORCE_HAMMING:
|
||||
name = "BruteForce-Hamming";
|
||||
break;
|
||||
case BRUTEFORCE_HAMMINGLUT:
|
||||
name = "BruteForce-HammingLUT";
|
||||
break;
|
||||
case BRUTEFORCE_SL2:
|
||||
name = "BruteForce-SL2";
|
||||
break;
|
||||
default:
|
||||
CV_Error( Error::StsBadArg, "Specified descriptor matcher type is not supported." );
|
||||
break;
|
||||
}
|
||||
|
||||
return new javaDescriptorMatcher(DescriptorMatcher::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:
|
||||
javaDescriptorMatcher(Ptr<DescriptorMatcher> _wrapped) : wrapped(_wrapped)
|
||||
{}
|
||||
|
||||
Ptr<DescriptorMatcher> wrapped;
|
||||
};
|
||||
|
||||
class CV_EXPORTS_AS(DescriptorExtractor) javaDescriptorExtractor
|
||||
{
|
||||
public:
|
||||
|
@ -696,6 +696,11 @@ BFMatcher::BFMatcher( int _normType, bool _crossCheck )
|
||||
crossCheck = _crossCheck;
|
||||
}
|
||||
|
||||
Ptr<BFMatcher> BFMatcher::create(int _normType, bool _crossCheck )
|
||||
{
|
||||
return makePtr<BFMatcher>(_normType, _crossCheck);
|
||||
}
|
||||
|
||||
Ptr<DescriptorMatcher> BFMatcher::clone( bool emptyTrainData ) const
|
||||
{
|
||||
Ptr<BFMatcher> matcher = makePtr<BFMatcher>(normType, crossCheck);
|
||||
@ -1031,6 +1036,41 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatche
|
||||
return dm;
|
||||
}
|
||||
|
||||
Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
|
||||
{
|
||||
|
||||
|
||||
String name;
|
||||
|
||||
switch(matcherType)
|
||||
{
|
||||
case FLANNBASED:
|
||||
name = "FlannBased";
|
||||
break;
|
||||
case BRUTEFORCE:
|
||||
name = "BruteForce";
|
||||
break;
|
||||
case BRUTEFORCE_L1:
|
||||
name = "BruteForce-L1";
|
||||
break;
|
||||
case BRUTEFORCE_HAMMING:
|
||||
name = "BruteForce-Hamming";
|
||||
break;
|
||||
case BRUTEFORCE_HAMMINGLUT:
|
||||
name = "BruteForce-HammingLUT";
|
||||
break;
|
||||
case BRUTEFORCE_SL2:
|
||||
name = "BruteForce-SL2";
|
||||
break;
|
||||
default:
|
||||
CV_Error( Error::StsBadArg, "Specified descriptor matcher type is not supported." );
|
||||
break;
|
||||
}
|
||||
|
||||
return DescriptorMatcher::create(name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Flann based matcher
|
||||
@ -1042,6 +1082,11 @@ FlannBasedMatcher::FlannBasedMatcher( const Ptr<flann::IndexParams>& _indexParam
|
||||
CV_Assert( _searchParams );
|
||||
}
|
||||
|
||||
Ptr<FlannBasedMatcher> FlannBasedMatcher::create()
|
||||
{
|
||||
return makePtr<FlannBasedMatcher>();
|
||||
}
|
||||
|
||||
void FlannBasedMatcher::add( InputArrayOfArrays _descriptors )
|
||||
{
|
||||
DescriptorMatcher::add( _descriptors );
|
||||
|
@ -14,7 +14,7 @@ class_ignore_list = (
|
||||
#core
|
||||
"FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
|
||||
#features2d
|
||||
"SimpleBlobDetector", "FlannBasedMatcher", "DescriptorMatcher"
|
||||
"SimpleBlobDetector"
|
||||
)
|
||||
|
||||
const_ignore_list = (
|
||||
|
Loading…
Reference in New Issue
Block a user