提交 01d3848f 编写于 作者: V Vadim Pisarevsky

all the tests now pass except for MSER

上级 162384a8
......@@ -874,6 +874,9 @@ public:
virtual ~Algorithm();
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 char* name) const;
......
......@@ -179,6 +179,9 @@ String Algorithm::name() const
return info()->name();
}
void Algorithm::set(int, double) {}
double Algorithm::get(int) const { return 0.; }
void Algorithm::set(const String& parameter, int 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,
class CV_EXPORTS_W FastFeatureDetector : public Feature2D
{
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,
......
......@@ -32,11 +32,8 @@ OCL_PERF_TEST_P(FASTFixture, FastDetect, testing::Combine(
mframe.copyTo(frame);
declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST");
Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20);
fd->set("nonmaxSuppression", true);
fd->set("type", type);
vector<KeyPoint> points;
OCL_TEST_CYCLE() fd->detect(frame, points);
......
......@@ -30,11 +30,8 @@ PERF_TEST_P(fast, detect, testing::Combine(
declare.in(frame);
Ptr<FeatureDetector> fd = Algorithm::create<FeatureDetector>("Feature2D.FAST");
Ptr<FeatureDetector> fd = FastFeatureDetector::create(20, true, type);
ASSERT_FALSE( fd.empty() );
fd->set("threshold", 20);
fd->set("nonmaxSuppression", true);
fd->set("type", type);
vector<KeyPoint> points;
TEST_CYCLE() fd->detect(frame, points);
......
......@@ -2099,7 +2099,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode)
void
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);
// also write scores
......
......@@ -383,6 +383,30 @@ public:
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;
bool nonmaxSuppression;
int type;
......
......@@ -800,9 +800,12 @@ extractMSER_8uC3( const Mat& src, Mat& labels,
double emean = 0;
Mat dx( src.rows, src.cols-1, CV_32FC1 );
Mat dy( src.rows, src.cols, CV_32FC1 );
Ne = preprocessMSER_8UC3( map, edge, emean, src, dx, dy, Ne, params.edgeBlurSize );
emean = emean / (double)Ne;
std::sort(edge, edge + Ne, LessThanEdge());
MSCREdge* edge_ub = edge+Ne;
MSCREdge* edgeptr = edge;
TempMSCR* mscrptr = mscr;
......
......@@ -106,8 +106,6 @@ public:
~CV_DescriptorExtractorTest()
{
if(!detector.empty())
detector.release();
}
protected:
virtual void createDescriptorExtractor() {}
......@@ -333,7 +331,7 @@ TEST( Features2d_DescriptorExtractor_KAZE, regression )
{
CV_DescriptorExtractorTest< L2<float> > test( "descriptor-kaze", 0.03f,
KAZE::create(),
L2<float>() );
L2<float>(), KAZE::create() );
test.safe_run();
}
......
......@@ -533,13 +533,13 @@ void CV_DescriptorMatcherTest::run( int )
TEST( Features2d_DescriptorMatcher_BruteForce, regression )
{
CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force",
DescriptorMatcher::create("BFMatcher"), 0.01f );
DescriptorMatcher::create("BruteForce"), 0.01f );
test.safe_run();
}
TEST( Features2d_DescriptorMatcher_FlannBased, regression )
{
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based",
DescriptorMatcher::create("FlannBasedMatcher"), 0.04f );
DescriptorMatcher::create("FlannBased"), 0.04f );
test.safe_run();
}
......@@ -595,7 +595,7 @@ protected:
TEST(Features2d_RotationInvariance_Detector_BRISK, regression)
{
DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.BRISK"),
DetectorRotationInvarianceTest test(BRISK::create(),
0.32f,
0.76f);
test.safe_run();
......@@ -603,7 +603,7 @@ TEST(Features2d_RotationInvariance_Detector_BRISK, regression)
TEST(Features2d_RotationInvariance_Detector_ORB, regression)
{
DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.ORB"),
DetectorRotationInvarianceTest test(ORB::create(),
0.47f,
0.76f);
test.safe_run();
......
......@@ -321,7 +321,7 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int
{
if (num_octaves_descr == num_octaves && num_layers_descr == num_layers)
{
surf = Algorithm::create<Feature2D>("Feature2D.SURF");
surf = xfeatures2d::SURF::create();
if( !surf )
CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" );
surf->set("hessianThreshold", hess_thresh);
......@@ -330,8 +330,8 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int
}
else
{
detector_ = Algorithm::create<FeatureDetector>("Feature2D.SURF");
extractor_ = Algorithm::create<DescriptorExtractor>("Feature2D.SURF");
detector_ = xfeatures2d::SURF::create();
extractor_ = xfeatures2d::SURF::create();
if( !detector_ || !extractor_ )
CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册