mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
Fix binary compatibility of opencv_features2d
This commit is contained in:
parent
88e9a072ec
commit
5a730d09cd
@ -566,19 +566,19 @@ protected:
|
||||
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
|
||||
int threshold, bool nonmaxSupression=true );
|
||||
|
||||
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
|
||||
CV_EXPORTS void FASTX( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
|
||||
int threshold, bool nonmaxSupression, int type );
|
||||
|
||||
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
{ // Define it in old class to simplify migration to 2.5
|
||||
TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2
|
||||
};
|
||||
|
||||
CV_WRAP FastFeatureDetector( int threshold=10, bool nonmaxSuppression=true);
|
||||
CV_WRAP FastFeatureDetector( int threshold, bool nonmaxSuppression, int type);
|
||||
CV_WRAP FastFeatureDetector( int threshold=10, bool nonmaxSuppression=true );
|
||||
AlgorithmInfo* info() const;
|
||||
|
||||
protected:
|
||||
@ -586,7 +586,6 @@ protected:
|
||||
|
||||
int threshold;
|
||||
bool nonmaxSuppression;
|
||||
short type;
|
||||
};
|
||||
|
||||
|
||||
|
@ -30,10 +30,13 @@ PERF_TEST_P(fast, detect, testing::Combine(
|
||||
|
||||
declare.in(frame);
|
||||
|
||||
FastFeatureDetector fd(20, true, type);
|
||||
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FASTX");
|
||||
fd->set("threshold", 20);
|
||||
fd->set("nonmaxSuppression", true);
|
||||
fd->set("type", type);
|
||||
vector<KeyPoint> points;
|
||||
|
||||
TEST_CYCLE() fd.detect(frame, points);
|
||||
TEST_CYCLE() fd->detect(frame, points);
|
||||
|
||||
SANITY_CHECK_KEYPOINTS(points);
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ private:
|
||||
float scale_;
|
||||
float offset_;
|
||||
// agast
|
||||
cv::Ptr<cv::FastFeatureDetector> fast_9_16_;
|
||||
cv::Ptr<cv::FastFeatureDetector2> fast_9_16_;
|
||||
int pixel_5_8_[25];
|
||||
int pixel_9_16_[25];
|
||||
};
|
||||
@ -2000,7 +2000,7 @@ BriskLayer::BriskLayer(const cv::Mat& img_in, float scale_in, float offset_in)
|
||||
scale_ = scale_in;
|
||||
offset_ = offset_in;
|
||||
// create an agast detector
|
||||
fast_9_16_ = new FastFeatureDetector(1, true, FastFeatureDetector::TYPE_9_16);
|
||||
fast_9_16_ = new FastFeatureDetector2(1, true, FastFeatureDetector::TYPE_9_16);
|
||||
makeOffsets(pixel_5_8_, (int)img_.step, 8);
|
||||
makeOffsets(pixel_9_16_, (int)img_.step, 16);
|
||||
}
|
||||
@ -2022,7 +2022,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode)
|
||||
offset_ = 0.5f * scale_ - 0.5f;
|
||||
}
|
||||
scores_ = cv::Mat::zeros(img_.rows, img_.cols, CV_8U);
|
||||
fast_9_16_ = new FastFeatureDetector(1, false, FastFeatureDetector::TYPE_9_16);
|
||||
fast_9_16_ = new FastFeatureDetector2(1, false, FastFeatureDetector::TYPE_9_16);
|
||||
makeOffsets(pixel_5_8_, (int)img_.step, 8);
|
||||
makeOffsets(pixel_9_16_, (int)img_.step, 16);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
|
||||
}
|
||||
}
|
||||
|
||||
void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
|
||||
void FASTX(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
|
||||
{
|
||||
switch(type) {
|
||||
case FastFeatureDetector::TYPE_5_8:
|
||||
@ -262,24 +262,37 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
|
||||
|
||||
void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression)
|
||||
{
|
||||
FAST(_img, keypoints, threshold, nonmax_suppression, FastFeatureDetector::TYPE_9_16);
|
||||
FASTX(_img, keypoints, threshold, nonmax_suppression, FastFeatureDetector::TYPE_9_16);
|
||||
}
|
||||
|
||||
/*
|
||||
* FastFeatureDetector
|
||||
*/
|
||||
FastFeatureDetector::FastFeatureDetector( int _threshold, bool _nonmaxSuppression )
|
||||
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type(FastFeatureDetector::TYPE_9_16)
|
||||
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression)
|
||||
{}
|
||||
|
||||
FastFeatureDetector::FastFeatureDetector( int _threshold, bool _nonmaxSuppression, int _type )
|
||||
: threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type)
|
||||
FastFeatureDetector2::FastFeatureDetector2( int _threshold, bool _nonmaxSuppression )
|
||||
: FastFeatureDetector(_threshold, _nonmaxSuppression), type(FastFeatureDetector::TYPE_9_16)
|
||||
{}
|
||||
|
||||
FastFeatureDetector2::FastFeatureDetector2( int _threshold, bool _nonmaxSuppression, int _type )
|
||||
: FastFeatureDetector(_threshold, _nonmaxSuppression), type((short)_type)
|
||||
{}
|
||||
|
||||
void FastFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||
{
|
||||
Mat grayImage = image;
|
||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
||||
FAST( grayImage, keypoints, threshold, nonmaxSuppression, type );
|
||||
FAST( grayImage, keypoints, threshold, nonmaxSuppression );
|
||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||
}
|
||||
|
||||
void FastFeatureDetector2::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
|
||||
{
|
||||
Mat grayImage = image;
|
||||
if( image.type() != CV_8U ) cvtColor( image, grayImage, CV_BGR2GRAY );
|
||||
FASTX( grayImage, keypoints, threshold, nonmaxSuppression, type );
|
||||
KeyPointsFilter::runByPixelsMask( keypoints, mask );
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,19 @@ void makeOffsets(int pixel[25], int row_stride, int patternSize);
|
||||
template<int patternSize>
|
||||
int cornerScore(const uchar* ptr, const int pixel[], int threshold);
|
||||
|
||||
class FastFeatureDetector2 : public FastFeatureDetector
|
||||
{
|
||||
public:
|
||||
CV_WRAP FastFeatureDetector2( int threshold=10, bool nonmaxSuppression=true);
|
||||
CV_WRAP FastFeatureDetector2( int threshold, bool nonmaxSuppression, int type);
|
||||
AlgorithmInfo* info() const;
|
||||
|
||||
protected:
|
||||
virtual void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
|
||||
|
||||
short type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "fast_score.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
@ -68,6 +69,10 @@ CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF",
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST",
|
||||
obj.info()->addParam(obj, "threshold", obj.threshold);
|
||||
obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression));
|
||||
|
||||
CV_INIT_ALGORITHM(FastFeatureDetector2, "Feature2D.FASTX",
|
||||
obj.info()->addParam(obj, "threshold", obj.threshold);
|
||||
obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
|
||||
obj.info()->addParam(obj, "type", obj.type));
|
||||
@ -167,6 +172,7 @@ bool cv::initModule_features2d(void)
|
||||
all &= !BriefDescriptorExtractor_info_auto.name().empty();
|
||||
all &= !BRISK_info_auto.name().empty();
|
||||
all &= !FastFeatureDetector_info_auto.name().empty();
|
||||
all &= !FastFeatureDetector2_info_auto.name().empty();
|
||||
all &= !StarDetector_info_auto.name().empty();
|
||||
all &= !MSER_info_auto.name().empty();
|
||||
all &= !FREAK_info_auto.name().empty();
|
||||
|
@ -75,8 +75,8 @@ void CV_FastTest::run( int )
|
||||
|
||||
vector<KeyPoint> keypoints1;
|
||||
vector<KeyPoint> keypoints2;
|
||||
FAST(gray1, keypoints1, 30, true, type);
|
||||
FAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type);
|
||||
FASTX(gray1, keypoints1, 30, true, type);
|
||||
FASTX(gray2, keypoints2, (type > 0 ? 30 : 20), true, type);
|
||||
|
||||
for(size_t i = 0; i < keypoints1.size(); ++i)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user