Commit 640408eb authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

added FAST<5/8> & FAST<7/12> (by Vincent Rabaud)

parent b43cec33
...@@ -473,12 +473,18 @@ protected: ...@@ -473,12 +473,18 @@ protected:
//! detects corners using FAST algorithm by E. Rosten //! detects corners using FAST algorithm by E. Rosten
CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints, CV_EXPORTS void FAST( InputArray image, CV_OUT vector<KeyPoint>& keypoints,
int threshold, bool nonmaxSupression=true ); int threshold, bool nonmaxSupression=true, int type = 2 );
class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector class CV_EXPORTS_W FastFeatureDetector : public FeatureDetector
{ {
public: public:
CV_WRAP FastFeatureDetector( int threshold=10, bool nonmaxSuppression=true ); enum
{
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);
AlgorithmInfo* info() const; AlgorithmInfo* info() const;
protected: protected:
...@@ -486,6 +492,7 @@ protected: ...@@ -486,6 +492,7 @@ protected:
int threshold; int threshold;
bool nonmaxSuppression; bool nonmaxSuppression;
int type;
}; };
......
...@@ -22,9 +22,13 @@ PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES)) ...@@ -22,9 +22,13 @@ PERF_TEST_P(fast, detectForORB, testing::Values(FAST_IMAGES))
declare.in(frame); declare.in(frame);
FastFeatureDetector fd(20, true); FastFeatureDetector fd(20, true, FastFeatureDetector::TYPE_5_8);
vector<KeyPoint> points; vector<KeyPoint> points;
TEST_CYCLE() fd.detect(frame, points); TEST_CYCLE() fd.detect(frame, points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_7_12);
TEST_CYCLE() fd.detect(frame, points);
fd = FastFeatureDetector(20, true, FastFeatureDetector::TYPE_9_16);
TEST_CYCLE() fd.detect(frame, points);
} }
This diff is collapsed.
...@@ -58,7 +58,8 @@ CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF", ...@@ -58,7 +58,8 @@ CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF",
CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST", CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST",
obj.info()->addParam(obj, "threshold", obj.threshold); obj.info()->addParam(obj, "threshold", obj.threshold);
obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression)); obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
obj.info()->addParam(obj, "type", obj.type, FastFeatureDetector::TYPE_9_16));
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -58,6 +58,7 @@ CV_FastTest::~CV_FastTest() {} ...@@ -58,6 +58,7 @@ CV_FastTest::~CV_FastTest() {}
void CV_FastTest::run( int ) void CV_FastTest::run( int )
{ {
for(int type=0; type <= 2; ++type) {
Mat image1 = imread(string(ts->get_data_path()) + "inpaint/orig.jpg"); Mat image1 = imread(string(ts->get_data_path()) + "inpaint/orig.jpg");
Mat image2 = imread(string(ts->get_data_path()) + "cameracalibration/chess9.jpg"); Mat image2 = imread(string(ts->get_data_path()) + "cameracalibration/chess9.jpg");
string xml = string(ts->get_data_path()) + "fast/result.xml"; string xml = string(ts->get_data_path()) + "fast/result.xml";
...@@ -74,8 +75,8 @@ void CV_FastTest::run( int ) ...@@ -74,8 +75,8 @@ void CV_FastTest::run( int )
vector<KeyPoint> keypoints1; vector<KeyPoint> keypoints1;
vector<KeyPoint> keypoints2; vector<KeyPoint> keypoints2;
FAST(gray1, keypoints1, 30); FAST(gray1, keypoints1, 30, type);
FAST(gray2, keypoints2, 30); FAST(gray2, keypoints2, 30, type);
for(size_t i = 0; i < keypoints1.size(); ++i) for(size_t i = 0; i < keypoints1.size(); ++i)
{ {
...@@ -109,17 +110,21 @@ void CV_FastTest::run( int ) ...@@ -109,17 +110,21 @@ void CV_FastTest::run( int )
read( fs["exp_kps2"], exp_kps2, Mat() ); read( fs["exp_kps2"], exp_kps2, Mat() );
fs.release(); fs.release();
// We only have testing data for 9_16 but it actually works equally well for 7_12
if ((type==1) || (type==2)){
if ( 0 != norm(exp_kps1, kps1, NORM_L2) || 0 != norm(exp_kps2, kps2, NORM_L2)) if ( 0 != norm(exp_kps1, kps1, NORM_L2) || 0 != norm(exp_kps2, kps2, NORM_L2))
{ {
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
return; return;
} }
}
/* cv::namedWindow("Img1"); cv::imshow("Img1", image1); /*cv::namedWindow("Img1"); cv::imshow("Img1", image1);
cv::namedWindow("Img2"); cv::imshow("Img2", image2); cv::namedWindow("Img2"); cv::imshow("Img2", image2);
cv::waitKey(0);*/ cv::waitKey(0);*/
}
ts->set_failed_test_info(cvtest::TS::OK); ts->set_failed_test_info(cvtest::TS::OK);
} }
TEST(Features2d_FAST, regression) { CV_FastTest test; test.safe_run(); } TEST(Features2d_FAST, regression) { CV_FastTest test; test.safe_run(); }
......
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