From 7369cfd9ecc1e6d38cdffe42836652cf1c232855 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Thu, 10 Apr 2014 14:02:43 +0400 Subject: [PATCH] Added perf test for cornerMinEigenVal --- .../imgproc/perf/perf_cornerEigenValsAndVecs.cpp | 40 --------- modules/imgproc/perf/perf_cornerHarris.cpp | 39 --------- modules/imgproc/perf/perf_corners.cpp | 95 ++++++++++++++++++++++ modules/imgproc/src/corner.cpp | 23 ++---- 4 files changed, 104 insertions(+), 93 deletions(-) delete mode 100644 modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp delete mode 100644 modules/imgproc/perf/perf_cornerHarris.cpp create mode 100644 modules/imgproc/perf/perf_corners.cpp diff --git a/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp b/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp deleted file mode 100644 index 5a323cc..0000000 --- a/modules/imgproc/perf/perf_cornerEigenValsAndVecs.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#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.png", "cv/shared/pic5.png"), - testing::Values( 3, 5 ), - testing::Values( 3, 5 ), - 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); - - Mat l1; - extractChannel(dst, l1, 0); - - SANITY_CHECK(l1, 2e-5); -} diff --git a/modules/imgproc/perf/perf_cornerHarris.cpp b/modules/imgproc/perf/perf_cornerHarris.cpp deleted file mode 100644 index 832845e..0000000 --- a/modules/imgproc/perf/perf_cornerHarris.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#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.png", "cv/shared/pic5.png"), - testing::Values( 3, 5 ), - testing::Values( 3, 5 ), - testing::Values( 0.04, 0.1 ), - 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, 2e-5); -} diff --git a/modules/imgproc/perf/perf_corners.cpp b/modules/imgproc/perf/perf_corners.cpp new file mode 100644 index 0000000..33c6bc9 --- /dev/null +++ b/modules/imgproc/perf/perf_corners.cpp @@ -0,0 +1,95 @@ +#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.png", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( 3, 5 ), + testing::Values( 0.04, 0.1 ), + 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, 2e-5); +} + +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.png", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( 3, 5 ), + 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); + + Mat l1; + extractChannel(dst, l1, 0); + + SANITY_CHECK(l1, 2e-5); +} + +PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal, + testing::Combine( + testing::Values( "stitching/a1.png", "cv/shared/pic5.png"), + testing::Values( 3, 5 ), + testing::Values( 3, 5 ), + 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() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType); + + SANITY_CHECK(dst, 2e-5); +} diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index 1f9d7bd..cc03c84 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -465,44 +465,39 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in typedef IppStatus (CV_STDCALL * ippiMinEigenValGetBufferSize)(IppiSize, int, int, int*); typedef IppStatus (CV_STDCALL * ippiMinEigenVal)(const void*, int, Ipp32f*, int, IppiSize, IppiKernelType, int, int, Ipp8u*); - Size srcWholeSize; Point srcOffset; - src.locateROI(srcWholeSize, srcOffset); - if (borderType == BORDER_REPLICATE && srcWholeSize == src.size()) + if (borderType == BORDER_REPLICATE && !src.isSubmatrix()) { - IppiKernelType kerType = ksize > 0 ? ippKernelSobel : ippKernelScharr; - IppiSize srcRoi = { src.cols, src.rows }; - ippiMinEigenValGetBufferSize getBufferSizeFunc = 0; ippiMinEigenVal minEigenValFunc = 0; - float multiplier = 0.f; + float norm_coef = 0.f; if (src.type() == CV_8UC1) { getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_8u32f_C1R; minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_8u32f_C1R; - multiplier = (float) 1 / 255; + norm_coef = 1.f / 255; } else if (src.type() == CV_32FC1) { getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_32f_C1R; minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_32f_C1R; - multiplier = 255.f; + norm_coef = 255.f; } if (getBufferSizeFunc && minEigenValFunc) { int bufferSize; + IppiKernelType kerType = ksize > 0 ? ippKernelSobel : ippKernelScharr; + IppiSize srcRoi = { src.cols, src.rows }; + IppiSize dstRoi = { dst.cols, dst.rows }; IppStatus ok = getBufferSizeFunc(srcRoi, ksize, blockSize, &bufferSize); if (ok >= 0) { - Ipp8u* buffer = ippsMalloc_8u(bufferSize); - ok = minEigenValFunc(src.data, src.step, (Ipp32f*) dst.data, (int) dst.step, srcRoi, kerType, ksize, blockSize, buffer); + ok = minEigenValFunc(src.data, (int) src.step, (Ipp32f*) dst.data, (int) dst.step, srcRoi, kerType, ksize, blockSize, buffer); + if (ok >= 0) ippiMulC_32f_C1IR(norm_coef, (Ipp32f*) dst.data, (int) dst.step, dstRoi); ippsFree(buffer); if (ok >= 0) - { - dst *= multiplier; return; - } } } } -- 2.7.4