Fix binary compatibility of opencv_features2d

This commit is contained in:
Andrey Kamaev
2012-10-15 21:09:24 +04:00
parent 88e9a072ec
commit 5a730d09cd
7 changed files with 52 additions and 18 deletions

View File

@@ -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);
}

View File

@@ -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 );
}

View File

@@ -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

View File

@@ -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();