Repository: opencv/opencv
File: modules/features2d/perf/perf_fast.cpp (C++)

Code before:
#include "perf_precomp.hpp"
#include "perf_feature2d.hpp"

namespace opencv_test
{
using namespace perf;

typedef tuple<int, int, bool, string> Fast_Params_t;
typedef perf::TestBaseWithParam<Fast_Params_t> Fast_Params;

PERF_TEST_P(Fast_Params, detect,
    testing::Combine(
        testing::Values(20,30,100),                   // threshold
        testing::Values(
            // (int)FastFeatureDetector::TYPE_5_8,
            // (int)FastFeatureDetector::TYPE_7_12,
            (int)FastFeatureDetector::TYPE_9_16       // detector_type
        ),
        testing::Bool(),                              // nonmaxSuppression
        testing::Values("cv/inpaint/orig.png",
                        "cv/cameracalibration/chess9.png")
    ))
{
    int threshold = get<0>(GetParam());
    int type = get<1>(GetParam());
    bool nonmaxSuppression = get<2>(GetParam());
    string filename = getDataPath(get<3>(GetParam()));

    Mat img = imread(filename, IMREAD_GRAYSCALE);
    ASSERT_FALSE(img.empty()) << "Failed to load image: " << filename;

    vector<KeyPoint> keypoints;

    int64 t1 = cv::getTickCount();
    for(int i = 0; i < 10; i++) {
        FAST(img, keypoints, threshold, nonmaxSuppression, (FastFeatureDetector::DetectorType)type);
    }
    int64 t2 = cv::getTickCount();
    declare.in(img);
    TEST_CYCLE()
    {
        FAST(img, keypoints, threshold, nonmaxSuppression, (FastFeatureDetector::DetectorType)type);
    }

    // SANITY_CHECK_KEYPOINTS(keypoints);
    SANITY_CHECK_NOTHING();
}

} // namespace opencv_test

Review comment (suggestion):
There are warnings:

```
  /home/ci/opencv/modules/features2d/perf/perf_fast.cpp: In member function 'virtual void opencv_test::Fast_Params_detect::PerfTestBody()':
  /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:24:9: warning: declaration of 'threshold' shadows a global declaration [-Wshadow]
     24 |     int threshold = get<0>(GetParam());
        |         ^~~~~~~~~
  In file included from /home/ci/opencv/modules/features2d/perf/perf_precomp.hpp:4,
                   from /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:1:
  /home/ci/opencv/modules/ts/include/opencv2/ts.hpp:957:21: note: shadowed declaration is here
    957 | CVTEST_GUARD_SYMBOL(threshold)
        |                     ^~~~~~~~~
  /home/ci/opencv/modules/ts/include/opencv2/ts.hpp:946:11: note: in definition of macro 'CVTEST_GUARD_SYMBOL'
    946 |     using name = required_namespace_specificatin_here_for_symbol_ ## name;
        |           ^~~~
  /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:34:11: warning: unused variable 't1' [-Wunused-variable]
     34 |     int64 t1 = cv::getTickCount();
        |           ^~
  /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:38:11: warning: unused variable 't2' [-Wunused-variable]
     38 |     int64 t2 = cv::getTickCount();
        |           ^~
```

Code after:
#include "perf_precomp.hpp"
#include "perf_feature2d.hpp"

namespace opencv_test
{
using namespace perf;

typedef tuple<int, int, bool, string> Fast_Params_t;
typedef perf::TestBaseWithParam<Fast_Params_t> Fast_Params;

PERF_TEST_P(Fast_Params, detect,
    testing::Combine(
        testing::Values(20,30,100),                   // threshold
        testing::Values(
            // (int)FastFeatureDetector::TYPE_5_8,
            // (int)FastFeatureDetector::TYPE_7_12,
            (int)FastFeatureDetector::TYPE_9_16       // detector_type
        ),
        testing::Bool(),                              // nonmaxSuppression
        testing::Values("cv/inpaint/orig.png",
                        "cv/cameracalibration/chess9.png")
    ))
{
    int threshold_p = get<0>(GetParam());
    int type_p = get<1>(GetParam());
    bool nonmaxSuppression_p = get<2>(GetParam());
    string filename = getDataPath(get<3>(GetParam()));

    Mat img = imread(filename, IMREAD_GRAYSCALE);
    ASSERT_FALSE(img.empty()) << "Failed to load image: " << filename;

    vector<KeyPoint> keypoints;

    declare.in(img);
    TEST_CYCLE()
    {
        FAST(img, keypoints, threshold_p, nonmaxSuppression_p, (FastFeatureDetector::DetectorType)type_p);
    }

    SANITY_CHECK_NOTHING();
}

} // namespace opencv_test