Commit 01d3848f authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

all the tests now pass except for MSER

parent 162384a8
...@@ -874,6 +874,9 @@ public: ...@@ -874,6 +874,9 @@ public:
virtual ~Algorithm(); virtual ~Algorithm();
String name() const; String name() const;
virtual void set(int, double);
virtual double get(int) const;
template<typename _Tp> typename ParamType<_Tp>::member_type get(const String& name) const; template<typename _Tp> typename ParamType<_Tp>::member_type get(const String& name) const;
template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const; template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const;
......
...@@ -179,6 +179,9 @@ String Algorithm::name() const ...@@ -179,6 +179,9 @@ String Algorithm::name() const
return info()->name(); return info()->name();
} }
void Algorithm::set(int, double) {}
double Algorithm::get(int) const { return 0.; }
void Algorithm::set(const String& parameter, int value) void Algorithm::set(const String& parameter, int value)
{ {
info()->set(this, parameter.c_str(), ParamType<int>::type, &value); info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
......
...@@ -213,9 +213,10 @@ CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints, ...@@ -213,9 +213,10 @@ CV_EXPORTS void FAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
class CV_EXPORTS_W FastFeatureDetector : public Feature2D class CV_EXPORTS_W FastFeatureDetector : public Feature2D
{ {
public: public:
enum Type enum
{ {
TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2 TYPE_5_8 = 0, TYPE_7_12 = 1, TYPE_9_16 = 2,
THRESHOLD = 10000, NONMAX_SUPPRESSION=10001, FAST_N=10002,
}; };
CV_WRAP static Ptr<FastFeatureDetector> create( int threshold=10, CV_WRAP static Ptr<FastFeatureDetector> create( int threshold=10,
......
...@@ -32,11 +32,8 @@ OCL_PERF_TEST_P(FASTFixture, FastDetect, testing::Combine( ...@@ -32,11 +32,8 @@ OCL_PERF_TEST_P(FASTFixture, FastDetect, testing::Combine(
mframe.copyTo(frame); mframe.copyTo(frame);
declare.in(frame); declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST"); Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
ASSERT_FALSE( fd.empty() ); ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20);
fd->set("nonmaxSuppression", true);
fd->set("type", type);
vector<KeyPoint> points; vector<KeyPoint> points;
OCL_TEST_CYCLE() fd->detect(frame, points); OCL_TEST_CYCLE() fd->detect(frame, points);
......
...@@ -30,11 +30,8 @@ PERF_TEST_P(fast, detect, testing::Combine( ...@@ -30,11 +30,8 @@ PERF_TEST_P(fast, detect, testing::Combine(
declare.in(frame); declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST"); Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
ASSERT_FALSE( fd.empty() ); ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20);
fd->set("nonmaxSuppression", true);
fd->set("type", type);
vector<KeyPoint> points; vector<KeyPoint> points;
TEST_CYCLE() fd->detect(frame, points); TEST_CYCLE() fd->detect(frame, points);
......
...@@ -2099,7 +2099,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode) ...@@ -2099,7 +2099,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode)
void void
BriskLayer::getAgastPoints(int threshold, std::vector<KeyPoint>& keypoints) BriskLayer::getAgastPoints(int threshold, std::vector<KeyPoint>& keypoints)
{ {
fast_9_16_ = FastFeatureDetector::create(threshold); fast_9_16_->set(FastFeatureDetector::THRESHOLD, threshold);
fast_9_16_->detect(img_, keypoints); fast_9_16_->detect(img_, keypoints);
// also write scores // also write scores
......
...@@ -383,6 +383,30 @@ public: ...@@ -383,6 +383,30 @@ public:
KeyPointsFilter::runByPixelsMask( keypoints, mask ); KeyPointsFilter::runByPixelsMask( keypoints, mask );
} }
void set(int prop, double value)
{
if(prop == THRESHOLD)
threshold = cvRound(value);
else if(prop == NONMAX_SUPPRESSION)
nonmaxSuppression = value != 0;
else if(prop == FAST_N)
type = cvRound(value);
else
CV_Error(Error::StsBadArg, "");
}
double get(int prop) const
{
if(prop == THRESHOLD)
return threshold;
if(prop == NONMAX_SUPPRESSION)
return nonmaxSuppression;
if(prop == FAST_N)
return type;
CV_Error(Error::StsBadArg, "");
return 0;
}
int threshold; int threshold;
bool nonmaxSuppression; bool nonmaxSuppression;
int type; int type;
......
...@@ -800,9 +800,12 @@ extractMSER_8uC3( const Mat& src, Mat& labels, ...@@ -800,9 +800,12 @@ extractMSER_8uC3( const Mat& src, Mat& labels,
double emean = 0; double emean = 0;
Mat dx( src.rows, src.cols-1, CV_32FC1 ); Mat dx( src.rows, src.cols-1, CV_32FC1 );
Mat dy( src.rows, src.cols, CV_32FC1 ); Mat dy( src.rows, src.cols, CV_32FC1 );
Ne = preprocessMSER_8UC3( map, edge, emean, src, dx, dy, Ne, params.edgeBlurSize ); Ne = preprocessMSER_8UC3( map, edge, emean, src, dx, dy, Ne, params.edgeBlurSize );
emean = emean / (double)Ne; emean = emean / (double)Ne;
std::sort(edge, edge + Ne, LessThanEdge()); std::sort(edge, edge + Ne, LessThanEdge());
MSCREdge* edge_ub = edge+Ne; MSCREdge* edge_ub = edge+Ne;
MSCREdge* edgeptr = edge; MSCREdge* edgeptr = edge;
TempMSCR* mscrptr = mscr; TempMSCR* mscrptr = mscr;
......
...@@ -106,8 +106,6 @@ public: ...@@ -106,8 +106,6 @@ public:
~CV_DescriptorExtractorTest() ~CV_DescriptorExtractorTest()
{ {
if(!detector.empty())
detector.release();
} }
protected: protected:
virtual void createDescriptorExtractor() {} virtual void createDescriptorExtractor() {}
...@@ -333,7 +331,7 @@ TEST( Features2d_DescriptorExtractor_KAZE, regression ) ...@@ -333,7 +331,7 @@ TEST( Features2d_DescriptorExtractor_KAZE, regression )
{ {
CV_DescriptorExtractorTest< L2<float> > test( "descriptor-kaze", 0.03f, CV_DescriptorExtractorTest< L2<float> > test( "descriptor-kaze", 0.03f,
KAZE::create(), KAZE::create(),
L2<float>() ); L2<float>(), KAZE::create() );
test.safe_run(); test.safe_run();
} }
......
This diff is collapsed.
...@@ -533,13 +533,13 @@ void CV_DescriptorMatcherTest::run( int ) ...@@ -533,13 +533,13 @@ void CV_DescriptorMatcherTest::run( int )
TEST( Features2d_DescriptorMatcher_BruteForce, regression ) TEST( Features2d_DescriptorMatcher_BruteForce, regression )
{ {
CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force",
DescriptorMatcher::create("BFMatcher"), 0.01f ); DescriptorMatcher::create("BruteForce"), 0.01f );
test.safe_run(); test.safe_run();
} }
TEST( Features2d_DescriptorMatcher_FlannBased, regression ) TEST( Features2d_DescriptorMatcher_FlannBased, regression )
{ {
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based",
DescriptorMatcher::create("FlannBasedMatcher"), 0.04f ); DescriptorMatcher::create("FlannBased"), 0.04f );
test.safe_run(); test.safe_run();
} }
...@@ -595,7 +595,7 @@ protected: ...@@ -595,7 +595,7 @@ protected:
TEST(Features2d_RotationInvariance_Detector_BRISK, regression) TEST(Features2d_RotationInvariance_Detector_BRISK, regression)
{ {
DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.BRISK"), DetectorRotationInvarianceTest test(BRISK::create(),
0.32f, 0.32f,
0.76f); 0.76f);
test.safe_run(); test.safe_run();
...@@ -603,7 +603,7 @@ TEST(Features2d_RotationInvariance_Detector_BRISK, regression) ...@@ -603,7 +603,7 @@ TEST(Features2d_RotationInvariance_Detector_BRISK, regression)
TEST(Features2d_RotationInvariance_Detector_ORB, regression) TEST(Features2d_RotationInvariance_Detector_ORB, regression)
{ {
DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.ORB"), DetectorRotationInvarianceTest test(ORB::create(),
0.47f, 0.47f,
0.76f); 0.76f);
test.safe_run(); test.safe_run();
......
...@@ -321,7 +321,7 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int ...@@ -321,7 +321,7 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int
{ {
if (num_octaves_descr == num_octaves && num_layers_descr == num_layers) if (num_octaves_descr == num_octaves && num_layers_descr == num_layers)
{ {
surf = Algorithm::create<Feature2D>("Feature2D.SURF"); surf = xfeatures2d::SURF::create();
if( !surf ) if( !surf )
CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" );
surf->set("hessianThreshold", hess_thresh); surf->set("hessianThreshold", hess_thresh);
...@@ -330,8 +330,8 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int ...@@ -330,8 +330,8 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int
} }
else else
{ {
detector_ = Algorithm::create<FeatureDetector>("Feature2D.SURF"); detector_ = xfeatures2d::SURF::create();
extractor_ = Algorithm::create<DescriptorExtractor>("Feature2D.SURF"); extractor_ = xfeatures2d::SURF::create();
if( !detector_ || !extractor_ ) if( !detector_ || !extractor_ )
CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment