From d9556a998ff22d6d9d8d2fd926f16f73921e84d2 Mon Sep 17 00:00:00 2001 From: Alexander Karsakov Date: Thu, 10 Apr 2014 11:00:08 +0400 Subject: [PATCH] Added ippiMinEigenVal_ to cv::cornerMinEigenVal --- modules/imgproc/src/corner.cpp | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index cc35ff2de5..1f9d7bda5a 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -460,6 +460,53 @@ void cv::cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockSize, in Mat src = _src.getMat(); _dst.create( src.size(), CV_32FC1 ); Mat dst = _dst.getMat(); + +#ifdef HAVE_IPP + 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()) + { + IppiKernelType kerType = ksize > 0 ? ippKernelSobel : ippKernelScharr; + IppiSize srcRoi = { src.cols, src.rows }; + + ippiMinEigenValGetBufferSize getBufferSizeFunc = 0; + ippiMinEigenVal minEigenValFunc = 0; + float multiplier = 0.f; + + if (src.type() == CV_8UC1) + { + getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_8u32f_C1R; + minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_8u32f_C1R; + multiplier = (float) 1 / 255; + } else if (src.type() == CV_32FC1) + { + getBufferSizeFunc = (ippiMinEigenValGetBufferSize) ippiMinEigenValGetBufferSize_32f_C1R; + minEigenValFunc = (ippiMinEigenVal) ippiMinEigenVal_32f_C1R; + multiplier = 255.f; + } + + if (getBufferSizeFunc && minEigenValFunc) + { + int bufferSize; + 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); + ippsFree(buffer); + if (ok >= 0) + { + dst *= multiplier; + return; + } + } + } + } +#endif cornerEigenValsVecs( src, dst, blockSize, ksize, MINEIGENVAL, 0, borderType ); }