Merge remote-tracking branch 'upstream/2.4' into merge-2.4
* #1538 from StevenPuttemans:bugfix_3283 * #1545 from alalek:ocl_test_fix_rng * #1551 from alalek:cmake_install_win * #1570 from ilya-lavrenov:ipp_warn_fix * #1573 from alalek:perf_simple_strategy * #1574 from alalek:svm_workaround * #1576 from alalek:ocl_fix_cl_double * #1577 from ilya-lavrenov:ocl_setto_opencl12 * #1578 from asmorkalov:android_fd_cp_fix * #1579 from ilya-lavrenov:ocl_norm * #1582 from sperrholz:ocl-arithm-additions * #1586 from ilya-lavrenov:ocl_setto_win_fix * #1589 from ilya-lavrenov:pr1582_fix * #1591 from alalek:ocl_remove_cl_hpp_h * #1592 from alalek:ocl_program_cache_update * #1593 from ilya-lavrenov:ocl_war_on_double * #1594 from ilya-lavrenov:ocl_perf * #1595 from alalek:cl_code_cleanup * #1596 from alalek:test_fix_run_py * #1597 from alalek:ocl_fix_cleanup * #1598 from alalek:ocl_fix_build_mac * #1599 from ilya-lavrenov:ocl_mac_kernel_warnings * #1601 from ilya-lavrenov:ocl_fix_tvl1_and_sparse * #1602 from alalek:ocl_test_dump_info * #1603 from ilya-lavrenov:ocl_disable_svm_noblas * #1605 from alalek:ocl_fixes * #1606 from ilya-lavrenov:ocl_imgproc * #1607 from ilya-lavrenov:ocl_fft_cleanup * #1608 from alalek:fix_warn_upd_haar * #1609 from ilya-lavrenov:ocl_some_optimization * #1610 from alalek:ocl_fix_perf_kalman * #1612 from alalek:ocl_fix_string_info * #1614 from ilya-lavrenov:ocl_svm_misprint * #1616 from ilya-lavrenov:ocl_cvtColor * #1617 from ilya-lavrenov:ocl_info * #1622 from a0byte:2.4 * #1625 from ilya-lavrenov:to_string Conflicts: cmake/OpenCVConfig.cmake cmake/OpenCVDetectPython.cmake cmake/OpenCVGenConfig.cmake modules/core/CMakeLists.txt modules/nonfree/src/surf.ocl.cpp modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/include/opencv2/ocl/private/util.hpp modules/ocl/perf/main.cpp modules/ocl/src/arithm.cpp modules/ocl/src/cl_operations.cpp modules/ocl/src/cl_programcache.cpp modules/ocl/src/color.cpp modules/ocl/src/fft.cpp modules/ocl/src/filtering.cpp modules/ocl/src/gemm.cpp modules/ocl/src/haar.cpp modules/ocl/src/imgproc.cpp modules/ocl/src/matrix_operations.cpp modules/ocl/src/pyrlk.cpp modules/ocl/src/split_merge.cpp modules/ocl/src/svm.cpp modules/ocl/test/main.cpp modules/ocl/test/test_fft.cpp modules/ocl/test/test_moments.cpp modules/ocl/test/test_objdetect.cpp modules/ocl/test/test_optflow.cpp modules/ocl/test/utility.hpp modules/python/CMakeLists.txt modules/ts/include/opencv2/ts.hpp modules/ts/src/ts_perf.cpp samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp
This commit is contained in:
@@ -52,16 +52,12 @@
|
||||
#define MIN_VALUE 171
|
||||
#define MAX_VALUE 357
|
||||
|
||||
//#define RANDOMROI
|
||||
int randomInt(int minVal, int maxVal);
|
||||
double randomDouble(double minVal, double maxVal);
|
||||
//std::string generateVarList(int first,...);
|
||||
std::string generateVarList(int &p1, int &p2);
|
||||
cv::Size randomSize(int minVal, int maxVal);
|
||||
cv::Scalar randomScalar(double minVal, double maxVal);
|
||||
cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0);
|
||||
namespace cvtest {
|
||||
|
||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
//void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
|
||||
cv::ocl::oclMat createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi);
|
||||
cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi);
|
||||
|
||||
// This function test if gpu_rst matches cpu_rst.
|
||||
// If the two vectors are not equal, it will return the difference in vector size
|
||||
@@ -78,10 +74,6 @@ double checkNorm(const cv::Mat &m);
|
||||
double checkNorm(const cv::Mat &m1, const cv::Mat &m2);
|
||||
double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
|
||||
|
||||
//oclMat create
|
||||
cv::ocl::oclMat createMat_ocl(cv::Size size, int type, bool useRoi = false);
|
||||
cv::ocl::oclMat loadMat_ocl(const cv::Mat& m, bool useRoi = false);
|
||||
|
||||
#define EXPECT_MAT_NORM(mat, eps) \
|
||||
{ \
|
||||
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
|
||||
@@ -101,13 +93,6 @@ cv::ocl::oclMat loadMat_ocl(const cv::Mat& m, bool useRoi = false);
|
||||
EXPECT_LE(checkSimilarity(cv::Mat(mat1), cv::Mat(mat2)), eps); \
|
||||
}
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
// void PrintTo(const DeviceInfo& info, std::ostream* os);
|
||||
}
|
||||
}
|
||||
|
||||
using perf::MatDepth;
|
||||
using perf::MatType;
|
||||
@@ -134,80 +119,106 @@ private:
|
||||
|
||||
void PrintTo(const Inverse &useRoi, std::ostream *os);
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
#define OCL_RNG_SEED 123456
|
||||
|
||||
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
|
||||
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
|
||||
CV_ENUM(ReduceOp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN)
|
||||
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
|
||||
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
|
||||
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
|
||||
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
|
||||
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
|
||||
template <typename T>
|
||||
struct TSTestWithParam : public ::testing::TestWithParam<T>
|
||||
{
|
||||
cv::RNG rng;
|
||||
|
||||
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
|
||||
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
|
||||
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
|
||||
TSTestWithParam()
|
||||
{
|
||||
rng = cv::RNG(OCL_RNG_SEED);
|
||||
}
|
||||
|
||||
void run_perf_test();
|
||||
int randomInt(int minVal, int maxVal)
|
||||
{
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
double randomDouble(double minVal, double maxVal)
|
||||
{
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
double randomDoubleLog(double minVal, double maxVal)
|
||||
{
|
||||
double logMin = log((double)minVal + 1);
|
||||
double logMax = log((double)maxVal + 1);
|
||||
double pow = rng.uniform(logMin, logMax);
|
||||
double v = exp(pow) - 1;
|
||||
CV_Assert(v >= minVal && (v < maxVal || (v == minVal && v == maxVal)));
|
||||
return v;
|
||||
}
|
||||
|
||||
Size randomSize(int minVal, int maxVal)
|
||||
{
|
||||
#if 1
|
||||
return cv::Size((int)randomDoubleLog(minVal, maxVal), (int)randomDoubleLog(minVal, maxVal));
|
||||
#else
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
#endif
|
||||
}
|
||||
|
||||
Size randomSize(int minValX, int maxValX, int minValY, int maxValY)
|
||||
{
|
||||
#if 1
|
||||
return cv::Size(randomDoubleLog(minValX, maxValX), randomDoubleLog(minValY, maxValY));
|
||||
#else
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
#endif
|
||||
}
|
||||
|
||||
Scalar randomScalar(double minVal, double maxVal)
|
||||
{
|
||||
return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal));
|
||||
}
|
||||
|
||||
Mat randomMat(Size size, int type, double minVal, double maxVal, bool useRoi = false)
|
||||
{
|
||||
RNG dataRng(rng.next());
|
||||
return cvtest::randomMat(dataRng, size, type, minVal, maxVal, useRoi);
|
||||
}
|
||||
|
||||
struct Border
|
||||
{
|
||||
int top, bot, lef, rig;
|
||||
};
|
||||
|
||||
Border randomBorder(int minValue = 0, int maxValue = MAX_VALUE)
|
||||
{
|
||||
Border border = {
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue),
|
||||
(int)randomDoubleLog(minValue, maxValue)
|
||||
};
|
||||
return border;
|
||||
}
|
||||
|
||||
void randomSubMat(Mat& whole, Mat& subMat, const Size& roiSize, const Border& border, int type, double minVal, double maxVal)
|
||||
{
|
||||
Size wholeSize = Size(roiSize.width + border.lef + border.rig, roiSize.height + border.top + border.bot);
|
||||
whole = randomMat(wholeSize, type, minVal, maxVal, false);
|
||||
subMat = whole(Rect(border.lef, border.top, roiSize.width, roiSize.height));
|
||||
}
|
||||
|
||||
void generateOclMat(cv::ocl::oclMat& whole, cv::ocl::oclMat& subMat, const Mat& wholeMat, const Size& roiSize, const Border& border)
|
||||
{
|
||||
whole = wholeMat;
|
||||
subMat = whole(Rect(border.lef, border.top, roiSize.width, roiSize.height));
|
||||
}
|
||||
};
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : public TSTestWithParam< std::tr1::tuple< __VA_ARGS__ > >
|
||||
|
||||
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
|
||||
|
||||
#define ALL_DEVICES testing::ValuesIn(devices())
|
||||
#define DEVICES(feature) testing::ValuesIn(devices(feature))
|
||||
|
||||
#define ALL_TYPES testing::ValuesIn(all_types())
|
||||
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
|
||||
|
||||
#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113), cv::Size(1300, 1300))
|
||||
|
||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||
|
||||
#ifndef ALL_DEPTH
|
||||
#define ALL_DEPTH testing::Values(MatDepth(CV_8U), MatDepth(CV_8S), MatDepth(CV_16U), MatDepth(CV_16S), MatDepth(CV_32S), MatDepth(CV_32F), MatDepth(CV_64F))
|
||||
#endif
|
||||
#define REPEAT 1000
|
||||
#define COUNT_U 0 // count the uploading execution time for ocl mat structures
|
||||
#define COUNT_D 0
|
||||
// the following macro section tests the target function (kernel) performance
|
||||
// upload is the code snippet for converting cv::mat to cv::ocl::oclMat
|
||||
// downloading is the code snippet for converting cv::ocl::oclMat back to cv::mat
|
||||
// change COUNT_U and COUNT_D to take downloading and uploading time into account
|
||||
#define P_TEST_FULL( upload, kernel_call, download ) \
|
||||
{ \
|
||||
std::cout<< "\n" #kernel_call "\n----------------------"; \
|
||||
{upload;} \
|
||||
R_TEST( kernel_call, 2 ); \
|
||||
double t = (double)cvGetTickCount(); \
|
||||
R_T( { \
|
||||
if( COUNT_U ) {upload;} \
|
||||
kernel_call; \
|
||||
if( COUNT_D ) {download;} \
|
||||
} ); \
|
||||
t = (double)cvGetTickCount() - t; \
|
||||
std::cout << "runtime is " << t/((double)cvGetTickFrequency()* 1000.) << "ms" << std::endl; \
|
||||
}
|
||||
|
||||
#define R_T2( test ) \
|
||||
{ \
|
||||
std::cout<< "\n" #test "\n----------------------"; \
|
||||
R_TEST( test, 15 ) \
|
||||
clock_t st = clock(); \
|
||||
R_T( test ) \
|
||||
std::cout<< clock() - st << "ms\n"; \
|
||||
}
|
||||
#define R_T( test ) \
|
||||
R_TEST( test, REPEAT )
|
||||
#define R_TEST( test, repeat ) \
|
||||
try{ \
|
||||
for( int i = 0; i < repeat; i ++ ) { test; } \
|
||||
} catch( ... ) { std::cout << "||||| Exception catched! |||||\n"; return; }
|
||||
|
||||
//////// Utility
|
||||
|
||||
#define IMAGE_CHANNELS testing::Values(Channels(1), Channels(3), Channels(4))
|
||||
#ifndef IMPLEMENT_PARAM_CLASS
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
@@ -227,4 +238,70 @@ void run_perf_test();
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
#endif // IMPLEMENT_PARAM_CLASS
|
||||
|
||||
} // namespace cvtest
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
|
||||
CV_ENUM(CmpCode, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
|
||||
CV_ENUM(NormCode, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX)
|
||||
CV_ENUM(ReduceOp, REDUCE_SUM, REDUCE_AVG, REDUCE_MAX, REDUCE_MIN)
|
||||
CV_ENUM(MorphOp, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT, MORPH_TOPHAT, MORPH_BLACKHAT)
|
||||
CV_ENUM(ThreshOp, THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV)
|
||||
CV_ENUM(Interpolation, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC)
|
||||
CV_ENUM(Border, BORDER_REFLECT101, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_WRAP)
|
||||
CV_ENUM(TemplateMethod, TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED)
|
||||
|
||||
CV_FLAGS(GemmFlags, GEMM_1_T, GEMM_2_T, GEMM_3_T);
|
||||
CV_FLAGS(WarpFlags, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, WARP_INVERSE_MAP)
|
||||
CV_FLAGS(DftFlags, DFT_INVERSE, DFT_SCALE, DFT_ROWS, DFT_COMPLEX_OUTPUT, DFT_REAL_OUTPUT)
|
||||
|
||||
# define OCL_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)() { } \
|
||||
virtual void TestBody(); \
|
||||
void OCLTestBody(); \
|
||||
private: \
|
||||
static int AddToRegistry() \
|
||||
{ \
|
||||
::testing::UnitTest::GetInstance()->parameterized_test_registry(). \
|
||||
GetTestCasePatternHolder<test_case_name>(\
|
||||
#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() \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
OCLTestBody(); \
|
||||
} \
|
||||
catch (const cv::Exception & ex) \
|
||||
{ \
|
||||
if (ex.code == cv::Error::OpenCLDoubleNotSupported)\
|
||||
std::cout << "Test skipped (selected device does not support double)" << std::endl; \
|
||||
else if (ex.code == cv::Error::OpenCLNoAMDBlasFft) \
|
||||
std::cout << "Test skipped (AMD Blas / Fft libraries are not available)" << std::endl; \
|
||||
else \
|
||||
throw; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::OCLTestBody()
|
||||
|
||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
||||
|
Reference in New Issue
Block a user