From f3c56f8310f16069922f1c8eae20882b64bae5cb Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 16 Apr 2014 15:34:18 +0400 Subject: [PATCH 1/6] first attemp --- modules/core/include/opencv2/core/base.hpp | 3 + modules/core/src/arithm.cpp | 28 +++++++ modules/core/src/convert.cpp | 2 + modules/core/src/copy.cpp | 1 + modules/core/src/precomp.hpp | 3 +- modules/core/src/system.cpp | 10 +++ modules/ts/include/opencv2/ts.hpp | 3 +- modules/ts/include/opencv2/ts/ts_ext.hpp | 89 ++++++++++++++++++++++ modules/ts/include/opencv2/ts/ts_perf.hpp | 3 +- 9 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 modules/ts/include/opencv2/ts/ts_ext.hpp diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index e9187faba4..ba5c8fe872 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -560,6 +560,9 @@ namespace cudev template class GpuMat_; } +CV_EXPORTS void setIppStatus(int status); +CV_EXPORTS int getIppStatus(); + } // cv #endif //__OPENCV_CORE_BASE_HPP__ diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index b74678ca67..190bdf98f9 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -464,6 +464,7 @@ static void add8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -483,6 +484,7 @@ static void add16u( const ushort* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -495,6 +497,7 @@ static void add16s( const short* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -514,6 +517,7 @@ static void add32f( const float* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp32, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -533,6 +537,7 @@ static void sub8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -552,6 +557,7 @@ static void sub16u( const ushort* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -564,6 +570,7 @@ static void sub16s( const short* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -583,6 +590,7 @@ static void sub32f( const float* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp32, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -617,6 +625,7 @@ static void max8u( const uchar* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -648,6 +657,7 @@ static void max16u( const ushort* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -686,6 +696,7 @@ static void max32f( const float* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp32, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -717,6 +728,7 @@ static void min8u( const uchar* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -748,6 +760,7 @@ static void min16u( const ushort* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -786,6 +799,7 @@ static void min32f( const float* src1, size_t step1, } if (i == sz.height) return; + setIppStatus(-1); #endif vBinOp32, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -802,9 +816,11 @@ static void absdiff8u( const uchar* src1, size_t step1, uchar* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) + printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -821,9 +837,11 @@ static void absdiff16u( const ushort* src1, size_t step1, ushort* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) + printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -847,9 +865,11 @@ static void absdiff32f( const float* src1, size_t step1, float* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) + printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp32, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -870,6 +890,7 @@ static void and8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VAnd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -882,6 +903,7 @@ static void or8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VOr)>(src1, step1, src2, step2, dst, step, sz)); } @@ -894,6 +916,7 @@ static void xor8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VXor)>(src1, step1, src2, step2, dst, step, sz)); } @@ -906,6 +929,7 @@ static void not8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2; if (0 <= ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz))) return; + setIppStatus(-1); #endif (vBinOp, IF_SIMD(VNot)>(src1, step1, src2, step2, dst, step, sz)); } @@ -2390,6 +2414,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; + setIppStatus(-1); } #endif //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2473,6 +2498,7 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; + setIppStatus(-1); } #endif cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2488,6 +2514,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; + setIppStatus(-1); } #endif //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2594,6 +2621,7 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; + setIppStatus(-1); } #endif cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 155ca67d6f..3d3f1aa62b 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -1086,6 +1086,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \ { \ if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \ return; \ + setIppStatus(-1); \ cvt_(src, sstep, dst, dstep, size); \ } @@ -1095,6 +1096,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \ { \ if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \ return; \ + setIppStatus(-1); \ cvt_(src, sstep, dst, dstep, size); \ } #else diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 202e7a9225..6a1ff4b3cb 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -574,6 +574,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) IppStatus status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis); if (status >= 0) return; + setIppStatus(-1); } #endif diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 1c498cd012..37e4a34944 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -235,13 +235,14 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl struct CoreTLSData { - CoreTLSData() : device(0), useOpenCL(-1) + CoreTLSData() : device(0), useOpenCL(-1), ippStatus(0) {} RNG rng; int device; ocl::Queue oclQueue; int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized + int ippStatus; // 0 - all is ok, -1 - IPP functions failed }; extern TLSData coreTlsData; diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index cef4db3c2c..cf4b986537 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1063,6 +1063,16 @@ TLSStorage::~TLSStorage() TLSData coreTlsData; +void setIppStatus(int status) +{ + coreTlsData.get()->ippStatus = status; +} + +int getIppStatus() +{ + return coreTlsData.get()->ippStatus; +} + } // namespace cv /* End of file. */ diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 8aeec65712..07f9845b76 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -25,6 +25,7 @@ #define GTEST_DONT_DEFINE_TEST 0 #include "opencv2/ts/ts_gtest.h" +#include "opencv2/ts/ts_ext.hpp" #ifndef GTEST_USES_SIMPLE_RE # define GTEST_USES_SIMPLE_RE 0 @@ -553,7 +554,7 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true); #endif #endif -#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE) +#if defined(HAVE_OPENCL) namespace cvtest { namespace ocl { void dumpOpenCLDevice(); }} diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp new file mode 100644 index 0000000000..14541fe890 --- /dev/null +++ b/modules/ts/include/opencv2/ts/ts_ext.hpp @@ -0,0 +1,89 @@ +#ifndef __OPENCV_TS_EXT_HPP__ +#define __OPENCV_TS_EXT_HPP__ + +#define CHECK_IPP_STATUS \ + do \ + { \ + EXPECT_LE(0, getIppStatus()); \ + } while ((void)0, 0) + +#undef TEST +#define TEST(test_case_name, test_name) \ + class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public ::testing::Test {\ + public:\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ + private:\ + virtual void TestBody();\ + virtual void Body();\ + static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ + };\ + \ + ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ + ::test_info_ =\ + ::testing::internal::MakeAndRegisterTestInfo(\ + #test_case_name, #test_name, NULL, NULL, \ + (::testing::internal::GetTestTypeId()), \ + ::testing::Test::SetUpTestCase, \ + ::testing::Test::TearDownTestCase, \ + new ::testing::internal::TestFactoryImpl<\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body() + +#undef TEST_F +#define TEST_F(test_fixture, test_name)\ + class GTEST_TEST_CLASS_NAME_(test_fixture, test_name) : public test_fixture {\ + public:\ + GTEST_TEST_CLASS_NAME_(test_fixture, test_name)() {}\ + private:\ + virtual void TestBody();\ + virtual void Body(); \ + static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_fixture, test_name));\ + };\ + \ + ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_fixture, test_name)\ + ::test_info_ =\ + ::testing::internal::MakeAndRegisterTestInfo(\ + #test_fixture, #test_name, NULL, NULL, \ + (::testing::internal::GetTypeId()), \ + test_fixture::SetUpTestCase, \ + test_fixture::TearDownTestCase, \ + new ::testing::internal::TestFactoryImpl<\ + GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\ + void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body() + +#undef TEST_P +#define TEST_P(test_case_name, test_name) \ + class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ + : public test_case_name { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ + private: \ + virtual void Body(); \ + virtual void TestBody(); \ + static int AddToRegistry() { \ + ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ + GetTestCasePatternHolder(\ + #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ + #test_case_name, \ + #test_name, \ + new ::testing::internal::TestMetaFactory< \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ + return 0; \ + } \ + static int gtest_registering_dummy_; \ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ + }; \ + int GTEST_TEST_CLASS_NAME_(test_case_name, \ + test_name)::gtest_registering_dummy_ = \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body() + +#endif // __OPENCV_TS_EXT_HPP__ diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 62e9e1471f..33265568b9 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -3,6 +3,7 @@ #include "opencv2/core.hpp" #include "ts_gtest.h" +#include "ts_ext.hpp" #include @@ -512,7 +513,7 @@ CV_EXPORTS void PrintTo(const Size& sz, ::std::ostream* os); #endif #endif -#if defined(HAVE_OPENCL) && !defined(CV_BUILD_OCL_MODULE) +#ifdef HAVE_OPENCL namespace cvtest { namespace ocl { void dumpOpenCLDevice(); }} From 2cd7a913ed81e90627ccdf4f374774f9800160dc Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 16 Apr 2014 18:50:23 +0400 Subject: [PATCH 2/6] verbose errors --- modules/core/include/opencv2/core/base.hpp | 5 +- modules/core/src/arithm.cpp | 53 ++++++++++------------ modules/core/src/convert.cpp | 4 +- modules/core/src/copy.cpp | 2 +- modules/core/src/precomp.hpp | 3 +- modules/core/src/system.cpp | 18 ++++++-- modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +- 7 files changed, 49 insertions(+), 38 deletions(-) diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index ba5c8fe872..d081d353ad 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -560,8 +560,11 @@ namespace cudev template class GpuMat_; } -CV_EXPORTS void setIppStatus(int status); +CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL, + int line = 0); CV_EXPORTS int getIppStatus(); +CV_EXPORTS String getIppErrorLocation(); +#define setIppErrorStatus() setIppStatus(-1, CV_Func, __FILE__, __LINE__) } // cv diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 190bdf98f9..f7256b85fa 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -464,7 +464,7 @@ static void add8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_8u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -484,7 +484,7 @@ static void add16u( const ushort* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_16u_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -497,7 +497,7 @@ static void add16s( const short* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_16s_C1RSfs(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -517,7 +517,7 @@ static void add32f( const float* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAdd_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp32, IF_SIMD(VAdd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -537,7 +537,7 @@ static void sub8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_8u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -557,7 +557,7 @@ static void sub16u( const ushort* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_16u_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -570,7 +570,7 @@ static void sub16s( const short* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_16s_C1RSfs(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz), 0)) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -590,7 +590,7 @@ static void sub32f( const float* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiSub_32f_C1R(src2, (int)step2, src1, (int)step1, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp32, IF_SIMD(VSub)>(src1, step1, src2, step2, dst, step, sz)); } @@ -625,7 +625,7 @@ static void max8u( const uchar* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -657,7 +657,7 @@ static void max16u( const ushort* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -696,7 +696,7 @@ static void max32f( const float* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp32, IF_SIMD(VMax)>(src1, step1, src2, step2, dst, step, sz); } @@ -728,7 +728,7 @@ static void min8u( const uchar* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -760,7 +760,7 @@ static void min16u( const ushort* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -799,7 +799,7 @@ static void min32f( const float* src1, size_t step1, } if (i == sz.height) return; - setIppStatus(-1); + setIppErrorStatus(); #endif vBinOp32, IF_SIMD(VMin)>(src1, step1, src2, step2, dst, step, sz); } @@ -816,11 +816,10 @@ static void absdiff8u( const uchar* src1, size_t step1, uchar* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) - printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -837,11 +836,10 @@ static void absdiff16u( const ushort* src1, size_t step1, ushort* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) - printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -865,11 +863,10 @@ static void absdiff32f( const float* src1, size_t step1, float* dst, size_t step, Size sz, void* ) { #if (ARITHM_USE_IPP == 1) - printf("!\n"); fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAbsDiff_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp32, IF_SIMD(VAbsDiff)>(src1, step1, src2, step2, dst, step, sz)); } @@ -890,7 +887,7 @@ static void and8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiAnd_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VAnd)>(src1, step1, src2, step2, dst, step, sz)); } @@ -903,7 +900,7 @@ static void or8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiOr_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VOr)>(src1, step1, src2, step2, dst, step, sz)); } @@ -916,7 +913,7 @@ static void xor8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); if (0 <= ippiXor_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VXor)>(src1, step1, src2, step2, dst, step, sz)); } @@ -929,7 +926,7 @@ static void not8u( const uchar* src1, size_t step1, fixSteps(sz, sizeof(dst[0]), step1, step2, step); (void)src2; if (0 <= ippiNot_8u_C1R(src1, (int)step1, dst, (int)step, ippiSize(sz))) return; - setIppStatus(-1); + setIppErrorStatus(); #endif (vBinOp, IF_SIMD(VNot)>(src1, step1, src2, step2, dst, step, sz)); } @@ -2414,7 +2411,7 @@ static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t ste fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; - setIppStatus(-1); + setIppErrorStatus(); } #endif //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2498,7 +2495,7 @@ static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; - setIppStatus(-1); + setIppErrorStatus(); } #endif cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2514,7 +2511,7 @@ static void cmp16s(const short* src1, size_t step1, const short* src2, size_t st fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; - setIppStatus(-1); + setIppErrorStatus(); } #endif //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); @@ -2621,7 +2618,7 @@ static void cmp32f(const float* src1, size_t step1, const float* src2, size_t st fixSteps(size, sizeof(dst[0]), step1, step2, step); if (0 <= ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, ippiSize(size), op)) return; - setIppStatus(-1); + setIppErrorStatus(); } #endif cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 3d3f1aa62b..e73dfef590 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -1086,7 +1086,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \ { \ if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height)) >= 0) \ return; \ - setIppStatus(-1); \ + setIppErrorStatus(); \ cvt_(src, sstep, dst, dstep, size); \ } @@ -1096,7 +1096,7 @@ static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \ { \ if (ippiConvert_##ippFavor(src, (int)sstep, dst, (int)dstep, ippiSize(size.width, size.height), ippRndFinancial, 0) >= 0) \ return; \ - setIppStatus(-1); \ + setIppErrorStatus(); \ cvt_(src, sstep, dst, dstep, size); \ } #else diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 6a1ff4b3cb..d21a390345 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -574,7 +574,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode ) IppStatus status = ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, ippiSize(src.cols, src.rows), axis); if (status >= 0) return; - setIppStatus(-1); + setIppErrorStatus(); } #endif diff --git a/modules/core/src/precomp.hpp b/modules/core/src/precomp.hpp index 37e4a34944..1c498cd012 100644 --- a/modules/core/src/precomp.hpp +++ b/modules/core/src/precomp.hpp @@ -235,14 +235,13 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl struct CoreTLSData { - CoreTLSData() : device(0), useOpenCL(-1), ippStatus(0) + CoreTLSData() : device(0), useOpenCL(-1) {} RNG rng; int device; ocl::Queue oclQueue; int useOpenCL; // 1 - use, 0 - do not use, -1 - auto/not initialized - int ippStatus; // 0 - all is ok, -1 - IPP functions failed }; extern TLSData coreTlsData; diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index cf4b986537..6081a60841 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1063,14 +1063,26 @@ TLSStorage::~TLSStorage() TLSData coreTlsData; -void setIppStatus(int status) +static int ippStatus = 0; // 0 - all is ok, -1 - IPP functions failed +static const char * funcname, * filename; +static int linen; + +void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line) { - coreTlsData.get()->ippStatus = status; + ippStatus = status; + funcname = _funcname; + filename = _filename; + linen = _line; } int getIppStatus() { - return coreTlsData.get()->ippStatus; + return ippStatus; +} + +String getIppErrorLocation() +{ + return format("%s:%d %s", filename ? filename : "", linen, funcname ? funcname : ""); } } // namespace cv diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp index 14541fe890..97349a9a2e 100644 --- a/modules/ts/include/opencv2/ts/ts_ext.hpp +++ b/modules/ts/include/opencv2/ts/ts_ext.hpp @@ -4,7 +4,7 @@ #define CHECK_IPP_STATUS \ do \ { \ - EXPECT_LE(0, getIppStatus()); \ + EXPECT_LE(0, getIppStatus()) << getIppErrorLocation().c_str(); \ } while ((void)0, 0) #undef TEST From ce0941160efa71dea559a8ac9da540a8680482bb Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 16 Apr 2014 19:23:44 +0400 Subject: [PATCH 3/6] added status check --- modules/core/src/mathfuncs.cpp | 12 +++++ modules/core/src/matmul.cpp | 7 +++ modules/core/src/matrix.cpp | 8 +++- modules/core/src/stat.cpp | 28 +++++++---- modules/imgproc/src/accum.cpp | 3 ++ modules/imgproc/src/canny.cpp | 19 +++++--- modules/imgproc/src/color.cpp | 70 +++++++++++++++++++++++++++- modules/imgproc/src/deriv.cpp | 3 ++ modules/imgproc/src/distransform.cpp | 1 + modules/imgproc/src/filter.cpp | 3 ++ modules/imgproc/src/histogram.cpp | 1 + modules/imgproc/src/imgwarp.cpp | 3 ++ modules/imgproc/src/moments.cpp | 1 + modules/imgproc/src/morph.cpp | 1 + modules/imgproc/src/samplers.cpp | 10 ++-- modules/imgproc/src/smooth.cpp | 4 ++ modules/imgproc/src/sumpixels.cpp | 1 + modules/imgproc/src/templmatch.cpp | 14 +++++- modules/imgproc/src/thresh.cpp | 9 ++++ 19 files changed, 175 insertions(+), 23 deletions(-) diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index bb33e952dd..3b45855a5a 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -241,6 +241,7 @@ static void Magnitude_32f(const float* x, const float* y, float* mag, int len) IppStatus status = ippsMagnitude_32f(x, y, mag, len); if (status >= 0) return; + setIppErrorStatus(); #endif int i = 0; @@ -273,6 +274,7 @@ static void Magnitude_64f(const double* x, const double* y, double* mag, int len IppStatus status = ippsMagnitude_64f(x, y, mag, len); if (status >= 0) return; + setIppErrorStatus(); #endif int i = 0; @@ -305,6 +307,7 @@ static void InvSqrt_32f(const float* src, float* dst, int len) #if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) if (ippsInvSqrt_32f_A21(src, dst, len) >= 0) return; + setIppErrorStatus(); #endif int i = 0; @@ -353,6 +356,7 @@ static void Sqrt_32f(const float* src, float* dst, int len) #if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) if (ippsSqrt_32f_A21(src, dst, len) >= 0) return; + setIppErrorStatus(); #endif int i = 0; @@ -386,6 +390,7 @@ static void Sqrt_64f(const double* src, double* dst, int len) #if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) if (ippsSqrt_64f_A50(src, dst, len) >= 0) return; + setIppErrorStatus(); #endif int i = 0; @@ -767,6 +772,7 @@ void polarToCart( InputArray src1, InputArray src2, IppStatus status = ippFunc(Mag.data, Angle.data, X.data, Y.data, static_cast(cn * X.total())); if (status >= 0) return; + setIppErrorStatus(); } #endif @@ -1319,6 +1325,7 @@ static void Exp_32f_ipp(const float *x, float *y, int n) { if (0 <= ippsExp_32f_A21(x, y, n)) return; + setIppErrorStatus(); Exp_32f(x, y, n); } @@ -1326,6 +1333,7 @@ static void Exp_64f_ipp(const double *x, double *y, int n) { if (0 <= ippsExp_64f_A50(x, y, n)) return; + setIppErrorStatus(); Exp_64f(x, y, n); } @@ -1977,6 +1985,7 @@ static void Log_32f_ipp(const float *x, float *y, int n) { if (0 <= ippsLn_32f_A21(x, y, n)) return; + setIppErrorStatus(); Log_32f(x, y, n); } @@ -1984,6 +1993,7 @@ static void Log_64f_ipp(const double *x, double *y, int n) { if (0 <= ippsLn_64f_A50(x, y, n)) return; + setIppErrorStatus(); Log_64f(x, y, n); } @@ -2181,6 +2191,7 @@ void pow( InputArray _src, double power, OutputArray _dst ) if (status >= 0) return; + setIppErrorStatus(); } #endif if (same) @@ -2241,6 +2252,7 @@ void pow( InputArray _src, double power, OutputArray _dst ) if (status >= 0) return; + setIppErrorStatus(); } #endif diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 23735194d3..fb23d1cbbb 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2229,6 +2229,7 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray (const Ipp32f *)src2.data, (int)src2.step, sizeof(Ipp32f), (Ipp32f *)dst.data, (int)dst.step, sizeof(Ipp32f), (int)len, 1) >= 0) return; + setIppErrorStatus(); #endif func(src1.data, src2.data, dst.data, (int)len, palpha); return; @@ -2810,6 +2811,7 @@ static double dotProd_8u(const uchar* src1, const uchar* src2, int len) src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r)) return r; + setIppErrorStatus(); #endif int i = 0; @@ -2870,6 +2872,7 @@ static double dotProd_16u(const ushort* src1, const ushort* src2, int len) double r = 0; if (0 <= ippiDotProd_16u64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r)) return r; + setIppErrorStatus(); #endif return dotProd_(src1, src2, len); } @@ -2880,6 +2883,7 @@ static double dotProd_16s(const short* src1, const short* src2, int len) double r = 0; if (0 <= ippiDotProd_16s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r)) return r; + setIppErrorStatus(); #endif return dotProd_(src1, src2, len); } @@ -2890,6 +2894,7 @@ static double dotProd_32s(const int* src1, const int* src2, int len) double r = 0; if (0 <= ippiDotProd_32s64f_C1R(src1, (int)(len*sizeof(src1[0])), src2, (int)(len*sizeof(src2[0])), ippiSize(len, 1), &r)) return r; + setIppErrorStatus(); #endif return dotProd_(src1, src2, len); } @@ -2900,6 +2905,7 @@ static double dotProd_32f(const float* src1, const float* src2, int len) double r = 0; if (0 <= ippsDotProd_32f64f(src1, src2, len, &r)) return r; + setIppErrorStatus(); #endif return dotProd_(src1, src2, len); } @@ -2910,6 +2916,7 @@ static double dotProd_64f(const double* src1, const double* src2, int len) double r = 0; if (0 <= ippsDotProd_64f(src1, src2, len, &r)) return r; + setIppErrorStatus(); #endif return dotProd_(src1, src2, len); } diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index f7aded7312..d753b97a30 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -3039,8 +3039,12 @@ void cv::transpose( InputArray _src, OutputArray _dst ) type == CV_32FC4 ? (ippiTranspose)ippiTranspose_32f_C4R : 0; IppiSize roiSize = { src.cols, src.rows }; - if (ippFunc != 0 && ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, roiSize) >= 0) - return; + if (ippFunc != 0) + { + if (ippFunc(src.data, (int)src.step, dst.data, (int)dst.step, roiSize) >= 0) + return; + setIppErrorStatus(); + } #endif if( dst.data == src.data ) diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index 66866abb84..e5f10bf447 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -579,11 +579,10 @@ cv::Scalar cv::sum( InputArray _src ) { Scalar sc; for( int i = 0; i < cn; i++ ) - { sc[i] = res[i]; - } return sc; } + setIppErrorStatus(); } } #endif @@ -714,6 +713,7 @@ int cv::countNonZero( InputArray _src ) if (status >= 0) return (Ipp32s)src.total() - count; + setIppErrorStatus(); } #endif @@ -757,9 +757,8 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) { Ipp64f res; if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &res) >= 0 ) - { return Scalar(res); - } + setIppErrorStatus(); } typedef IppStatus (CV_STDCALL* ippiMaskMeanFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *); ippiMaskMeanFuncC3 ippFuncC3 = @@ -776,6 +775,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) { return Scalar(res1, res2, res3); } + setIppErrorStatus(); } } else @@ -809,11 +809,10 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask ) { Scalar sc; for( int i = 0; i < cn; i++ ) - { sc[i] = res[i]; - } return sc; } + setIppErrorStatus(); } } } @@ -977,6 +976,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input { if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, pmean, pstddev) >= 0 ) return; + setIppErrorStatus(); } typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *, Ipp64f *); ippiMaskMeanStdDevFuncC3 ippFuncC3 = @@ -990,6 +990,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 && ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 ) return; + setIppErrorStatus(); } } else @@ -1006,6 +1007,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input { if( ippFuncC1(src.data, (int)src.step[0], sz, pmean, pstddev) >= 0 ) return; + setIppErrorStatus(); } typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC3)(const void *, int, IppiSize, int, Ipp64f *, Ipp64f *); ippiMeanStdDevFuncC3 ippFuncC3 = @@ -1019,6 +1021,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input ippFuncC3(src.data, (int)src.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 && ippFuncC3(src.data, (int)src.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 ) return; + setIppErrorStatus(); } } } @@ -1404,6 +1407,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal, } return; } + setIppErrorStatus(); } } else @@ -1436,6 +1440,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal, } return; } + setIppErrorStatus(); } } } @@ -2076,9 +2081,9 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) { Ipp64f norm; if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 ) - { return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm; - } + + setIppErrorStatus(); } typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *); ippiMaskNormFuncC3 ippFuncC3 = @@ -2114,6 +2119,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) 0; return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm; } + setIppErrorStatus(); } } else @@ -2190,6 +2196,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask ) } return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm; } + setIppErrorStatus(); } } } @@ -2430,6 +2437,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m Ipp64f norm; if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 ) return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm; + setIppErrorStatus(); } } else @@ -2459,6 +2467,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m Ipp64f norm; if( ippFunc(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 ) return (double)norm; + setIppErrorStatus(); } } } @@ -2511,6 +2520,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m Ipp64f norm; if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 ) return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm; + setIppErrorStatus(); } typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *); ippiMaskNormDiffFuncC3 ippFuncC3 = @@ -2546,6 +2556,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m 0; return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm; } + setIppErrorStatus(); } } else @@ -2622,6 +2633,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m } return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm; } + setIppErrorStatus(); } } } diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index 74a63e916c..0e99d74839 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -503,6 +503,7 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m if (status >= 0) return; + setIppErrorStatus(); } } #endif @@ -584,6 +585,7 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2, if (status >= 0) return; + setIppErrorStatus(); } } #endif @@ -663,6 +665,7 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst, if (status >= 0) return; + setIppErrorStatus(); } } #endif diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 65e8173065..3590e290db 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -59,10 +59,14 @@ static bool ippCanny(const Mat& _src, Mat& _dst, float low, float high) int size = 0, size1 = 0; IppiSize roi = { _src.cols, _src.rows }; - ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size); - ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1); + if (ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size) < 0) + return false; + if (ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1) < 0) + return false; size = std::max(size, size1); - ippiCannyGetSize(roi, &size1); + + if (ippiCannyGetSize(roi, &size1) < 0) + return false; size = std::max(size, size1); AutoBuffer buf(size + 64); @@ -286,9 +290,12 @@ void cv::Canny( InputArray _src, OutputArray _dst, #endif #ifdef USE_IPP_CANNY - if( aperture_size == 3 && !L2gradient && 1 == cn && - ippCanny(src, dst, (float)low_thresh, (float)high_thresh) ) - return; + if( aperture_size == 3 && !L2gradient && 1 == cn ) + { + if (ippCanny(src, dst, (float)low_thresh, (float)high_thresh)) + return; + setIppErrorStatus(); + } #endif Mat dx(src.rows, src.cols, CV_16SC(cn)); diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 92a8cdd756..5839cb366c 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -3288,32 +3288,38 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if ( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC3C4RTab[depth], 0, 1, 2)) ) return; + setIppErrorStatus(); } else if( code == CV_BGRA2BGR ) { if ( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiCopyAC4C3RTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_BGR2RGBA ) { if( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC3C4RTab[depth], 2, 1, 0)) ) return; + setIppErrorStatus(); } else if( code == CV_RGBA2BGR ) { if( CvtColorIPPLoop(src, dst, IPPReorderFunctor(ippiSwapChannelsC4C3RTab[depth], 2, 1, 0)) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2BGR ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC3RTab[depth], 2, 1, 0)) ) return; + setIppErrorStatus(); } #if !defined(HAVE_IPP_ICV_ONLY) && (IPP_VERSION_X100 >= 801) else if( code == CV_RGBA2BGRA ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderFunctor(ippiSwapChannelsC4RTab[depth], 2, 1, 0)) ) return; + setIppErrorStatus(); } #endif #endif @@ -3343,24 +3349,29 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R))) return; + setIppErrorStatus(); } else if (code == CV_BGRA2BGR565) { - if (CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], - (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 0, 1, 2, depth))) + if (CvtColorIPPLoopCopy(src, dst, + IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], + (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_RGB2BGR565) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if (code == CV_RGBA2BGR565) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } CV_SUPPRESS_DEPRECATED_END #endif @@ -3392,24 +3403,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R))) return; + setIppErrorStatus(); } else if (code == CV_BGR5652RGB) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } if (code == CV_BGR5652BGRA) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_BGR5652RGBA) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } CV_SUPPRESS_DEPRECATED_END #endif @@ -3432,21 +3447,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC3Tab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2GRAY ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC3Tab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_BGRA2GRAY ) { if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC4Tab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_RGBA2GRAY ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC4Tab[depth])) ) return; + setIppErrorStatus(); } #endif @@ -3484,11 +3503,13 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoop(src, dst, IPPGray2BGRFunctor(ippiCopyP3C3RTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_GRAY2BGRA ) { if( CvtColorIPPLoop(src, dst, IPPGray2BGRAFunctor(ippiCopyP3C3RTab[depth], ippiSwapChannelsC3C4RTab[depth], depth)) ) return; + setIppErrorStatus(); } #endif @@ -3532,24 +3553,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiRGBToYUV_8u_C3R))) return; + setIppErrorStatus(); } else if (code == CV_BGR2YUV && scn == 3 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth))) return; + setIppErrorStatus(); } else if (code == CV_RGB2YUV && scn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_BGR2YUV && scn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiRGBToYUV_8u_C3R, 2, 1, 0, depth))) return; + setIppErrorStatus(); } #endif @@ -3587,24 +3612,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R))) return; + setIppErrorStatus(); } else if (code == CV_YUV2BGR && dcn == 3 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R, ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } else if (code == CV_YUV2RGB && dcn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R, ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_YUV2BGR && dcn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiYUVToRGB_8u_C3R, ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } #endif @@ -3629,21 +3658,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_BGR2XYZ && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2XYZ && scn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2XYZTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2XYZ && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } #endif @@ -3668,21 +3701,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_XYZ2BGR && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } if( code == CV_XYZ2RGB && dcn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiXYZ2RGBTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_XYZ2RGB && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } #endif @@ -3713,41 +3750,49 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_BGR2HSV_FULL && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2HSV_FULL && scn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2HSVTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2HSV_FULL && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HSVTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_BGR2HLS_FULL && scn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_BGR2HLS_FULL && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2HLS_FULL && scn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2HLSTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_RGB2HLS_FULL && scn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2HLSTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } } #endif @@ -3794,41 +3839,49 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_HSV2BGR_FULL && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_HSV2RGB_FULL && dcn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiHSV2RGBTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_HSV2RGB_FULL && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHSV2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_HLS2BGR_FULL && dcn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_HLS2BGR_FULL && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_HLS2RGB_FULL && dcn == 3 ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiHLS2RGBTab[depth])) ) return; + setIppErrorStatus(); } else if( code == CV_HLS2RGB_FULL && dcn == 4 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiHLS2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } } #endif @@ -3868,47 +3921,55 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToLab_8u_C3R))) return; + setIppErrorStatus(); } else if (code == CV_LBGR2Lab && scn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth))) return; + setIppErrorStatus(); } else if (code == CV_LRGB2Lab && scn == 4 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth))) return; + setIppErrorStatus(); } else if (code == CV_LRGB2Luv && scn == 3) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGBToLUVTab[depth]))) return; + setIppErrorStatus(); } else if (code == CV_LRGB2Luv && scn == 4) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGBToLUVTab[depth], 0, 1, 2, depth))) return; + setIppErrorStatus(); } else if (code == CV_LBGR2Luv && scn == 3) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGBToLUVTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } else if (code == CV_LBGR2Luv && scn == 4) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGBToLUVTab[depth], 2, 1, 0, depth))) return; + setIppErrorStatus(); } #endif @@ -3949,24 +4010,28 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R)) ) return; + setIppErrorStatus(); } else if( code == CV_Lab2LBGR && dcn == 4 && depth == CV_8U ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R, ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) ) return; + setIppErrorStatus(); } if( code == CV_Lab2LRGB && dcn == 3 && depth == CV_8U ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R, ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } else if( code == CV_Lab2LRGB && dcn == 4 && depth == CV_8U ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiLabToBGR_8u_C3R, ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; + setIppErrorStatus(); } #endif if( code == CV_Luv2LRGB && dcn == 3 ) @@ -4194,6 +4259,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) #if defined(HAVE_IPP) && !defined(HAVE_IPP_ICV_ONLY) if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiAlphaPremul_8u_AC4R))) return; + setIppErrorStatus(); #endif CvtColorLoop(src, dst, RGBA2mRGBA()); } diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index 326f86cd41..8e79f2a8a4 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -456,6 +456,7 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, Mat src = _src.getMat(), dst = _dst.getMat(); if (IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale)) return; + setIppErrorStatus(); } #endif int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); @@ -498,6 +499,7 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, Mat src = _src.getMat(), dst = _dst.getMat(); if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale)) return; + setIppErrorStatus(); } #endif int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); @@ -630,6 +632,7 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize, if (status >= 0) return; + setIppErrorStatus(); } } #undef IPP_FILTER_LAPLACIAN diff --git a/modules/imgproc/src/distransform.cpp b/modules/imgproc/src/distransform.cpp index 94a5592858..7173fe335e 100644 --- a/modules/imgproc/src/distransform.cpp +++ b/modules/imgproc/src/distransform.cpp @@ -752,6 +752,7 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, roi, _mask) >= 0 ) return; + setIppErrorStatus(); } #endif Mat zpix = src == 0; diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 1af9e9d2f3..a6ab7afb7e 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -1488,7 +1488,10 @@ private: ippBorderRepl, borderValue[0], bufptr) < 0) || (cn == 3 && ippiFilterRowBorderPipeline_32f_C3R(src, step, &dst, roisz, _kx, _ksize, 0, ippBorderRepl, borderValue, bufptr) < 0)) + { + setIppErrorStatus(); return 0; + } return width - _ksize + 1; } #endif diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index ea73547713..339546f9a2 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -1255,6 +1255,7 @@ void cv::calcHist( const Mat* images, int nimages, const int* channels, ihist.convertTo(hist, CV_32F); return; } + setIppErrorStatus(); } #endif diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 03a9d79a3f..d4a74b68cc 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -2424,6 +2424,7 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize, parallel_for_(range, invoker, dst.total()/(double)(1<<16)); if( ok ) return; + setIppErrorStatus(); } } #undef IPP_RESIZE_EPS @@ -4281,6 +4282,7 @@ void cv::warpAffine( InputArray _src, OutputArray _dst, parallel_for_(range, invoker, dst.total()/(double)(1<<16)); if( ok ) return; + setIppErrorStatus(); } #endif */ @@ -4524,6 +4526,7 @@ void cv::warpPerspective( InputArray _src, OutputArray _dst, InputArray _M0, parallel_for_(range, invoker, dst.total()/(double)(1<<16)); if( ok ) return; + setIppErrorStatus(); } #endif */ diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index 8e0749776a..277600c3bf 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -519,6 +519,7 @@ cv::Moments cv::moments( InputArray _src, bool binary ) } ippiMomentFree_64f(moment); } + setIppErrorStatus(); CV_SUPPRESS_DEPRECATED_END } #endif diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 5b13ffc29e..897d19e4e7 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -1466,6 +1466,7 @@ static void morphOp( int op, InputArray _src, OutputArray _dst, #if IPP_VERSION_X100 >= 801 if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) ) return; + setIppErrorStatus(); #endif if (iterations == 0 || kernel.rows*kernel.cols == 1) diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp index 197a7ced65..d3edbbf12a 100644 --- a/modules/imgproc/src/samplers.cpp +++ b/modules/imgproc/src/samplers.cpp @@ -390,9 +390,13 @@ void cv::getRectSubPix( InputArray _image, Size patchSize, Point2f center, srctype == CV_8UC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_8u32f_C1R : srctype == CV_32FC1 && ddepth == CV_32F ? (ippiGetRectSubPixFunc)ippiCopySubpixIntersect_32f_C1R : 0; - if( ippfunc && ippfunc(image.data, (int)image.step, src_size, patch.data, - (int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 ) - return; + if( ippfunc) + { + if (ippfunc(image.data, (int)image.step, src_size, patch.data, + (int)patch.step, win_size, icenter, &minpt, &maxpt) >= 0 ) + return; + setIppErrorStatus(); + } #endif if( depth == CV_8U && ddepth == CV_8U ) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 4318cd1871..300217bb93 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -888,6 +888,7 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, if (status >= 0) \ return; \ } \ + setIppErrorStatus(); \ } while ((void)0, 0) if (stype == CV_8UC1) @@ -1193,6 +1194,7 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, return; } } + setIppErrorStatus(); } #endif @@ -2033,6 +2035,7 @@ void cv::medianBlur( InputArray _src0, OutputArray _dst, int ksize ) if (status >= 0) \ return; \ } \ + setIppErrorStatus(); \ } \ while ((void)0, 0) @@ -2433,6 +2436,7 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d, parallel_for_(Range(0, dst.rows), body, dst.total()/(double)(1<<16)); if( ok ) return; + setIppErrorStatus(); } #endif diff --git a/modules/imgproc/src/sumpixels.cpp b/modules/imgproc/src/sumpixels.cpp index 6802916bab..b86e084429 100755 --- a/modules/imgproc/src/sumpixels.cpp +++ b/modules/imgproc/src/sumpixels.cpp @@ -393,6 +393,7 @@ void cv::integral( InputArray _src, OutputArray _sum, OutputArray _sqsum, Output } if (0 <= status) return; + setIppErrorStatus(); } #endif diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 75ae2f7cc5..91306ed66c 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -423,6 +423,12 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, Size corrsize, int ctype, Point anchor, double delta, int borderType ) { +#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY + if (ipp_crossCorr(img, _templ, corr)) + return; + setIppErrorStatus(); +#endif + const double blockScale = 4.5; const int minBlockSize = 256; std::vector buf; @@ -639,8 +645,12 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, #endif #if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY - if (method == CV_TM_SQDIFF && ipp_sqrDistance(img, templ, result)) - return; + if (method == CV_TM_SQDIFF) + { + if (ipp_sqrDistance(img, templ, result)) + return; + setIppErrorStatus(); + } #endif int cn = img.channels(); diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 17f323a1ad..c4199890e3 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -75,14 +75,17 @@ thresh_8u( const Mat& _src, Mat& _dst, uchar thresh, uchar maxval, int type ) case THRESH_TRUNC: if (0 <= ippiThreshold_GT_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh)) return; + setIppErrorStatus(); break; case THRESH_TOZERO: if (0 <= ippiThreshold_LTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh+1, 0)) return; + setIppErrorStatus(); break; case THRESH_TOZERO_INV: if (0 <= ippiThreshold_GTVal_8u_C1R(_src.data, (int)src_step, _dst.data, (int)dst_step, sz, thresh, 0)) return; + setIppErrorStatus(); break; } #endif @@ -313,14 +316,17 @@ thresh_16s( const Mat& _src, Mat& _dst, short thresh, short maxval, int type ) case THRESH_TRUNC: if (0 <= ippiThreshold_GT_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh)) return; + setIppErrorStatus(); break; case THRESH_TOZERO: if (0 <= ippiThreshold_LTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+1, 0)) return; + setIppErrorStatus(); break; case THRESH_TOZERO_INV: if (0 <= ippiThreshold_GTVal_16s_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0)) return; + setIppErrorStatus(); break; } #endif @@ -504,14 +510,17 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type ) case THRESH_TRUNC: if (0 <= ippiThreshold_GT_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh)) return; + setIppErrorStatus(); break; case THRESH_TOZERO: if (0 <= ippiThreshold_LTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh+FLT_EPSILON, 0)) return; + setIppErrorStatus(); break; case THRESH_TOZERO_INV: if (0 <= ippiThreshold_GTVal_32f_C1R(src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0)) return; + setIppErrorStatus(); break; } #endif From 6f9ca3d77cac2572b20c2a10bf272d652648e20a Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 16 Apr 2014 19:45:35 +0400 Subject: [PATCH 4/6] fixed some errors --- modules/core/src/arithm.cpp | 44 ++++++++++++------------- modules/core/src/matmul.cpp | 8 ----- modules/imgproc/src/deriv.cpp | 62 +++++++++++++++++------------------ 3 files changed, 53 insertions(+), 61 deletions(-) diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index f7256b85fa..966db7106b 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -939,7 +939,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl { int scn = (int)sc.total(), cn = CV_MAT_CN(buftype); size_t esz = CV_ELEM_SIZE(buftype); - getConvertFunc(sc.depth(), buftype)(sc.data, 0, 0, 0, scbuf, 0, Size(std::min(cn, scn), 1), 0); + getConvertFunc(sc.depth(), buftype)(sc.data, 1, 0, 1, scbuf, 1, Size(std::min(cn, scn), 1), 0); // unroll the scalar if( scn < cn ) { @@ -1628,33 +1628,33 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, uchar* dptr = ptrs[2]; if( cvtsrc1 ) { - cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 ); + cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 ); sptr1 = buf1; } if( ptrs[0] == ptrs[1] ) sptr2 = sptr1; else if( cvtsrc2 ) { - cvtsrc2( sptr2, 0, 0, 0, buf2, 0, bszn, 0 ); + cvtsrc2( sptr2, 1, 0, 1, buf2, 1, bszn, 0 ); sptr2 = buf2; } if( !haveMask && !cvtdst ) - func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata ); + func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata ); else { - func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata ); + func( sptr1, 1, sptr2, 1, wbuf, 0, bszn, usrdata ); if( !haveMask ) - cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 ); + cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 ); else if( !cvtdst ) { - copymask( wbuf, 0, ptrs[3], 0, dptr, 0, Size(bsz, 1), &dsz ); + copymask( wbuf, 1, ptrs[3], 1, dptr, 1, Size(bsz, 1), &dsz ); ptrs[3] += bsz; } else { - cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 ); - copymask( maskbuf, 0, ptrs[3], 0, dptr, 0, Size(bsz, 1), &dsz ); + cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 ); + copymask( maskbuf, 1, ptrs[3], 1, dptr, 1, Size(bsz, 1), &dsz ); ptrs[3] += bsz; } } @@ -1695,7 +1695,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, if( cvtsrc1 ) { - cvtsrc1( sptr1, 0, 0, 0, buf1, 0, bszn, 0 ); + cvtsrc1( sptr1, 1, 0, 1, buf1, 1, bszn, 0 ); sptr1 = buf1; } @@ -1703,21 +1703,21 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, std::swap(sptr1, sptr2); if( !haveMask && !cvtdst ) - func( sptr1, 0, sptr2, 0, dptr, 0, bszn, usrdata ); + func( sptr1, 1, sptr2, 1, dptr, 1, bszn, usrdata ); else { - func( sptr1, 0, sptr2, 0, wbuf, 0, bszn, usrdata ); + func( sptr1, 1, sptr2, 1, wbuf, 1, bszn, usrdata ); if( !haveMask ) - cvtdst( wbuf, 0, 0, 0, dptr, 0, bszn, 0 ); + cvtdst( wbuf, 1, 0, 1, dptr, 1, bszn, 0 ); else if( !cvtdst ) { - copymask( wbuf, 0, ptrs[2], 0, dptr, 0, Size(bsz, 1), &dsz ); + copymask( wbuf, 1, ptrs[2], 1, dptr, 1, Size(bsz, 1), &dsz ); ptrs[2] += bsz; } else { - cvtdst( wbuf, 0, 0, 0, maskbuf, 0, bszn, 0 ); - copymask( maskbuf, 0, ptrs[2], 0, dptr, 0, Size(bsz, 1), &dsz ); + cvtdst( wbuf, 1, 0, 1, maskbuf, 1, bszn, 0 ); + copymask( maskbuf, 1, ptrs[2], 1, dptr, 1, Size(bsz, 1), &dsz ); ptrs[2] += bsz; } } @@ -2712,7 +2712,7 @@ static bool ocl_compare(InputArray _src1, InputArray _src2, OutputArray _dst, in else { double fval = 0; - getConvertFunc(depth2, CV_64F)(src2.data, 0, 0, 0, (uchar *)&fval, 0, Size(1, 1), 0); + getConvertFunc(depth2, CV_64F)(src2.data, 1, 0, 1, (uchar *)&fval, 1, Size(1, 1), 0); if( fval < getMinVal(depth1) ) return dst.setTo(Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0)), true; @@ -2833,7 +2833,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op) else { double fval=0; - getConvertFunc(depth2, CV_64F)(src2.data, 0, 0, 0, (uchar*)&fval, 0, Size(1,1), 0); + getConvertFunc(depth2, CV_64F)(src2.data, 1, 0, 1, (uchar*)&fval, 1, Size(1,1), 0); if( fval < getMinVal(depth1) ) { dst = Scalar::all(op == CMP_GT || op == CMP_GE || op == CMP_NE ? 255 : 0); @@ -3060,8 +3060,8 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb, int* iubuf = ilbuf + cn; BinaryFunc sccvtfunc = getConvertFunc(ldepth, CV_32S); - sccvtfunc(lscalar.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0); - sccvtfunc(uscalar.data, 0, 0, 0, (uchar*)iubuf, 0, Size(cn, 1), 0); + sccvtfunc(lscalar.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); + sccvtfunc(uscalar.data, 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); int minval = cvRound(getMinVal(sdepth)), maxval = cvRound(getMaxVal(sdepth)); for( int k = 0; k < cn; k++ ) @@ -3171,8 +3171,8 @@ void cv::inRange(InputArray _src, InputArray _lowerb, int* iubuf = ilbuf + cn; BinaryFunc sccvtfunc = getConvertFunc(scdepth, CV_32S); - sccvtfunc(lb.data, 0, 0, 0, (uchar*)ilbuf, 0, Size(cn, 1), 0); - sccvtfunc(ub.data, 0, 0, 0, (uchar*)iubuf, 0, Size(cn, 1), 0); + sccvtfunc(lb.data, 1, 0, 1, (uchar*)ilbuf, 1, Size(cn, 1), 0); + sccvtfunc(ub.data, 1, 0, 1, (uchar*)iubuf, 1, Size(cn, 1), 0); int minval = cvRound(getMinVal(depth)), maxval = cvRound(getMaxVal(depth)); for( int k = 0; k < cn; k++ ) diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index fb23d1cbbb..df42daca6d 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -2223,14 +2223,6 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray if (src1.isContinuous() && src2.isContinuous() && dst.isContinuous()) { size_t len = src1.total()*cn; -#if defined HAVE_IPP && !defined HAVE_IPP_ICV_ONLY - if (depth == CV_32F && - ippmSaxpy_vava_32f((const Ipp32f *)src1.data, (int)src1.step, sizeof(Ipp32f), falpha, - (const Ipp32f *)src2.data, (int)src2.step, sizeof(Ipp32f), - (Ipp32f *)dst.data, (int)dst.step, sizeof(Ipp32f), (int)len, 1) >= 0) - return; - setIppErrorStatus(); -#endif func(src1.data, src2.data, dst.data, (int)len, palpha); return; } diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index 8e79f2a8a4..c6885d4629 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -201,7 +201,7 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy, switch(src.type()) { - case CV_8U: + case CV_8UC1: { if(scale != 1) return false; @@ -232,14 +232,14 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy, return false; } } - case CV_32F: + case CV_32FC1: #if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R return false; #else { switch(dst.type()) { - case CV_32F: + case CV_32FC1: { if ((dx == 1) && (dy == 0)) { @@ -289,67 +289,64 @@ static bool IPPDerivScharr(const Mat& src, Mat& dst, int ddepth, int dx, int dy, static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int ksize, double scale) { - int bufSize = 0; + int stype = src.type(), dtype = dst.type(), bufSize = 0; cv::AutoBuffer buffer; if (ksize == 3 || ksize == 5) { - if ( ddepth < 0 ) - ddepth = src.depth(); - - if (src.type() == CV_8U && dst.type() == CV_16S && scale == 1) + if (stype == CV_8UC1 && dtype == CV_16SC1 && scale == 1) { - if ((dx == 1) && (dy == 0)) + if (dx == 1 && dy == 0) { if (0 > ippiFilterSobelNegVertGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; buffer.allocate(bufSize); - return (0 <= ippiFilterSobelNegVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, + return 0 <= ippiFilterSobelNegVertBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), - ippBorderRepl, 0, (Ipp8u*)(char*)buffer)); + ippBorderRepl, 0, (Ipp8u*)(char*)buffer); } - if ((dx == 0) && (dy == 1)) + if (dx == 0 && dy == 1) { if (0 > ippiFilterSobelHorizGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; buffer.allocate(bufSize); - return (0 <= ippiFilterSobelHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, + return 0 <= ippiFilterSobelHorizBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), - ippBorderRepl, 0, (Ipp8u*)(char*)buffer)); + ippBorderRepl, 0, (Ipp8u*)(char*)buffer); } - if ((dx == 2) && (dy == 0)) + if (dx == 2 && dy == 0) { if (0 > ippiFilterSobelVertSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; buffer.allocate(bufSize); - return (0 <= ippiFilterSobelVertSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, + return 0 <= ippiFilterSobelVertSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), - ippBorderRepl, 0, (Ipp8u*)(char*)buffer)); + ippBorderRepl, 0, (Ipp8u*)(char*)buffer); } - if ((dx == 0) && (dy == 2)) + if (dx == 0 && dy == 2) { if (0 > ippiFilterSobelHorizSecondGetBufferSize_8u16s_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; buffer.allocate(bufSize); - return (0 <= ippiFilterSobelHorizSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, + return 0 <= ippiFilterSobelHorizSecondBorder_8u16s_C1R((const Ipp8u*)src.data, (int)src.step, (Ipp16s*)dst.data, (int)dst.step, ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), - ippBorderRepl, 0, (Ipp8u*)(char*)buffer)); + ippBorderRepl, 0, (Ipp8u*)(char*)buffer); } } - if (src.type() == CV_32F && dst.type() == CV_32F) + if (stype == CV_32FC1 && dtype == CV_32FC1) { #if defined(HAVE_IPP_ICV_ONLY) // N/A: ippiMulC_32f_C1R return false; #else #if 0 - if ((dx == 1) && (dy == 0)) + if (dx == 1 && dy == 0) { if (0 > ippiFilterSobelNegVertGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize), &bufSize)) return false; @@ -366,7 +363,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k return true; } - if ((dx == 0) && (dy == 1)) + if (dx == 0 && dy == 1) { if (0 > ippiFilterSobelHorizGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; @@ -384,7 +381,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k } #endif - if((dx == 2) && (dy == 0)) + if(dx == 2 && dy == 0) { if (0 > ippiFilterSobelVertSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; @@ -401,7 +398,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k return true; } - if((dx == 0) && (dy == 2)) + if(dx == 0 && dy == 2) { if (0 > ippiFilterSobelHorizSecondGetBufferSize_32f_C1R(ippiSize(src.cols, src.rows), (IppiMaskSize)(ksize*10+ksize),&bufSize)) return false; @@ -422,7 +419,7 @@ static bool IPPDeriv(const Mat& src, Mat& dst, int ddepth, int dx, int dy, int k } } - if(ksize <= 0) + if (ksize <= 0) return IPPDerivScharr(src, dst, ddepth, dx, dy, scale); return false; } @@ -437,7 +434,8 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); if (ddepth < 0) ddepth = sdepth; - _dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) ); + int dtype = CV_MAKE_TYPE(ddepth, cn); + _dst.create( _src.size(), dtype ); #ifdef HAVE_TEGRA_OPTIMIZATION if (scale == 1.0 && delta == 0) @@ -451,12 +449,12 @@ void cv::Sobel( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, #endif #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) - if(dx < 3 && dy < 3 && cn == 1 && borderType == BORDER_REPLICATE) + if (dx < 3 && dy < 3 && cn == 1 && borderType == BORDER_REPLICATE && + ((stype == CV_8UC1 && dtype == CV_16SC1) || (stype == CV_32FC1 && dtype == CV_32FC1))) { Mat src = _src.getMat(), dst = _dst.getMat(); if (IPPDeriv(src, dst, ddepth, dx, dy, ksize,scale)) return; - setIppErrorStatus(); } #endif int ktype = std::max(CV_32F, std::max(ddepth, sdepth)); @@ -482,7 +480,8 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, int stype = _src.type(), sdepth = CV_MAT_DEPTH(stype), cn = CV_MAT_CN(stype); if (ddepth < 0) ddepth = sdepth; - _dst.create( _src.size(), CV_MAKETYPE(ddepth, cn) ); + int dtype = CV_MAKETYPE(ddepth, cn); + _dst.create( _src.size(), dtype ); #ifdef HAVE_TEGRA_OPTIMIZATION if (scale == 1.0 && delta == 0) @@ -494,7 +493,8 @@ void cv::Scharr( InputArray _src, OutputArray _dst, int ddepth, int dx, int dy, #endif #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) - if(dx < 2 && dy < 2 && _src.channels() == 1 && borderType == 1) + if(dx < 2 && dy < 2 && borderType == BORDER_REPLICATE && + ((stype == CV_8UC1 && dtype == CV_16SC1) || (stype == CV_32FC1 && dtype == CV_32FC1))) { Mat src = _src.getMat(), dst = _dst.getMat(); if(IPPDerivScharr(src, dst, ddepth, dx, dy, scale)) From 87eb1b8fccb96e9b10c62ef4d9461b8f8687192c Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Wed, 16 Apr 2014 23:35:39 +0400 Subject: [PATCH 5/6] fixes in imgproc --- modules/imgproc/src/color.cpp | 53 +++++++------- modules/imgproc/src/imgwarp.cpp | 42 +++++------ modules/imgproc/src/moments.cpp | 92 ++++++++++++------------- modules/imgproc/src/morph.cpp | 12 +++- modules/imgproc/src/smooth.cpp | 15 ++-- modules/imgproc/src/templmatch.cpp | 29 ++++---- modules/imgproc/test/ocl/test_color.cpp | 24 ++++--- 7 files changed, 138 insertions(+), 129 deletions(-) diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 5839cb366c..ef198f6159 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -310,8 +310,8 @@ static ippiReorderFunc ippiSwapChannelsC4RTab[] = static ippiColor2GrayFunc ippiColor2GrayC3Tab[] = { - /*(ippiColor2GrayFunc)ippiColorToGray_8u_C3C1R*/ 0, 0, /*(ippiColor2GrayFunc)ippiColorToGray_16u_C3C1R*/ 0, 0, - 0, /*(ippiColor2GrayFunc)ippiColorToGray_32f_C3C1R*/ 0, 0, 0 + (ippiColor2GrayFunc)ippiColorToGray_8u_C3C1R, 0, (ippiColor2GrayFunc)ippiColorToGray_16u_C3C1R, 0, + 0, (ippiColor2GrayFunc)ippiColorToGray_32f_C3C1R, 0, 0 }; static ippiColor2GrayFunc ippiColor2GrayC4Tab[] = @@ -341,18 +341,18 @@ static ippiGeneralFunc ippiCopyP3C3RTab[] = static ippiGeneralFunc ippiRGB2XYZTab[] = { (ippiGeneralFunc)ippiRGBToXYZ_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToXYZ_16u_C3R, 0, - 0, /*(ippiGeneralFunc)ippiRGBToXYZ_32f_C3R*/ 0, 0, 0 + 0, (ippiGeneralFunc)ippiRGBToXYZ_32f_C3R, 0, 0 }; static ippiGeneralFunc ippiXYZ2RGBTab[] = { (ippiGeneralFunc)ippiXYZToRGB_8u_C3R, 0, (ippiGeneralFunc)ippiXYZToRGB_16u_C3R, 0, - 0, /*(ippiGeneralFunc)ippiXYZToRGB_32f_C3R*/ 0, 0, 0 + 0, (ippiGeneralFunc)ippiXYZToRGB_32f_C3R, 0, 0 }; static ippiGeneralFunc ippiRGB2HSVTab[] = { - /*(ippiGeneralFunc)ippiRGBToHSV_8u_C3R*/ 0, 0, /*(ippiGeneralFunc)ippiRGBToHSV_16u_C3R*/ 0, 0, + (ippiGeneralFunc)ippiRGBToHSV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToHSV_16u_C3R, 0, 0, 0, 0, 0 }; @@ -3345,13 +3345,16 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) #if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) CV_SUPPRESS_DEPRECATED_START +#if 0 if (code == CV_BGR2BGR565 && scn == 3) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R))) return; setIppErrorStatus(); } - else if (code == CV_BGRA2BGR565) + else +#endif + if (code == CV_BGRA2BGR565 && scn == 4) { if (CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], @@ -3359,14 +3362,14 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } - else if (code == CV_RGB2BGR565) + else if (code == CV_RGB2BGR565 && scn == 3) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) ) return; setIppErrorStatus(); } - else if (code == CV_RGBA2BGR565) + else if (code == CV_RGBA2BGR565 && scn == 4) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], (ippiGeneralFunc)ippiBGRToBGR565_8u16u_C3R, 2, 1, 0, depth)) ) @@ -3399,27 +3402,27 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) #if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) CV_SUPPRESS_DEPRECATED_START - if (code == CV_BGR5652BGR) + if (code == CV_BGR5652BGR && dcn == 3) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R))) return; setIppErrorStatus(); } - else if (code == CV_BGR5652RGB) + else if (code == CV_BGR5652RGB && dcn == 3) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth))) return; setIppErrorStatus(); } - if (code == CV_BGR5652BGRA) + else if (code == CV_BGR5652BGRA && dcn == 4) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth))) return; setIppErrorStatus(); } - else if (code == CV_BGR5652RGBA) + else if (code == CV_BGR5652RGBA && dcn == 4) { if (CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor((ippiGeneralFunc)ippiBGR565ToBGR_16u8u_C3R, ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth))) @@ -3443,25 +3446,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) dst = _dst.getMat(); #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) - if( code == CV_BGR2GRAY ) + if( code == CV_BGR2GRAY && depth == CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC3Tab[depth])) ) return; setIppErrorStatus(); } - else if( code == CV_RGB2GRAY ) + else if( code == CV_RGB2GRAY && depth == CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC3Tab[depth])) ) return; setIppErrorStatus(); } - else if( code == CV_BGRA2GRAY ) + else if( code == CV_BGRA2GRAY && depth == CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPColor2GrayFunctor(ippiColor2GrayC4Tab[depth])) ) return; setIppErrorStatus(); } - else if( code == CV_RGBA2GRAY ) + else if( code == CV_RGBA2GRAY && depth == CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGB2GrayC4Tab[depth])) ) return; @@ -3654,25 +3657,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) dst = _dst.getMat(); #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) - if( code == CV_BGR2XYZ && scn == 3 ) + if( code == CV_BGR2XYZ && scn == 3 && depth != CV_32F ) { if( CvtColorIPPLoopCopy(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) ) return; setIppErrorStatus(); } - else if( code == CV_BGR2XYZ && scn == 4 ) + else if( code == CV_BGR2XYZ && scn == 4 && depth != CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 2, 1, 0, depth)) ) return; setIppErrorStatus(); } - else if( code == CV_RGB2XYZ && scn == 3 ) + else if( code == CV_RGB2XYZ && scn == 3 && depth != CV_32F ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2XYZTab[depth])) ) return; setIppErrorStatus(); } - else if( code == CV_RGB2XYZ && scn == 4 ) + else if( code == CV_RGB2XYZ && scn == 4 && depth != CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC4C3RTab[depth], ippiRGB2XYZTab[depth], 0, 1, 2, depth)) ) return; @@ -3697,25 +3700,25 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) dst = _dst.getMat(); #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) - if( code == CV_XYZ2BGR && dcn == 3 ) + if( code == CV_XYZ2BGR && dcn == 3 && depth != CV_32F ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3RTab[depth], 2, 1, 0, depth)) ) return; setIppErrorStatus(); } - else if( code == CV_XYZ2BGR && dcn == 4 ) + else if( code == CV_XYZ2BGR && dcn == 4 && depth != CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; setIppErrorStatus(); } - if( code == CV_XYZ2RGB && dcn == 3 ) + if( code == CV_XYZ2RGB && dcn == 3 && depth != CV_32F ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiXYZ2RGBTab[depth])) ) return; setIppErrorStatus(); } - else if( code == CV_XYZ2RGB && dcn == 4 ) + else if( code == CV_XYZ2RGB && dcn == 4 && depth != CV_32F ) { if( CvtColorIPPLoop(src, dst, IPPGeneralReorderFunctor(ippiXYZ2RGBTab[depth], ippiSwapChannelsC3C4RTab[depth], 0, 1, 2, depth)) ) return; @@ -3758,7 +3761,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } - else if( code == CV_RGB2HSV_FULL && scn == 3 ) + else if( code == CV_RGB2HSV_FULL && scn == 3 && depth == CV_16U ) { if( CvtColorIPPLoopCopy(src, dst, IPPGeneralFunctor(ippiRGB2HSVTab[depth])) ) return; diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index d4a74b68cc..eaea144187 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -1876,19 +1876,18 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec return k; } -#define CHECK_IPP_FUNC(FUNC) if( FUNC==0 ) { *ok = false; return;} -#define CHECK_IPP_STATUS(STATUS) if( STATUS!=ippStsNoErr ) { *ok = false; return;} +#define CHECK_IPP_STATUS(STATUS) if (STATUS < 0) { *ok = false; return; } #define SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN) \ - func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\ + func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \ CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\ specBuf.allocate(specSize);\ pSpec = (uchar*)specBuf;\ CHECK_IPP_STATUS(ippiResizeLinearInit_##TYPE(srcSize, dstSize, (IppiResizeSpec_32f*)pSpec)); #define SET_IPP_RESIZE_LINEAR_FUNC_64_PTR(TYPE, CN) \ - if (mode==(int)ippCubic) { *ok = false; return;}\ - func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\ + if (mode == (int)ippCubic) { *ok = false; return; } \ + func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \ CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\ specBuf.allocate(specSize);\ pSpec = (uchar*)specBuf;\ @@ -1897,19 +1896,19 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec getSrcOffsetFunc = (ippiResizeGetSrcOffset) ippiResizeGetBufferSize_##TYPE; #define SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN) \ - func = (ippiResizeFunc)ippiResizeCubic_##TYPE##_##CN##R; CHECK_IPP_FUNC(func);\ + func = (ippiResizeFunc)ippiResizeCubic_##TYPE##_##CN##R; \ CHECK_IPP_STATUS(ippiResizeGetSize_##TYPE(srcSize, dstSize, (IppiInterpolationType)mode, 0, &specSize, &initSize));\ specBuf.allocate(specSize);\ pSpec = (uchar*)specBuf;\ AutoBuffer buf(initSize);\ uchar* pInit = (uchar*)buf;\ - CHECK_IPP_STATUS(ippiResizeCubicInit_##TYPE(srcSize, dstSize, 0.f, 0.75f, (IppiResizeSpec_32f*)pSpec, pInit)); + CHECK_IPP_STATUS(ippiResizeCubicInit_##TYPE(srcSize, dstSize, 0.f, 0.75f, (IppiResizeSpec_32f*)pSpec, pInit)); #define SET_IPP_RESIZE_PTR(TYPE, CN) \ - if (mode == (int)ippLinear) { SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN);}\ - else if (mode == (int)ippCubic) { SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN);}\ - else { *ok = false; return;}\ - getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE;\ + if (mode == (int)ippLinear) { SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN);} \ + else if (mode == (int)ippCubic) { SET_IPP_RESIZE_CUBIC_FUNC_PTR(TYPE, CN);} \ + else { *ok = false; return; } \ + getBufferSizeFunc = (ippiResizeGetBufferSize)ippiResizeGetBufferSize_##TYPE; \ getSrcOffsetFunc = (ippiResizeGetSrcOffset)ippiResizeGetSrcOffset_##TYPE; #if !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 701 @@ -2392,29 +2391,26 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize, return; #endif - int depth = src.depth(), cn = src.channels(); + int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); double scale_x = 1./inv_scale_x, scale_y = 1./inv_scale_y; int k, sx, sy, dx, dy; #if !defined(HAVE_IPP_ICV_ONLY) && IPP_VERSION_X100 >= 701 -#define IPP_RESIZE_EPS 1.e-10 +#define IPP_RESIZE_EPS 1e-10 - double ex = fabs((double)dsize.width/src.cols - inv_scale_x)/inv_scale_x; - double ey = fabs((double)dsize.height/src.rows - inv_scale_y)/inv_scale_y; + double ex = fabs((double)dsize.width / src.cols - inv_scale_x) / inv_scale_x; + double ey = fabs((double)dsize.height / src.rows - inv_scale_y) / inv_scale_y; - if ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || - (ex == 0 && ey == 0 && depth == CV_64F)) + if ( ((ex < IPP_RESIZE_EPS && ey < IPP_RESIZE_EPS && depth != CV_64F) || (ex == 0 && ey == 0 && depth == CV_64F)) && + (interpolation == INTER_LINEAR || interpolation == INTER_CUBIC)) { - int mode = 0; + int mode = -1; if (interpolation == INTER_LINEAR && src.rows >= 2 && src.cols >= 2) - { mode = ippLinear; - } else if (interpolation == INTER_CUBIC && src.rows >= 4 && src.cols >= 4) - { mode = ippCubic; - } - if( mode != 0 && (cn == 1 || cn ==3 || cn == 4) && + + if( mode >= 0 && (cn == 1 || cn == 3 || cn == 4) && (depth == CV_8U || depth == CV_16U || depth == CV_16S || depth == CV_32F || (depth == CV_64F && mode == ippLinear))) { diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index 277600c3bf..f65d6d906e 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -444,19 +444,15 @@ cv::Moments cv::moments( InputArray _src, bool binary ) MomentsInTileFunc func = 0; uchar nzbuf[TILE_SIZE*TILE_SIZE]; Moments m; - int type = _src.type(); - int depth = CV_MAT_DEPTH( type ); - int cn = CV_MAT_CN( type ); + int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); Size size = _src.size(); if( size.width <= 0 || size.height <= 0 ) return m; #ifdef HAVE_OPENCL - if( ocl::useOpenCL() && type == CV_8UC1 && !binary && - _src.isUMat() && ocl_moments(_src, m) ) - ; - else + if( !(ocl::useOpenCL() && type == CV_8UC1 && !binary && + _src.isUMat() && ocl_moments(_src, m)) ) #endif { Mat mat = _src.getMat(); @@ -469,57 +465,61 @@ cv::Moments cv::moments( InputArray _src, bool binary ) #if IPP_VERSION_X100 >= 801 && !defined HAVE_IPP_ICV_ONLY if (!binary) { - IppiSize roi = {mat.cols, mat.rows}; - IppiMomentState_64f *moment; + IppiSize roi = { mat.cols, mat.rows }; + IppiMomentState_64f * moment = NULL; // ippiMomentInitAlloc_64f, ippiMomentFree_64f are deprecated in 8.1, but there are not another way // to initialize IppiMomentState_64f. When GetStateSize and Init functions will appear we have to // change our code. CV_SUPPRESS_DEPRECATED_START - if (0 <= ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate)) + if (ippiMomentInitAlloc_64f(&moment, ippAlgHintAccurate) >= 0) { - IppStatus sts = (IppStatus)(-1); - if (depth == CV_8U) - sts = ippiMoments64f_8u_C1R((const Ipp8u *)mat.data, (int)mat.step, roi, moment); - else if( depth == CV_16U ) - sts = ippiMoments64f_16u_C1R((const Ipp16u *)mat.data, (int)mat.step, roi, moment); - else if( depth == CV_32F ) - sts = ippiMoments64f_32f_C1R((const Ipp32f *)mat.data, (int)mat.step, roi, moment); - if (0 <= sts) + typedef IppStatus (CV_STDCALL * ippiMoments)(const void * pSrc, int srcStep, IppiSize roiSize, IppiMomentState_64f* pCtx); + ippiMoments ippFunc = + type == CV_8UC1 ? (ippiMoments)ippiMoments64f_8u_C1R : + type == CV_16UC1 ? (ippiMoments)ippiMoments64f_16u_C1R : + type == CV_32FC1? (ippiMoments)ippiMoments64f_32f_C1R : 0; + + if (ippFunc) { - IppiPoint point = {0, 0}; - ippiGetSpatialMoment_64f(moment, 0, 0, 0, point, &m.m00); - ippiGetSpatialMoment_64f(moment, 1, 0, 0, point, &m.m10); - ippiGetSpatialMoment_64f(moment, 0, 1, 0, point, &m.m01); + if (ippFunc(mat.data, (int)mat.step, roi, moment) >= 0) + { + IppiPoint point = { 0, 0 }; + ippiGetSpatialMoment_64f(moment, 0, 0, 0, point, &m.m00); + ippiGetSpatialMoment_64f(moment, 1, 0, 0, point, &m.m10); + ippiGetSpatialMoment_64f(moment, 0, 1, 0, point, &m.m01); - ippiGetSpatialMoment_64f(moment, 2, 0, 0, point, &m.m20); - ippiGetSpatialMoment_64f(moment, 1, 1, 0, point, &m.m11); - ippiGetSpatialMoment_64f(moment, 0, 2, 0, point, &m.m02); + ippiGetSpatialMoment_64f(moment, 2, 0, 0, point, &m.m20); + ippiGetSpatialMoment_64f(moment, 1, 1, 0, point, &m.m11); + ippiGetSpatialMoment_64f(moment, 0, 2, 0, point, &m.m02); - ippiGetSpatialMoment_64f(moment, 3, 0, 0, point, &m.m30); - ippiGetSpatialMoment_64f(moment, 2, 1, 0, point, &m.m21); - ippiGetSpatialMoment_64f(moment, 1, 2, 0, point, &m.m12); - ippiGetSpatialMoment_64f(moment, 0, 3, 0, point, &m.m03); - ippiGetCentralMoment_64f(moment, 2, 0, 0, &m.mu20); - ippiGetCentralMoment_64f(moment, 1, 1, 0, &m.mu11); - ippiGetCentralMoment_64f(moment, 0, 2, 0, &m.mu02); - ippiGetCentralMoment_64f(moment, 3, 0, 0, &m.mu30); - ippiGetCentralMoment_64f(moment, 2, 1, 0, &m.mu21); - ippiGetCentralMoment_64f(moment, 1, 2, 0, &m.mu12); - ippiGetCentralMoment_64f(moment, 0, 3, 0, &m.mu03); - ippiGetNormalizedCentralMoment_64f(moment, 2, 0, 0, &m.nu20); - ippiGetNormalizedCentralMoment_64f(moment, 1, 1, 0, &m.nu11); - ippiGetNormalizedCentralMoment_64f(moment, 0, 2, 0, &m.nu02); - ippiGetNormalizedCentralMoment_64f(moment, 3, 0, 0, &m.nu30); - ippiGetNormalizedCentralMoment_64f(moment, 2, 1, 0, &m.nu21); - ippiGetNormalizedCentralMoment_64f(moment, 1, 2, 0, &m.nu12); - ippiGetNormalizedCentralMoment_64f(moment, 0, 3, 0, &m.nu03); + ippiGetSpatialMoment_64f(moment, 3, 0, 0, point, &m.m30); + ippiGetSpatialMoment_64f(moment, 2, 1, 0, point, &m.m21); + ippiGetSpatialMoment_64f(moment, 1, 2, 0, point, &m.m12); + ippiGetSpatialMoment_64f(moment, 0, 3, 0, point, &m.m03); + ippiGetCentralMoment_64f(moment, 2, 0, 0, &m.mu20); + ippiGetCentralMoment_64f(moment, 1, 1, 0, &m.mu11); + ippiGetCentralMoment_64f(moment, 0, 2, 0, &m.mu02); + ippiGetCentralMoment_64f(moment, 3, 0, 0, &m.mu30); + ippiGetCentralMoment_64f(moment, 2, 1, 0, &m.mu21); + ippiGetCentralMoment_64f(moment, 1, 2, 0, &m.mu12); + ippiGetCentralMoment_64f(moment, 0, 3, 0, &m.mu03); + ippiGetNormalizedCentralMoment_64f(moment, 2, 0, 0, &m.nu20); + ippiGetNormalizedCentralMoment_64f(moment, 1, 1, 0, &m.nu11); + ippiGetNormalizedCentralMoment_64f(moment, 0, 2, 0, &m.nu02); + ippiGetNormalizedCentralMoment_64f(moment, 3, 0, 0, &m.nu30); + ippiGetNormalizedCentralMoment_64f(moment, 2, 1, 0, &m.nu21); + ippiGetNormalizedCentralMoment_64f(moment, 1, 2, 0, &m.nu12); + ippiGetNormalizedCentralMoment_64f(moment, 0, 3, 0, &m.nu03); - ippiMomentFree_64f(moment); - return m; + ippiMomentFree_64f(moment); + return m; + } + setIppErrorStatus(); } ippiMomentFree_64f(moment); } - setIppErrorStatus(); + else + setIppErrorStatus(); CV_SUPPRESS_DEPRECATED_END } #endif diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 897d19e4e7..56b24b6068 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -1269,10 +1269,13 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst, int borderType, const Scalar &borderValue) { Mat src = _src.getMat(), kernel = _kernel; - if( !( src.depth() == CV_8U || src.depth() == CV_32F ) || ( iterations > 1 ) || + int type = src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); + + if( !( depth == CV_8U || depth == CV_32F ) || !(cn == 1 || cn == 3 || cn == 4) || !( borderType == cv::BORDER_REPLICATE || (borderType == cv::BORDER_CONSTANT && borderValue == morphologyDefaultBorderValue()) ) || !( op == MORPH_DILATE || op == MORPH_ERODE) ) return false; + if( borderType == cv::BORDER_CONSTANT && kernel.data ) { int x, y; @@ -1331,7 +1334,11 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst, if( iterations > 1 ) return false; - return IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel ); + if (IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel )) + return true; + + setIppErrorStatus(); + return false; } #endif @@ -1466,7 +1473,6 @@ static void morphOp( int op, InputArray _src, OutputArray _dst, #if IPP_VERSION_X100 >= 801 if( IPPMorphOp(op, _src, _dst, kernel, anchor, iterations, borderType, borderValue) ) return; - setIppErrorStatus(); #endif if (iterations == 0 || kernel.rows*kernel.cols == 1) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 300217bb93..9491157934 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -867,11 +867,11 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, ippAnchor.y = ksize.height / 2 - (ksize.height % 2 == 0 ? 1 : 0); if (normalize && !src.isSubmatrix() && ddepth == sdepth && - (ippBorderType == BORDER_REPLICATE || ippBorderType == BORDER_CONSTANT) && - ocvAnchor == ippAnchor ) + (/*ippBorderType == BORDER_REPLICATE ||*/ /* returns ippStsStepErr: Step value is not valid */ + ippBorderType == BORDER_CONSTANT) && ocvAnchor == ippAnchor ) { - Ipp32s bufSize; - IppiSize roiSize = ippiSize(dst.cols, dst.rows), maskSize = ippiSize(ksize.width, ksize.height); + Ipp32s bufSize = 0; + IppiSize roiSize = { dst.cols, dst.rows }, maskSize = { ksize.width, ksize.height }; #define IPP_FILTER_BOX_BORDER(ippType, ippDataType, flavor) \ do \ @@ -880,11 +880,12 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth, { \ Ipp8u * buffer = ippsMalloc_8u(bufSize); \ ippType borderValue[4] = { 0, 0, 0, 0 }; \ - ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderType == BORDER_REPLICATE ? ippBorderRepl : -1; \ - CV_Assert(ippBorderType >= 0); \ - IppStatus status = ippiFilterBoxBorder_##flavor((ippType *)src.data, (int)src.step, (ippType *)dst.data, (int)dst.step, roiSize, maskSize, \ + ippBorderType = ippBorderType == BORDER_CONSTANT ? ippBorderConst : ippBorderRepl; \ + IppStatus status = ippiFilterBoxBorder_##flavor((const ippType *)src.data, (int)src.step, (ippType *)dst.data, \ + (int)dst.step, roiSize, maskSize, \ (IppiBorderType)ippBorderType, borderValue, buffer); \ ippsFree(buffer); \ + printf("%s %d %d\n", ippGetStatusString(status), (int)src.step, (int)dst.step); \ if (status >= 0) \ return; \ } \ diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 91306ed66c..05e31f14e4 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -347,9 +347,6 @@ typedef IppStatus (CV_STDCALL * ippimatchTemplate)(const void*, int, IppiSize, c static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst) { - if (src.channels()!= 1) - return false; - IppStatus status; IppiSize srcRoiSize = {src.cols,src.rows}; @@ -383,9 +380,6 @@ static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst) static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst) { - if (src.channels()!= 1) - return false; - IppStatus status; IppiSize srcRoiSize = {src.cols,src.rows}; @@ -423,12 +417,6 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, Size corrsize, int ctype, Point anchor, double delta, int borderType ) { -#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY - if (ipp_crossCorr(img, _templ, corr)) - return; - setIppErrorStatus(); -#endif - const double blockScale = 4.5; const int minBlockSize = 256; std::vector buf; @@ -613,8 +601,9 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, int method ) { + int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED ); - CV_Assert( (_img.depth() == CV_8U || _img.depth() == CV_32F) && _img.type() == _templ.type() && _img.dims() <= 2 ); + CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 ); bool needswap = _img.size().height < _templ.size().height || _img.size().width < _templ.size().width; if (needswap) @@ -645,7 +634,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, #endif #if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY - if (method == CV_TM_SQDIFF) + if (method == CV_TM_SQDIFF && cn == 1) { if (ipp_sqrDistance(img, templ, result)) return; @@ -653,10 +642,16 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, } #endif - int cn = img.channels(); - #if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7 && !defined HAVE_IPP_ICV_ONLY - if (!ipp_crossCorr(img, templ, result)) + if (cn == 1) + { + if (!ipp_crossCorr(img, templ, result)) + { + setIppErrorStatus(); + crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0); + } + } + else #endif crossCorr( img, templ, result, result.size(), result.type(), Point(0,0), 0, 0); diff --git a/modules/imgproc/test/ocl/test_color.cpp b/modules/imgproc/test/ocl/test_color.cpp index 62962002f0..0fdcd6092f 100644 --- a/modules/imgproc/test/ocl/test_color.cpp +++ b/modules/imgproc/test/ocl/test_color.cpp @@ -175,17 +175,25 @@ OCL_TEST_P(CvtColor, XYZ2BGRA) { performTest(3, 4, CVTCODE(XYZ2BGR), IPP_EPS); } // RGB <-> HSV +#if IPP_VERSION_X100 > 0 +#define IPP_EPS depth <= CV_32S ? 1 : 4e-5 +#else +#define IPP_EPS 1e-3 +#endif + typedef CvtColor CvtColor8u32f; -OCL_TEST_P(CvtColor8u32f, RGB2HSV) { performTest(3, 3, CVTCODE(RGB2HSV)); } -OCL_TEST_P(CvtColor8u32f, BGR2HSV) { performTest(3, 3, CVTCODE(BGR2HSV)); } -OCL_TEST_P(CvtColor8u32f, RGBA2HSV) { performTest(4, 3, CVTCODE(RGB2HSV)); } -OCL_TEST_P(CvtColor8u32f, BGRA2HSV) { performTest(4, 3, CVTCODE(BGR2HSV)); } +OCL_TEST_P(CvtColor8u32f, RGB2HSV) { performTest(3, 3, CVTCODE(RGB2HSV), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, BGR2HSV) { performTest(3, 3, CVTCODE(BGR2HSV), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, RGBA2HSV) { performTest(4, 3, CVTCODE(RGB2HSV), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, BGRA2HSV) { performTest(4, 3, CVTCODE(BGR2HSV), IPP_EPS); } -OCL_TEST_P(CvtColor8u32f, RGB2HSV_FULL) { performTest(3, 3, CVTCODE(RGB2HSV_FULL)); } -OCL_TEST_P(CvtColor8u32f, BGR2HSV_FULL) { performTest(3, 3, CVTCODE(BGR2HSV_FULL)); } -OCL_TEST_P(CvtColor8u32f, RGBA2HSV_FULL) { performTest(4, 3, CVTCODE(RGB2HSV_FULL)); } -OCL_TEST_P(CvtColor8u32f, BGRA2HSV_FULL) { performTest(4, 3, CVTCODE(BGR2HSV_FULL)); } +OCL_TEST_P(CvtColor8u32f, RGB2HSV_FULL) { performTest(3, 3, CVTCODE(RGB2HSV_FULL), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, BGR2HSV_FULL) { performTest(3, 3, CVTCODE(BGR2HSV_FULL), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, RGBA2HSV_FULL) { performTest(4, 3, CVTCODE(RGB2HSV_FULL), IPP_EPS); } +OCL_TEST_P(CvtColor8u32f, BGRA2HSV_FULL) { performTest(4, 3, CVTCODE(BGR2HSV_FULL), IPP_EPS); } + +#undef IPP_EPS OCL_TEST_P(CvtColor8u32f, HSV2RGB) { performTest(3, 3, CVTCODE(HSV2RGB), depth == CV_8U ? 1 : 4e-1); } OCL_TEST_P(CvtColor8u32f, HSV2BGR) { performTest(3, 3, CVTCODE(HSV2BGR), depth == CV_8U ? 1 : 4e-1); } From 05a47d9014d6fa003bcae375203740f461b7705c Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 17 Apr 2014 15:21:30 +0400 Subject: [PATCH 6/6] cmd option --- modules/core/include/opencv2/core/base.hpp | 4 ++- modules/core/include/opencv2/core/private.hpp | 2 ++ modules/core/src/system.cpp | 9 ++++-- modules/imgproc/src/color.cpp | 11 +++++-- modules/imgproc/src/imgwarp.cpp | 2 +- modules/imgproc/src/morph.cpp | 1 - modules/ts/include/opencv2/ts.hpp | 7 +++-- modules/ts/include/opencv2/ts/ts_ext.hpp | 19 +++++++----- modules/ts/src/ts.cpp | 29 +++++++++++++++++++ modules/ts/src/ts_perf.cpp | 7 ++++- 10 files changed, 72 insertions(+), 19 deletions(-) diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index d081d353ad..1830ded92e 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -560,12 +560,14 @@ namespace cudev template class GpuMat_; } +namespace ipp +{ CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL, int line = 0); CV_EXPORTS int getIppStatus(); CV_EXPORTS String getIppErrorLocation(); -#define setIppErrorStatus() setIppStatus(-1, CV_Func, __FILE__, __LINE__) +} // ipp } // cv #endif //__OPENCV_CORE_BASE_HPP__ diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index 8857fa378f..a9210a18ba 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -218,6 +218,8 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un # endif # define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR) +#define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__) + static inline IppiSize ippiSize(int width, int height) { IppiSize size = { width, height }; diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 6081a60841..6296fe5180 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -1063,9 +1063,12 @@ TLSStorage::~TLSStorage() TLSData coreTlsData; +namespace ipp +{ + static int ippStatus = 0; // 0 - all is ok, -1 - IPP functions failed -static const char * funcname, * filename; -static int linen; +static const char * funcname = NULL, * filename = NULL; +static int linen = 0; void setIppStatus(int status, const char * const _funcname, const char * const _filename, int _line) { @@ -1085,6 +1088,8 @@ String getIppErrorLocation() return format("%s:%d %s", filename ? filename : "", linen, funcname ? funcname : ""); } +} // namespace ipp + } // namespace cv /* End of file. */ diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index ef198f6159..9c04d1cd63 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -374,7 +374,7 @@ static ippiGeneralFunc ippiHLS2RGBTab[] = 0, (ippiGeneralFunc)ippiHLSToRGB_32f_C3R, 0, 0 }; -#if !defined(HAVE_IPP_ICV_ONLY) +#if !defined(HAVE_IPP_ICV_ONLY) && 0 static ippiGeneralFunc ippiRGBToLUVTab[] = { (ippiGeneralFunc)ippiRGBToLUV_8u_C3R, 0, (ippiGeneralFunc)ippiRGBToLUV_16u_C3R, 0, @@ -3920,6 +3920,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) dst = _dst.getMat(); #if defined HAVE_IPP && !defined(HAVE_IPP_ICV_ONLY) +#if 0 if (code == CV_LBGR2Lab && scn == 3 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor((ippiGeneralFunc)ippiBGRToLab_8u_C3R))) @@ -3933,7 +3934,9 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } - else if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U) + else +#endif + if (code == CV_LRGB2Lab && scn == 3 && depth == CV_8U) { if (CvtColorIPPLoop(src, dst, IPPReorderGeneralFunctor(ippiSwapChannelsC3RTab[depth], (ippiGeneralFunc)ippiBGRToLab_8u_C3R, 2, 1, 0, depth))) @@ -3947,6 +3950,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } +#if 0 else if (code == CV_LRGB2Luv && scn == 3) { if (CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiRGBToLUVTab[depth]))) @@ -3974,6 +3978,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } +#endif #endif if( code == CV_BGR2Lab || code == CV_RGB2Lab || @@ -4036,7 +4041,6 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) return; setIppErrorStatus(); } -#endif if( code == CV_Luv2LRGB && dcn == 3 ) { if( CvtColorIPPLoop(src, dst, IPPGeneralFunctor(ippiLUVToRGBTab[depth])) ) @@ -4060,6 +4064,7 @@ void cv::cvtColor( InputArray _src, OutputArray _dst, int code, int dcn ) ippiSwapChannelsC3C4RTab[depth], 2, 1, 0, depth)) ) return; } +#endif #endif if( code == CV_Lab2BGR || code == CV_Lab2RGB || diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index eaea144187..16ad5552d2 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -1876,7 +1876,7 @@ static int computeResizeAreaTab( int ssize, int dsize, int cn, double scale, Dec return k; } -#define CHECK_IPP_STATUS(STATUS) if (STATUS < 0) { *ok = false; return; } +#define CHECK_IPP_STATUS(STATUS) if (STATUS != 0) { *ok = false; return; } #define SET_IPP_RESIZE_LINEAR_FUNC_PTR(TYPE, CN) \ func = (ippiResizeFunc)ippiResizeLinear_##TYPE##_##CN##R; \ diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 56b24b6068..e76f8ab4ed 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -1337,7 +1337,6 @@ static bool IPPMorphOp(int op, InputArray _src, OutputArray _dst, if (IPPMorphReplicate( op, src, dst, kernel, ksize, anchor, rectKernel )) return true; - setIppErrorStatus(); return false; } #endif diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp index 07f9845b76..c58d31969b 100644 --- a/modules/ts/include/opencv2/ts.hpp +++ b/modules/ts/include/opencv2/ts.hpp @@ -554,15 +554,17 @@ CV_EXPORTS void printVersionInfo(bool useStdOut = true); #endif #endif -#if defined(HAVE_OPENCL) +#ifdef HAVE_OPENCL namespace cvtest { namespace ocl { void dumpOpenCLDevice(); -}} +} } #define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice(); #else #define TEST_DUMP_OCL_INFO #endif +void parseCustomOptions(int argc, char **argv); + #define CV_TEST_MAIN(resourcesubdir, ...) \ int main(int argc, char **argv) \ { \ @@ -571,6 +573,7 @@ int main(int argc, char **argv) \ cvtest::printVersionInfo(); \ __CV_TEST_EXEC_ARGS(__VA_ARGS__) \ TEST_DUMP_OCL_INFO \ + parseCustomOptions(argc, argv); \ return RUN_ALL_TESTS(); \ } diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp index 97349a9a2e..08039baded 100644 --- a/modules/ts/include/opencv2/ts/ts_ext.hpp +++ b/modules/ts/include/opencv2/ts/ts_ext.hpp @@ -1,11 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +// Copyright (C) 2014, Intel, Inc., all rights reserved. +// Third party copyrights are property of their respective owners. + #ifndef __OPENCV_TS_EXT_HPP__ #define __OPENCV_TS_EXT_HPP__ -#define CHECK_IPP_STATUS \ - do \ - { \ - EXPECT_LE(0, getIppStatus()) << getIppErrorLocation().c_str(); \ - } while ((void)0, 0) +void checkIppStatus(); #undef TEST #define TEST(test_case_name, test_name) \ @@ -29,7 +32,7 @@ ::testing::Test::TearDownTestCase, \ new ::testing::internal::TestFactoryImpl<\ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ - void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body() #undef TEST_F @@ -54,7 +57,7 @@ test_fixture::TearDownTestCase, \ new ::testing::internal::TestFactoryImpl<\ GTEST_TEST_CLASS_NAME_(test_fixture, test_name)>);\ - void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \ void GTEST_TEST_CLASS_NAME_(test_fixture, test_name)::Body() #undef TEST_P @@ -83,7 +86,7 @@ int GTEST_TEST_CLASS_NAME_(test_case_name, \ test_name)::gtest_registering_dummy_ = \ GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ - void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { setIppStatus(0); Body(); CHECK_IPP_STATUS; } \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() { cv::ipp::setIppStatus(0); Body(); checkIppStatus(); } \ void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::Body() #endif // __OPENCV_TS_EXT_HPP__ diff --git a/modules/ts/src/ts.cpp b/modules/ts/src/ts.cpp index 45aaadf13c..29fd056fea 100644 --- a/modules/ts/src/ts.cpp +++ b/modules/ts/src/ts.cpp @@ -658,4 +658,33 @@ void smoothBorder(Mat& img, const Scalar& color, int delta) } //namespace cvtest +bool test_ipp_check = false; + +void checkIppStatus() +{ + if (test_ipp_check) + { + int status = cv::ipp::getIppStatus(); + EXPECT_LE(0, status) << cv::ipp::getIppErrorLocation().c_str(); + } +} + +void parseCustomOptions(int argc, char **argv) +{ + const char * const command_line_keys = + "{ ipp test_ipp_check |false |check whether IPP works without failures }" + "{ h help |false |print help info }"; + + cv::CommandLineParser parser(argc, argv, command_line_keys); + if (parser.get("help")) + { + std::cout << "\nAvailable options besides google test option: \n"; + parser.printMessage(); + } + + test_ipp_check = parser.get("test_ipp_check"); + if (!test_ipp_check) + test_ipp_check = getenv("OPENCV_IPP_CHECK") != NULL; +} + /* End of file. */ diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 25981a7219..c5d4be5c2b 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -31,6 +31,7 @@ static double param_time_limit; static int param_threads; static bool param_write_sanity; static bool param_verify_sanity; +extern bool test_ipp_check; #ifdef HAVE_CUDA static int param_cuda_device; #endif @@ -670,6 +671,9 @@ void TestBase::Init(const std::vector & availableImpls, "{ perf_time_limit |3.0 |default time limit for a single test (in seconds)}" #endif "{ perf_max_deviation |1.0 |}" +#ifdef HAVE_IPP + "{ perf_ipp_check |false |check whether IPP works without failures}" +#endif "{ help h |false |print help info}" #ifdef HAVE_CUDA "{ perf_cuda_device |0 |run CUDA test suite onto specific CUDA capable device}" @@ -713,7 +717,8 @@ void TestBase::Init(const std::vector & availableImpls, param_force_samples = args.get("perf_force_samples"); param_write_sanity = args.has("perf_write_sanity"); param_verify_sanity = args.has("perf_verify_sanity"); - param_threads = args.get("perf_threads"); + test_ipp_check = !args.has("perf_ipp_check") ? getenv("OPENCV_IPP_CHECK") != NULL : true; + param_threads = args.get("perf_threads"); #ifdef ANDROID param_affinity_mask = args.get("perf_affinity_mask"); log_power_checkpoints = args.has("perf_log_power_checkpoints");