From 49f29aeb6a4c09a3b51754c32674ed740803d141 Mon Sep 17 00:00:00 2001 From: Kirill Kornyakov Date: Mon, 16 Jan 2012 13:35:16 +0000 Subject: [PATCH] Created perf tests for cornerHarris, cornerEigenValsAndVecs, goodFeaturesToTrack, adaptiveThreshold, HoughLines. --- .../perf/perf_cornerEigenValsAndVecs.cpp | 37 +++++++++++++++++ modules/imgproc/perf/perf_cornerHarris.cpp | 39 ++++++++++++++++++ .../imgproc/perf/perf_goodFeaturesToTrack.cpp | 38 ++++++++++++++++++ modules/imgproc/perf/perf_houghLines.cpp | 40 +++++++++++++++++++ modules/imgproc/perf/perf_threshold.cpp | 34 ++++++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp create mode 100644 modules/imgproc/perf/perf_cornerHarris.cpp create mode 100644 modules/imgproc/perf/perf_goodFeaturesToTrack.cpp create mode 100644 modules/imgproc/perf/perf_houghLines.cpp diff --git a/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp b/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp new file mode 100644 index 0000000000..a7475fa9da --- /dev/null +++ b/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp @@ -0,0 +1,37 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101) + +typedef std::tr1::tuple Img_BlockSize_ApertureSize_BorderType_t; +typedef perf::TestBaseWithParam Img_BlockSize_ApertureSize_BorderType; + +PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs, + testing::Combine( + testing::Values( "stitching/a1.jpg", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( 3, 5 ), + testing::ValuesIn(BorderType::all()) + ) + ) +{ + String filename = getDataPath(get<0>(GetParam())); + int blockSize = get<1>(GetParam()); + int apertureSize = get<2>(GetParam()); + BorderType borderType = get<3>(GetParam()); + + Mat src = imread(filename, IMREAD_GRAYSCALE); + if (src.empty()) + FAIL() << "Unable to load source image" << filename; + + Mat dst; + + TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType); + + SANITY_CHECK(dst); +} \ No newline at end of file diff --git a/modules/imgproc/perf/perf_cornerHarris.cpp b/modules/imgproc/perf/perf_cornerHarris.cpp new file mode 100644 index 0000000000..c7a30b5498 --- /dev/null +++ b/modules/imgproc/perf/perf_cornerHarris.cpp @@ -0,0 +1,39 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101) + +typedef std::tr1::tuple Img_BlockSize_ApertureSize_k_BorderType_t; +typedef perf::TestBaseWithParam Img_BlockSize_ApertureSize_k_BorderType; + +PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris, + testing::Combine( + testing::Values( "stitching/a1.jpg", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( 3, 5 ), + testing::Values( 1, 0.1 ), + testing::ValuesIn(BorderType::all()) + ) + ) +{ + String filename = getDataPath(get<0>(GetParam())); + int blockSize = get<1>(GetParam()); + int apertureSize = get<2>(GetParam()); + double k = get<3>(GetParam()); + BorderType borderType = get<4>(GetParam()); + + Mat src = imread(filename, IMREAD_GRAYSCALE); + if (src.empty()) + FAIL() << "Unable to load source image" << filename; + + Mat dst; + + TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType); + + SANITY_CHECK(dst); +} \ No newline at end of file diff --git a/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp b/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp new file mode 100644 index 0000000000..fbd7abe254 --- /dev/null +++ b/modules/imgproc/perf/perf_goodFeaturesToTrack.cpp @@ -0,0 +1,38 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +typedef std::tr1::tuple Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris_t; +typedef perf::TestBaseWithParam Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris; + +PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_UseHarris, goodFeaturesToTrack, + testing::Combine( + testing::Values( "stitching/a1.jpg", "cv/shared/pic5.png"), + testing::Values( 100, 500 ), + testing::Values( 0.1, 0.01 ), + testing::Values( 3, 5 ), + testing::Bool() + ) + ) +{ + String filename = getDataPath(get<0>(GetParam())); + int maxCorners = get<1>(GetParam()); + double qualityLevel = get<2>(GetParam()); + int blockSize = get<3>(GetParam()); + bool useHarrisDetector = get<4>(GetParam()); + + Mat image = imread(filename, IMREAD_GRAYSCALE); + if (image.empty()) + FAIL() << "Unable to load source image" << filename; + + Mat corners; + + double minDistance = 1; + TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(), blockSize, useHarrisDetector); + + SANITY_CHECK(corners); +} diff --git a/modules/imgproc/perf/perf_houghLines.cpp b/modules/imgproc/perf/perf_houghLines.cpp new file mode 100644 index 0000000000..6e4179e4fd --- /dev/null +++ b/modules/imgproc/perf/perf_houghLines.cpp @@ -0,0 +1,40 @@ +#include "perf_precomp.hpp" + +#include "cmath" + +using namespace std; +using namespace cv; +using namespace perf; +using std::tr1::make_tuple; +using std::tr1::get; + +typedef std::tr1::tuple Image_RhoStep_ThetaStep_Threshold_t; +typedef perf::TestBaseWithParam Image_RhoStep_ThetaStep_Threshold; + +PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines, + testing::Combine( + testing::Values( "cv/shared/pic5.png", "stitching/a1.jpg" ), + testing::Values( 1, 10 ), + testing::Values( 0.01, 0.1 ), + testing::Values( 300, 500 ) + ) + ) +{ + String filename = getDataPath(get<0>(GetParam())); + double rhoStep = get<1>(GetParam()); + double thetaStep = get<2>(GetParam()); + int threshold = get<3>(GetParam()); + + Mat image = imread(filename, IMREAD_GRAYSCALE); + if (image.empty()) + FAIL() << "Unable to load source image" << filename; + + Canny(image, image, 0, 0); + + Mat lines; + declare.time(7); + + TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold); + + SANITY_CHECK(lines); +} \ No newline at end of file diff --git a/modules/imgproc/perf/perf_threshold.cpp b/modules/imgproc/perf/perf_threshold.cpp index b95b36f83e..2be7d36287 100644 --- a/modules/imgproc/perf/perf_threshold.cpp +++ b/modules/imgproc/perf/perf_threshold.cpp @@ -55,3 +55,37 @@ PERF_TEST_P(Size_Only, threshold_otsu, testing::Values(TYPICAL_MAT_SIZES)) SANITY_CHECK(dst); } +CV_ENUM(AdaptThreshType, THRESH_BINARY, THRESH_BINARY_INV) +CV_ENUM(AdaptThreshMethod, ADAPTIVE_THRESH_MEAN_C, ADAPTIVE_THRESH_GAUSSIAN_C) + +typedef std::tr1::tuple Size_AdaptThreshType_AdaptThreshMethod_BlockSize_t; +typedef perf::TestBaseWithParam Size_AdaptThreshType_AdaptThreshMethod_BlockSize; + +PERF_TEST_P(Size_AdaptThreshType_AdaptThreshMethod_BlockSize, adaptiveThreshold, + testing::Combine( + testing::Values(TYPICAL_MAT_SIZES), + testing::ValuesIn(AdaptThreshType::all()), + testing::ValuesIn(AdaptThreshMethod::all()), + testing::Values(3, 5) + ) + ) +{ + Size sz = get<0>(GetParam()); + AdaptThreshType adaptThreshType = get<1>(GetParam()); + AdaptThreshMethod adaptThreshMethod = get<2>(GetParam()); + int blockSize = get<3>(GetParam()); + + double maxValue = theRNG().uniform(1, 254); + double C = 10.0; + + int type = CV_8UC1; + Mat src(sz, type); + Mat dst(sz, type); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() adaptiveThreshold(src, dst, maxValue, adaptThreshMethod, adaptThreshType, blockSize, C); + + SANITY_CHECK(dst); +} +