minor changes
This commit is contained in:
parent
7bda826671
commit
4a43041309
@ -1388,10 +1388,20 @@ protected:
|
||||
class CV_EXPORTS GridAdaptedFeatureDetector : public FeatureDetector
|
||||
{
|
||||
public:
|
||||
GridAdaptedFeatureDetector( const Ptr<FeatureDetector>& _detector, int _maxTotalKeypoints,
|
||||
int _gridRows=4, int _gridCols=4 );
|
||||
/*
|
||||
* detector Detector that will be adapted.
|
||||
* maxTotalKeypoints Maximum count of keypoints detected on the image. Only the strongest keypoints
|
||||
* will be keeped.
|
||||
* gridRows Grid rows count.
|
||||
* gridCols Grid column count.
|
||||
*/
|
||||
GridAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector, int maxTotalKeypoints,
|
||||
int gridRows=4, int gridCols=4 );
|
||||
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||
|
||||
// todo read/write
|
||||
virtual void read( const FileNode& fn ) {}
|
||||
virtual void write( FileStorage& fs ) const {}
|
||||
|
||||
protected:
|
||||
Ptr<FeatureDetector> detector;
|
||||
@ -1407,9 +1417,12 @@ protected:
|
||||
class PyramidAdaptedFeatureDetector : public FeatureDetector
|
||||
{
|
||||
public:
|
||||
PyramidAdaptedFeatureDetector( const Ptr<FeatureDetector>& _detector, int _levels=2 );
|
||||
PyramidAdaptedFeatureDetector( const Ptr<FeatureDetector>& detector, int levels=2 );
|
||||
virtual void detect( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||
|
||||
// todo read/write
|
||||
virtual void read( const FileNode& fn ) {}
|
||||
virtual void write( FileStorage& fs ) const {}
|
||||
|
||||
protected:
|
||||
Ptr<FeatureDetector> detector;
|
||||
@ -1788,13 +1801,61 @@ protected:
|
||||
};
|
||||
|
||||
/*
|
||||
* Next two functions are used to implement BruteForceMatcher class specialization
|
||||
* Brute-force descriptor matcher.
|
||||
*
|
||||
* For each descriptor in the first set, this matcher finds the closest
|
||||
* descriptor in the second set by trying each one.
|
||||
*
|
||||
* For efficiency, BruteForceMatcher is templated on the distance metric.
|
||||
* For float descriptors, a common choice would be cv::L2<float>.
|
||||
*/
|
||||
template<class Distance>
|
||||
class BruteForceMatcher;
|
||||
class CV_EXPORTS BruteForceMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
BruteForceMatcher( Distance d = Distance() ) : distance(d) {}
|
||||
virtual ~BruteForceMatcher() {}
|
||||
|
||||
virtual void train() {}
|
||||
virtual bool supportMask() { return true; }
|
||||
|
||||
protected:
|
||||
virtual Ptr<DescriptorMatcher> cloneWithoutData() const { return new BruteForceMatcher(distance); }
|
||||
|
||||
virtual void knnMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
virtual void radiusMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
Distance distance;
|
||||
|
||||
private:
|
||||
/*
|
||||
* Next two methods are used to implement specialization
|
||||
*/
|
||||
static void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
static void bfRadiusMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
};
|
||||
|
||||
template<class Distance>
|
||||
inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
void BruteForceMatcher<Distance>::knnMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
bfKnnMatchImpl( *this, queryDescs, matches, knn, masks, compactResult );
|
||||
}
|
||||
|
||||
template<class Distance>
|
||||
void BruteForceMatcher<Distance>::radiusMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
bfRadiusMatchImpl( *this, queryDescs, matches, maxDistance, masks, compactResult );
|
||||
}
|
||||
|
||||
template<class Distance>
|
||||
inline void BruteForceMatcher<Distance>::bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
@ -1869,7 +1930,7 @@ inline void bfKnnMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
}
|
||||
|
||||
template<class Distance>
|
||||
inline void bfRadiusMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
inline void BruteForceMatcher<Distance>::bfRadiusMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
@ -1920,58 +1981,6 @@ inline void bfRadiusMatchImpl( BruteForceMatcher<Distance>& matcher,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Brute-force descriptor matcher.
|
||||
*
|
||||
* For each descriptor in the first set, this matcher finds the closest
|
||||
* descriptor in the second set by trying each one.
|
||||
*
|
||||
* For efficiency, BruteForceMatcher is templated on the distance metric.
|
||||
* For float descriptors, a common choice would be cv::L2<float>.
|
||||
*/
|
||||
template<class Distance>
|
||||
class CV_EXPORTS BruteForceMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
template<class bfDistance>
|
||||
friend void bfKnnMatchImpl( BruteForceMatcher<bfDistance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
template<class bfDistance>
|
||||
friend void bfRadiusMatchImpl( BruteForceMatcher<bfDistance>& matcher,
|
||||
const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
|
||||
BruteForceMatcher( Distance d = Distance() ) : distance(d) {}
|
||||
virtual ~BruteForceMatcher() {}
|
||||
|
||||
virtual void train() {}
|
||||
virtual bool supportMask() { return true; }
|
||||
|
||||
protected:
|
||||
virtual Ptr<DescriptorMatcher> cloneWithoutData() const { return new BruteForceMatcher(distance); }
|
||||
|
||||
virtual void knnMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
virtual void radiusMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult );
|
||||
Distance distance;
|
||||
};
|
||||
|
||||
template<class Distance>
|
||||
void BruteForceMatcher<Distance>::knnMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, int knn,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
bfKnnMatchImpl<Distance>( *this, queryDescs, matches, knn, masks, compactResult );
|
||||
}
|
||||
|
||||
template<class Distance>
|
||||
void BruteForceMatcher<Distance>::radiusMatchImpl( const Mat& queryDescs, vector<vector<DMatch> >& matches, float maxDistance,
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
bfRadiusMatchImpl<Distance>( *this, queryDescs, matches, maxDistance, masks, compactResult );
|
||||
}
|
||||
|
||||
/*
|
||||
* BruteForceMatcher L2 specialization
|
||||
*/
|
||||
|
@ -425,7 +425,7 @@ void GridAdaptedFeatureDetector::detect( const Mat& image, vector<KeyPoint>& key
|
||||
}
|
||||
|
||||
/*
|
||||
* GridAdaptedFeatureDetector
|
||||
* PyramidAdaptedFeatureDetector
|
||||
*/
|
||||
PyramidAdaptedFeatureDetector::PyramidAdaptedFeatureDetector( const Ptr<FeatureDetector>& _detector, int _levels )
|
||||
: detector(_detector), levels(_levels)
|
||||
|
@ -231,7 +231,7 @@ void BruteForceMatcher<L2<float> >::knnMatchImpl( const Mat& queryDescs, vector<
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
#ifndef HAVE_EIGEN2
|
||||
bfKnnMatchImpl<L2<float> >( *this, queryDescs, matches, knn, masks, compactResult );
|
||||
bfKnnMatchImpl( *this, queryDescs, matches, knn, masks, compactResult );
|
||||
#else
|
||||
CV_Assert( queryDescs.type() == CV_32FC1 || queryDescs.empty() );
|
||||
CV_Assert( masks.empty() || masks.size() == trainDescCollection.size() );
|
||||
@ -319,7 +319,7 @@ void BruteForceMatcher<L2<float> >::radiusMatchImpl( const Mat& queryDescs, vect
|
||||
const vector<Mat>& masks, bool compactResult )
|
||||
{
|
||||
#ifndef HAVE_EIGEN2
|
||||
bfRadiusMatchImpl<L2<float> >( *this, queryDescs, matches, maxDistance, masks, compactResult );
|
||||
bfRadiusMatchImpl( *this, queryDescs, matches, maxDistance, masks, compactResult );
|
||||
#else
|
||||
CV_Assert( queryDescs.type() == CV_32FC1 || queryDescs.empty() );
|
||||
CV_Assert( masks.empty() || masks.size() == trainDescCollection.size() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user