[opencv] 248/251: features2d(test): more AKAZE tests

Nobuhiro Iwamatsu iwamatsu at moszumanska.debian.org
Sun Aug 27 23:27:48 UTC 2017


This is an automated email from the git hooks/post-receive script.

iwamatsu pushed a commit to annotated tag 3.3.0
in repository opencv.

commit 94dbc35d922503d42b1d1f0ee31b3937ed9147d4
Author: Alexander Alekhin <alexander.a.alekhin at gmail.com>
Date:   Thu Aug 3 22:02:47 2017 +0000

    features2d(test): more AKAZE tests
---
 modules/features2d/src/kaze/AKAZEFeatures.cpp      |  3 +-
 .../test/test_descriptors_regression.cpp           | 99 +++++++++++++---------
 modules/ts/misc/run_long.py                        |  6 +-
 3 files changed, 64 insertions(+), 44 deletions(-)

diff --git a/modules/features2d/src/kaze/AKAZEFeatures.cpp b/modules/features2d/src/kaze/AKAZEFeatures.cpp
index a4d336b..024a5ca 100644
--- a/modules/features2d/src/kaze/AKAZEFeatures.cpp
+++ b/modules/features2d/src/kaze/AKAZEFeatures.cpp
@@ -2144,7 +2144,8 @@ void generateDescriptorSubsample(Mat& sampleList, Mat& comparisons, int nbits,
   }
   ssz *= nchannels;
 
-  CV_Assert(nbits <= ssz); // Descriptor size can't be bigger than full descriptor
+  CV_Assert(ssz == 162*nchannels);
+  CV_Assert(nbits <= ssz && "Descriptor size can't be bigger than full descriptor (486 = 162*3 - 3 channels)");
 
   // Since the full descriptor is usually under 10k elements, we pick
   // the selection from the full matrix.  We take as many samples per
diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp
index 0862649..7540d1d 100644
--- a/modules/features2d/test/test_descriptors_regression.cpp
+++ b/modules/features2d/test/test_descriptors_regression.cpp
@@ -43,6 +43,7 @@
 
 using namespace std;
 using namespace cv;
+using namespace testing;
 
 const string FEATURES2D_DIR = "features2d";
 const string IMAGE_FILENAME = "tsukuba.png";
@@ -417,68 +418,82 @@ TEST( Features2d_DescriptorExtractor, batch )
     }
 }
 
-TEST( Features2d_Feature2d, no_crash )
+class DescriptorImage : public TestWithParam<std::string>
+{
+protected:
+    virtual void SetUp() {
+        pattern = GetParam();
+    }
+
+    std::string pattern;
+};
+
+TEST_P(DescriptorImage, no_crash)
 {
-    const String& pattern = string(cvtest::TS::ptr()->get_data_path() + "shared/*.png");
     vector<String> fnames;
-    glob(pattern, fnames, false);
+    glob(cvtest::TS::ptr()->get_data_path() + pattern, fnames, false);
     sort(fnames.begin(), fnames.end());
 
-    Ptr<AKAZE> akaze = AKAZE::create();
+    Ptr<AKAZE> akaze_mldb = AKAZE::create(AKAZE::DESCRIPTOR_MLDB);
+    Ptr<AKAZE> akaze_mldb_upright = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT);
+    Ptr<AKAZE> akaze_mldb_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 256);
+    Ptr<AKAZE> akaze_mldb_upright_256 = AKAZE::create(AKAZE::DESCRIPTOR_MLDB_UPRIGHT, 256);
+    Ptr<AKAZE> akaze_kaze = AKAZE::create(AKAZE::DESCRIPTOR_KAZE);
+    Ptr<AKAZE> akaze_kaze_upright = AKAZE::create(AKAZE::DESCRIPTOR_KAZE_UPRIGHT);
     Ptr<ORB> orb = ORB::create();
     Ptr<KAZE> kaze = KAZE::create();
     Ptr<BRISK> brisk = BRISK::create();
-    size_t i, n = fnames.size();
+    size_t n = fnames.size();
     vector<KeyPoint> keypoints;
     Mat descriptors;
     orb->setMaxFeatures(5000);
 
-    for( i = 0; i < n; i++ )
+    for(size_t i = 0; i < n; i++ )
     {
         printf("%d. image: %s:\n", (int)i, fnames[i].c_str());
         if( strstr(fnames[i].c_str(), "MP.png") != 0 )
+        {
+            printf("\tskip\n");
             continue;
+        }
         bool checkCount = strstr(fnames[i].c_str(), "templ.png") == 0;
 
         Mat img = imread(fnames[i], -1);
-        printf("\tAKAZE ... "); fflush(stdout);
-        akaze->detectAndCompute(img, noArray(), keypoints, descriptors);
-        printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
-        if( checkCount )
-        {
-            EXPECT_GT((int)keypoints.size(), 0);
-        }
-        ASSERT_EQ(descriptors.rows, (int)keypoints.size());
-        printf("ok\n");
 
-        printf("\tKAZE ... "); fflush(stdout);
-        kaze->detectAndCompute(img, noArray(), keypoints, descriptors);
-        printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
-        if( checkCount )
-        {
-            EXPECT_GT((int)keypoints.size(), 0);
-        }
+        printf("\t%dx%d\n", img.cols, img.rows);
+
+#define TEST_DETECTOR(name, descriptor) \
+        keypoints.clear(); descriptors.release(); \
+        printf("\t" name "\n"); fflush(stdout); \
+        descriptor->detectAndCompute(img, noArray(), keypoints, descriptors); \
+        printf("\t\t\t(%d keypoints, descriptor size = %d)\n", (int)keypoints.size(), descriptors.cols); fflush(stdout); \
+        if (checkCount) \
+        { \
+            EXPECT_GT((int)keypoints.size(), 0); \
+        } \
         ASSERT_EQ(descriptors.rows, (int)keypoints.size());
-        printf("ok\n");
 
-        printf("\tORB ... "); fflush(stdout);
-        orb->detectAndCompute(img, noArray(), keypoints, descriptors);
-        printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
-        if( checkCount )
-        {
-            EXPECT_GT((int)keypoints.size(), 0);
-        }
-        ASSERT_EQ(descriptors.rows, (int)keypoints.size());
-        printf("ok\n");
-
-        printf("\tBRISK ... "); fflush(stdout);
-        brisk->detectAndCompute(img, noArray(), keypoints, descriptors);
-        printf("(%d keypoints) ", (int)keypoints.size()); fflush(stdout);
-        if( checkCount )
-        {
-            EXPECT_GT((int)keypoints.size(), 0);
-        }
-        ASSERT_EQ(descriptors.rows, (int)keypoints.size());
-        printf("ok\n");
+        TEST_DETECTOR("AKAZE:MLDB", akaze_mldb);
+        TEST_DETECTOR("AKAZE:MLDB_UPRIGHT", akaze_mldb_upright);
+        TEST_DETECTOR("AKAZE:MLDB_256", akaze_mldb_256);
+        TEST_DETECTOR("AKAZE:MLDB_UPRIGHT_256", akaze_mldb_upright_256);
+        TEST_DETECTOR("AKAZE:KAZE", akaze_kaze);
+        TEST_DETECTOR("AKAZE:KAZE_UPRIGHT", akaze_kaze_upright);
+        TEST_DETECTOR("KAZE", kaze);
+        TEST_DETECTOR("ORB", orb);
+        TEST_DETECTOR("BRISK", brisk);
     }
 }
+
+INSTANTIATE_TEST_CASE_P(Features2d, DescriptorImage,
+        testing::Values(
+            "shared/lena.png",
+            "shared/box*.png",
+            "shared/fruits*.png",
+            "shared/airplane.png",
+            "shared/graffiti.png",
+            "shared/1_itseez-0001*.png",
+            "shared/pic*.png",
+            "shared/templ.png"
+        )
+);
diff --git a/modules/ts/misc/run_long.py b/modules/ts/misc/run_long.py
index d820f97..5640ea3 100644
--- a/modules/ts/misc/run_long.py
+++ b/modules/ts/misc/run_long.py
@@ -8,7 +8,11 @@ from pprint import PrettyPrinter as PP
 LONG_TESTS_DEBUG_VALGRIND = [
     ('calib3d', 'Calib3d_InitUndistortRectifyMap.accuracy', 2017.22),
     ('dnn', 'Reproducibility*', 1000), # large DNN models
-    ('features2d', 'Features2d_Feature2d.no_crash', 1235.68),
+    ('features2d', 'Features2d/DescriptorImage.no_crash/3', 1000),
+    ('features2d', 'Features2d/DescriptorImage.no_crash/4', 1000),
+    ('features2d', 'Features2d/DescriptorImage.no_crash/5', 1000),
+    ('features2d', 'Features2d/DescriptorImage.no_crash/6', 1000),
+    ('features2d', 'Features2d/DescriptorImage.no_crash/7', 1000),
     ('imgcodecs', 'Imgcodecs_Png.write_big', 1000), # memory limit
     ('imgcodecs', 'Imgcodecs_Tiff.decode_tile16384x16384', 1000), # memory limit
     ('ml', 'ML_RTrees.regression', 1423.47),

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list