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:
@@ -10,7 +10,8 @@
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -41,105 +42,17 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
#define DUMP_INFO_STDOUT(propertyDisplayName, propertyValue) \
|
||||
do { \
|
||||
std::cout << (propertyDisplayName) << ": " << (propertyValue) << std::endl; \
|
||||
} while (false)
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
#define DUMP_INFO_XML(propertyXMLName, propertyValue) \
|
||||
do { \
|
||||
std::stringstream ss; ss << propertyValue; \
|
||||
::testing::Test::RecordProperty((propertyXMLName), ss.str()); \
|
||||
} while (false)
|
||||
|
||||
void print_info()
|
||||
{
|
||||
printf("\n");
|
||||
#if defined _WIN32
|
||||
# if defined _WIN64
|
||||
puts("OS: Windows 64");
|
||||
# else
|
||||
puts("OS: Windows 32");
|
||||
# endif
|
||||
#elif defined linux
|
||||
# if defined _LP64
|
||||
puts("OS: Linux 64");
|
||||
# else
|
||||
puts("OS: Linux 32");
|
||||
# endif
|
||||
#elif defined __APPLE__
|
||||
# if defined _LP64
|
||||
puts("OS: Apple 64");
|
||||
# else
|
||||
puts("OS: Apple 32");
|
||||
# endif
|
||||
#endif
|
||||
#include "opencv2/ocl/private/opencl_dumpinfo.hpp"
|
||||
|
||||
}
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
TS::ptr()->init(".");
|
||||
InitGoogleTest(&argc, argv);
|
||||
const char *keys =
|
||||
"{ h | false | print help message }"
|
||||
"{ t | gpu | set device type:i.e. -t=cpu or gpu}"
|
||||
"{ p | -1 | set platform id i.e. -p=0}"
|
||||
"{ d | 0 | set device id i.e. -d=0}";
|
||||
|
||||
if (getenv("OPENCV_OPENCL_DEVICE") == NULL) // TODO Remove this after buildbot updates
|
||||
{
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cout << "Available options besides google test option:" << endl;
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
string type = cmd.get<string>("type");
|
||||
int pid = cmd.get<int>("platform");
|
||||
int device = cmd.get<int>("device");
|
||||
|
||||
print_info();
|
||||
int flag = CVCL_DEVICE_TYPE_GPU;
|
||||
if(type == "cpu")
|
||||
{
|
||||
flag = CVCL_DEVICE_TYPE_CPU;
|
||||
}
|
||||
|
||||
cv::ocl::PlatformsInfo platformsInfo;
|
||||
cv::ocl::getOpenCLPlatforms(platformsInfo);
|
||||
if (pid >= (int)platformsInfo.size())
|
||||
{
|
||||
std::cout << "platform is invalid\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
cv::ocl::DevicesInfo devicesInfo;
|
||||
int devnums = cv::ocl::getOpenCLDevices(devicesInfo, flag, (pid < 0) ? NULL : platformsInfo[pid]);
|
||||
if (device < 0 || device >= devnums)
|
||||
{
|
||||
std::cout << "device/platform invalid\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
cv::ocl::setDevice(devicesInfo[device]);
|
||||
}
|
||||
|
||||
const DeviceInfo& deviceInfo = cv::ocl::Context::getContext()->getDeviceInfo();
|
||||
|
||||
cout << "Device type: " << (deviceInfo.deviceType == CVCL_DEVICE_TYPE_CPU ?
|
||||
"CPU" :
|
||||
(deviceInfo.deviceType == CVCL_DEVICE_TYPE_GPU ? "GPU" : "unknown")) << endl
|
||||
<< "Platform name: " << deviceInfo.platform->platformName << endl
|
||||
<< "Device name: " << deviceInfo.deviceName << endl;
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
#else // DON'T HAVE_OPENCL
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("OpenCV was built without OpenCL support\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
CV_TEST_MAIN(".", dumpOpenCLDevice())
|
||||
|
80
modules/ocl/test/test_api.cpp
Normal file
80
modules/ocl/test/test_api.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/ocl/cl_runtime/cl_runtime.hpp" // for OpenCL types: cl_mem
|
||||
|
||||
TEST(TestAPI, openCLExecuteKernelInterop)
|
||||
{
|
||||
cv::RNG rng;
|
||||
Size sz(10000, 1);
|
||||
cv::Mat cpuMat = cvtest::randomMat(rng, sz, CV_32FC4, -10, 10, false);
|
||||
|
||||
cv::ocl::oclMat gpuMat(cpuMat);
|
||||
cv::ocl::oclMat gpuMatDst(sz, CV_32FC4);
|
||||
|
||||
const char* kernelStr =
|
||||
"__kernel void test_kernel(__global float4* src, __global float4* dst) {\n"
|
||||
" int x = get_global_id(0);\n"
|
||||
" dst[x] = src[x];\n"
|
||||
"}\n";
|
||||
|
||||
cv::ocl::ProgramSource program("test_interop", kernelStr);
|
||||
|
||||
using namespace std;
|
||||
vector<pair<size_t , const void *> > args;
|
||||
args.push_back( make_pair( sizeof(cl_mem), (void *) &gpuMat.data ));
|
||||
args.push_back( make_pair( sizeof(cl_mem), (void *) &gpuMatDst.data ));
|
||||
|
||||
size_t globalThreads[3] = { sz.width, 1, 1 };
|
||||
cv::ocl::openCLExecuteKernelInterop(
|
||||
gpuMat.clCxt,
|
||||
program,
|
||||
"test_kernel",
|
||||
globalThreads, NULL, args,
|
||||
-1, -1,
|
||||
"");
|
||||
|
||||
cv::Mat dst;
|
||||
gpuMatDst.download(dst);
|
||||
|
||||
EXPECT_LE(checkNorm(cpuMat, dst), 1e-3);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -85,14 +85,12 @@ PARAM_TEST_CASE(mog, UseGray, LearningRate, bool)
|
||||
virtual void SetUp()
|
||||
{
|
||||
useGray = GET_PARAM(0);
|
||||
|
||||
learningRate = GET_PARAM(1);
|
||||
|
||||
useRoi = GET_PARAM(2);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(mog, Update)
|
||||
OCL_TEST_P(mog, Update)
|
||||
{
|
||||
std::string inputFile = string(cvtest::TS::ptr()->get_data_path()) + "gpu/video/768x576.avi";
|
||||
cv::VideoCapture cap(inputFile);
|
||||
@@ -103,7 +101,7 @@ TEST_P(mog, Update)
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
cv::ocl::MOG mog;
|
||||
cv::ocl::oclMat foreground = createMat_ocl(frame.size(), CV_8UC1, useRoi);
|
||||
cv::ocl::oclMat foreground = createMat_ocl(rng, frame.size(), CV_8UC1, useRoi);
|
||||
|
||||
Ptr<cv::BackgroundSubtractorMOG> mog_gold = createBackgroundSubtractorMOG();
|
||||
cv::Mat foreground_gold;
|
||||
@@ -120,7 +118,7 @@ TEST_P(mog, Update)
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
mog(loadMat_ocl(frame, useRoi), foreground, (float)learningRate);
|
||||
mog(loadMat_ocl(rng, frame, useRoi), foreground, (float)learningRate);
|
||||
|
||||
mog_gold->apply(frame, foreground_gold, learningRate);
|
||||
|
||||
@@ -153,7 +151,7 @@ PARAM_TEST_CASE(mog2, UseGray, DetectShadow, bool)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(mog2, Update)
|
||||
OCL_TEST_P(mog2, Update)
|
||||
{
|
||||
std::string inputFile = string(cvtest::TS::ptr()->get_data_path()) + "gpu/video/768x576.avi";
|
||||
cv::VideoCapture cap(inputFile);
|
||||
@@ -165,7 +163,7 @@ TEST_P(mog2, Update)
|
||||
|
||||
cv::ocl::MOG2 mog2;
|
||||
mog2.bShadowDetection = detectShadow;
|
||||
cv::ocl::oclMat foreground = createMat_ocl(frame.size(), CV_8UC1, useRoi);
|
||||
cv::ocl::oclMat foreground = createMat_ocl(rng, frame.size(), CV_8UC1, useRoi);
|
||||
|
||||
cv::Ptr<cv::BackgroundSubtractorMOG2> mog2_gold = createBackgroundSubtractorMOG2();
|
||||
mog2_gold->setDetectShadows(detectShadow);
|
||||
@@ -183,7 +181,7 @@ TEST_P(mog2, Update)
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
mog2(loadMat_ocl(frame, useRoi), foreground);
|
||||
mog2(loadMat_ocl(rng, frame, useRoi), foreground);
|
||||
|
||||
mog2_gold->apply(frame, foreground_gold);
|
||||
|
||||
@@ -194,7 +192,7 @@ TEST_P(mog2, Update)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(mog2, getBackgroundImage)
|
||||
OCL_TEST_P(mog2, getBackgroundImage)
|
||||
{
|
||||
if (useGray)
|
||||
return;
|
||||
@@ -218,12 +216,12 @@ TEST_P(mog2, getBackgroundImage)
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
mog2(loadMat_ocl(frame, useRoi), foreground);
|
||||
mog2(loadMat_ocl(rng, frame, useRoi), foreground);
|
||||
|
||||
mog2_gold->apply(frame, foreground_gold);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat background = createMat_ocl(frame.size(), frame.type(), useRoi);
|
||||
cv::ocl::oclMat background = createMat_ocl(rng, frame.size(), frame.type(), useRoi);
|
||||
mog2.getBackgroundImage(background);
|
||||
|
||||
cv::Mat background_gold;
|
||||
|
@@ -88,7 +88,7 @@ PARAM_TEST_CASE(Blend, cv::Size, MatType/*, UseRoi*/)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Blend, Accuracy)
|
||||
OCL_TEST_P(Blend, Accuracy)
|
||||
{
|
||||
int depth = CV_MAT_DEPTH(type);
|
||||
|
||||
|
@@ -72,8 +72,6 @@ namespace
|
||||
queryDescCount = 300; // must be even number because we split train data in some cases in two
|
||||
countFactor = 4; // do not change it
|
||||
|
||||
cv::RNG &rng = cvtest::TS::ptr()->get_rng();
|
||||
|
||||
cv::Mat queryBuf, trainBuf;
|
||||
|
||||
// Generate query descriptors randomly.
|
||||
@@ -108,7 +106,7 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(BruteForceMatcher, Match_Single)
|
||||
OCL_TEST_P(BruteForceMatcher, Match_Single)
|
||||
{
|
||||
cv::ocl::BruteForceMatcher_OCL_base matcher(distType);
|
||||
|
||||
@@ -128,7 +126,7 @@ namespace
|
||||
ASSERT_EQ(0, badCount);
|
||||
}
|
||||
|
||||
TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
||||
OCL_TEST_P(BruteForceMatcher, KnnMatch_2_Single)
|
||||
{
|
||||
const int knn = 2;
|
||||
|
||||
@@ -160,7 +158,7 @@ namespace
|
||||
ASSERT_EQ(0, badCount);
|
||||
}
|
||||
|
||||
TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
||||
OCL_TEST_P(BruteForceMatcher, RadiusMatch_Single)
|
||||
{
|
||||
float radius = 1.f / countFactor;
|
||||
|
||||
|
@@ -46,10 +46,10 @@
|
||||
#include "test_precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
PARAM_TEST_CASE(StereoMatchBM, int, int)
|
||||
{
|
||||
int n_disp;
|
||||
@@ -62,7 +62,7 @@ PARAM_TEST_CASE(StereoMatchBM, int, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(StereoMatchBM, Regression)
|
||||
OCL_TEST_P(StereoMatchBM, Regression)
|
||||
{
|
||||
|
||||
Mat left_image = readImage("gpu/stereobm/aloe-L.png", IMREAD_GRAYSCALE);
|
||||
@@ -110,7 +110,7 @@ PARAM_TEST_CASE(StereoMatchBP, int, int, int, float, float, float, float)
|
||||
disc_single_jump_ = GET_PARAM(6);
|
||||
}
|
||||
};
|
||||
TEST_P(StereoMatchBP, Regression)
|
||||
OCL_TEST_P(StereoMatchBP, Regression)
|
||||
{
|
||||
Mat left_image = readImage("gpu/stereobp/aloe-L.png");
|
||||
Mat right_image = readImage("gpu/stereobp/aloe-R.png");
|
||||
@@ -163,7 +163,7 @@ PARAM_TEST_CASE(StereoMatchConstSpaceBP, int, int, int, int, float, float, float
|
||||
msg_type_ = GET_PARAM(9);
|
||||
}
|
||||
};
|
||||
TEST_P(StereoMatchConstSpaceBP, Regression)
|
||||
OCL_TEST_P(StereoMatchConstSpaceBP, Regression)
|
||||
{
|
||||
Mat left_image = readImage("gpu/csstereobp/aloe-L.png");
|
||||
Mat right_image = readImage("gpu/csstereobp/aloe-R.png");
|
||||
|
@@ -64,7 +64,7 @@ PARAM_TEST_CASE(Canny, AppertureSize, L2gradient)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Canny, Accuracy)
|
||||
OCL_TEST_P(Canny, Accuracy)
|
||||
{
|
||||
cv::Mat img = readImage("cv/shared/fruits.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
@@ -93,7 +93,7 @@ PARAM_TEST_CASE(CvtColor, cv::Size, MatDepth)
|
||||
};
|
||||
|
||||
#define CVTCODE(name) cv::COLOR_ ## name
|
||||
#define TEST_P_CVTCOLOR(name) TEST_P(CvtColor, name)\
|
||||
#define OCL_TEST_P_CVTCOLOR(name) OCL_TEST_P(CvtColor, name)\
|
||||
{\
|
||||
cv::Mat src = img;\
|
||||
cv::ocl::oclMat ocl_img, dst;\
|
||||
@@ -107,17 +107,17 @@ PARAM_TEST_CASE(CvtColor, cv::Size, MatDepth)
|
||||
}
|
||||
|
||||
//add new ones here using macro
|
||||
TEST_P_CVTCOLOR(RGB2GRAY)
|
||||
TEST_P_CVTCOLOR(BGR2GRAY)
|
||||
TEST_P_CVTCOLOR(RGBA2GRAY)
|
||||
TEST_P_CVTCOLOR(BGRA2GRAY)
|
||||
OCL_TEST_P_CVTCOLOR(RGB2GRAY)
|
||||
OCL_TEST_P_CVTCOLOR(BGR2GRAY)
|
||||
OCL_TEST_P_CVTCOLOR(RGBA2GRAY)
|
||||
OCL_TEST_P_CVTCOLOR(BGRA2GRAY)
|
||||
|
||||
TEST_P_CVTCOLOR(RGB2YUV)
|
||||
TEST_P_CVTCOLOR(BGR2YUV)
|
||||
TEST_P_CVTCOLOR(YUV2RGB)
|
||||
TEST_P_CVTCOLOR(YUV2BGR)
|
||||
TEST_P_CVTCOLOR(RGB2YCrCb)
|
||||
TEST_P_CVTCOLOR(BGR2YCrCb)
|
||||
OCL_TEST_P_CVTCOLOR(RGB2YUV)
|
||||
OCL_TEST_P_CVTCOLOR(BGR2YUV)
|
||||
OCL_TEST_P_CVTCOLOR(YUV2RGB)
|
||||
OCL_TEST_P_CVTCOLOR(YUV2BGR)
|
||||
OCL_TEST_P_CVTCOLOR(RGB2YCrCb)
|
||||
OCL_TEST_P_CVTCOLOR(BGR2YCrCb)
|
||||
|
||||
PARAM_TEST_CASE(CvtColor_Gray2RGB, cv::Size, MatDepth, int)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ PARAM_TEST_CASE(CvtColor_Gray2RGB, cv::Size, MatDepth, int)
|
||||
img = randomMat(size, CV_MAKETYPE(depth, 1), 0.0, depth == CV_32F ? 1.0 : 255.0);
|
||||
}
|
||||
};
|
||||
TEST_P(CvtColor_Gray2RGB, Accuracy)
|
||||
OCL_TEST_P(CvtColor_Gray2RGB, Accuracy)
|
||||
{
|
||||
cv::Mat src = img;
|
||||
cv::ocl::oclMat ocl_img, dst;
|
||||
@@ -163,7 +163,7 @@ PARAM_TEST_CASE(CvtColor_YUV420, cv::Size, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(CvtColor_YUV420, Accuracy)
|
||||
OCL_TEST_P(CvtColor_YUV420, Accuracy)
|
||||
{
|
||||
cv::Mat src = img;
|
||||
cv::ocl::oclMat ocl_img, dst;
|
||||
|
@@ -44,10 +44,12 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
#ifdef HAVE_CLAMDFFT
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Dft
|
||||
|
||||
PARAM_TEST_CASE(Dft, cv::Size, int)
|
||||
{
|
||||
cv::Size dft_size;
|
||||
@@ -59,7 +61,7 @@ PARAM_TEST_CASE(Dft, cv::Size, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Dft, C2C)
|
||||
OCL_TEST_P(Dft, C2C)
|
||||
{
|
||||
cv::Mat a = randomMat(dft_size, CV_32FC2, 0.0, 100.0);
|
||||
cv::Mat b_gold;
|
||||
@@ -71,7 +73,7 @@ TEST_P(Dft, C2C)
|
||||
EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), a.size().area() * 1e-4);
|
||||
}
|
||||
|
||||
TEST_P(Dft, R2C)
|
||||
OCL_TEST_P(Dft, R2C)
|
||||
{
|
||||
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 100.0);
|
||||
cv::Mat b_gold, b_gold_roi;
|
||||
@@ -88,7 +90,7 @@ TEST_P(Dft, R2C)
|
||||
EXPECT_MAT_NEAR(b_gold_roi, cv::Mat(d_b), a.size().area() * 1e-4);
|
||||
}
|
||||
|
||||
TEST_P(Dft, R2CthenC2R)
|
||||
OCL_TEST_P(Dft, R2CthenC2R)
|
||||
{
|
||||
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 10.0);
|
||||
|
||||
@@ -98,7 +100,6 @@ TEST_P(Dft, R2CthenC2R)
|
||||
EXPECT_MAT_NEAR(a, d_c, a.size().area() * 1e-4);
|
||||
}
|
||||
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, Dft, testing::Combine(
|
||||
testing::Values(cv::Size(2, 3), cv::Size(5, 4), cv::Size(25, 20), cv::Size(512, 1), cv::Size(1024, 768)),
|
||||
testing::Values(0, (int)cv::DFT_ROWS, (int)cv::DFT_SCALE) ));
|
||||
@@ -119,12 +120,12 @@ PARAM_TEST_CASE(MulSpectrums, cv::Size, DftFlags, bool)
|
||||
flag = GET_PARAM(1);
|
||||
ccorr = GET_PARAM(2);
|
||||
|
||||
a = randomMat(size, CV_32FC2);
|
||||
b = randomMat(size, CV_32FC2);
|
||||
a = randomMat(size, CV_32FC2, -100, 100, false);
|
||||
b = randomMat(size, CV_32FC2, -100, 100, false);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(MulSpectrums, Simple)
|
||||
OCL_TEST_P(MulSpectrums, Simple)
|
||||
{
|
||||
cv::ocl::oclMat c;
|
||||
cv::ocl::mulSpectrums(cv::ocl::oclMat(a), cv::ocl::oclMat(b), c, flag, 1.0, ccorr);
|
||||
@@ -135,7 +136,7 @@ TEST_P(MulSpectrums, Simple)
|
||||
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
|
||||
}
|
||||
|
||||
TEST_P(MulSpectrums, Scaled)
|
||||
OCL_TEST_P(MulSpectrums, Scaled)
|
||||
{
|
||||
float scale = 1.f / size.area();
|
||||
|
||||
@@ -219,7 +220,7 @@ PARAM_TEST_CASE(Convolve_DFT, cv::Size, KSize, Ccorr)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Convolve_DFT, Accuracy)
|
||||
OCL_TEST_P(Convolve_DFT, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, CV_32FC1, 0.0, 100.0);
|
||||
cv::Mat kernel = randomMat(cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0);
|
||||
@@ -236,5 +237,4 @@ TEST_P(Convolve_DFT, Accuracy)
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, Convolve_DFT, testing::Combine(
|
||||
DIFFERENT_CONVOLVE_SIZES,
|
||||
testing::Values(KSize(19), KSize(23), KSize(45)),
|
||||
testing::Values(Ccorr(true)/*, Ccorr(false)*/))); // false ccorr cannot pass for some instances
|
||||
#endif // HAVE_CLAMDFFT
|
||||
testing::Values(Ccorr(true)/*, Ccorr(false)*/))); // TODO false ccorr cannot pass for some instances
|
||||
|
@@ -91,7 +91,6 @@ PARAM_TEST_CASE(FilterTestBase,
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(2, mat1.cols);
|
||||
roirows = rng.uniform(2, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@@ -146,7 +145,7 @@ struct Blur : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Blur, Mat)
|
||||
OCL_TEST_P(Blur, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -173,7 +172,7 @@ struct Laplacian : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Laplacian, Accuracy)
|
||||
OCL_TEST_P(Laplacian, Accuracy)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -201,13 +200,12 @@ struct ErodeDilate : FilterTestBase
|
||||
type = GET_PARAM(0);
|
||||
iterations = GET_PARAM(3);
|
||||
Init(type);
|
||||
// rng.fill(kernel, cv::RNG::UNIFORM, cv::Scalar::all(0), cv::Scalar::all(3));
|
||||
kernel = randomMat(Size(3, 3), CV_8UC1, 0, 3);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_P(ErodeDilate, Mat)
|
||||
OCL_TEST_P(ErodeDilate, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -246,7 +244,7 @@ struct Sobel : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Sobel, Mat)
|
||||
OCL_TEST_P(Sobel, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -276,7 +274,7 @@ struct Scharr : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Scharr, Mat)
|
||||
OCL_TEST_P(Scharr, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -304,13 +302,12 @@ struct GaussianBlur : FilterTestBase
|
||||
ksize = GET_PARAM(1);
|
||||
bordertype = GET_PARAM(3);
|
||||
Init(type);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
sigma1 = rng.uniform(0.1, 1.0);
|
||||
sigma2 = rng.uniform(0.1, 1.0);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(GaussianBlur, Mat)
|
||||
OCL_TEST_P(GaussianBlur, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -342,7 +339,7 @@ struct Filter2D : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Filter2D, Mat)
|
||||
OCL_TEST_P(Filter2D, Mat)
|
||||
{
|
||||
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
@@ -368,13 +365,12 @@ struct Bilateral : FilterTestBase
|
||||
ksize = GET_PARAM(1);
|
||||
bordertype = GET_PARAM(3);
|
||||
Init(type);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
sigmacolor = rng.uniform(20, 100);
|
||||
sigmaspace = rng.uniform(10, 40);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Bilateral, Mat)
|
||||
OCL_TEST_P(Bilateral, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -404,7 +400,7 @@ struct AdaptiveBilateral : FilterTestBase
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(AdaptiveBilateral, Mat)
|
||||
OCL_TEST_P(AdaptiveBilateral, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
|
@@ -42,12 +42,13 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
#ifdef HAVE_CLAMDBLAS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GEMM
|
||||
|
||||
PARAM_TEST_CASE(Gemm, int, cv::Size, int)
|
||||
{
|
||||
int type;
|
||||
@@ -62,7 +63,7 @@ PARAM_TEST_CASE(Gemm, int, cv::Size, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Gemm, Accuracy)
|
||||
OCL_TEST_P(Gemm, Accuracy)
|
||||
{
|
||||
cv::Mat a = randomMat(mat_size, type, 0.0, 10.0);
|
||||
cv::Mat b = randomMat(mat_size, type, 0.0, 10.0);
|
||||
@@ -81,4 +82,3 @@ INSTANTIATE_TEST_CASE_P(ocl_gemm, Gemm, testing::Combine(
|
||||
testing::Values(CV_32FC1, CV_32FC2/*, CV_64FC1, CV_64FC2*/),
|
||||
testing::Values(cv::Size(20, 20), cv::Size(300, 300)),
|
||||
testing::Values(0, (int)cv::GEMM_1_T, (int)cv::GEMM_2_T, (int)(cv::GEMM_1_T + cv::GEMM_2_T))));
|
||||
#endif
|
||||
|
@@ -58,7 +58,7 @@ PARAM_TEST_CASE(HoughCircles, cv::Size)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HoughCircles, Accuracy)
|
||||
OCL_TEST_P(HoughCircles, Accuracy)
|
||||
{
|
||||
const cv::Size size = GET_PARAM(0);
|
||||
|
||||
|
@@ -351,33 +351,32 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
|
||||
type3 = GET_PARAM(2);
|
||||
type4 = GET_PARAM(3);
|
||||
type5 = GET_PARAM(4);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
double min = 1, max = 20;
|
||||
|
||||
if(type1 != nulltype)
|
||||
{
|
||||
mat1 = randomMat(rng, size, type1, min, max, false);
|
||||
mat1 = randomMat(size, type1, min, max, false);
|
||||
clmat1 = mat1;
|
||||
}
|
||||
if(type2 != nulltype)
|
||||
{
|
||||
mat2 = randomMat(rng, size, type2, min, max, false);
|
||||
mat2 = randomMat(size, type2, min, max, false);
|
||||
clmat2 = mat2;
|
||||
}
|
||||
if(type3 != nulltype)
|
||||
{
|
||||
dst = randomMat(rng, size, type3, min, max, false);
|
||||
dst = randomMat(size, type3, min, max, false);
|
||||
cldst = dst;
|
||||
}
|
||||
if(type4 != nulltype)
|
||||
{
|
||||
dst1 = randomMat(rng, size, type4, min, max, false);
|
||||
dst1 = randomMat(size, type4, min, max, false);
|
||||
cldst1 = dst1;
|
||||
}
|
||||
if(type5 != nulltype)
|
||||
{
|
||||
mask = randomMat(rng, size, CV_8UC1, 0, 2, false);
|
||||
mask = randomMat(size, CV_8UC1, 0, 2, false);
|
||||
cv::threshold(mask, mask, 0.5, 255., type5);
|
||||
clmask = mask;
|
||||
}
|
||||
@@ -388,7 +387,6 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
roirows = rng.uniform(1, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@@ -455,7 +453,7 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
|
||||
|
||||
struct equalizeHist : ImgprocTestBase {};
|
||||
|
||||
TEST_P(equalizeHist, Mat)
|
||||
OCL_TEST_P(equalizeHist, Mat)
|
||||
{
|
||||
if (mat1.type() != CV_8UC1 || mat1.type() != dst.type())
|
||||
{
|
||||
@@ -479,10 +477,9 @@ TEST_P(equalizeHist, Mat)
|
||||
|
||||
struct CopyMakeBorder : ImgprocTestBase {};
|
||||
|
||||
TEST_P(CopyMakeBorder, Mat)
|
||||
OCL_TEST_P(CopyMakeBorder, Mat)
|
||||
{
|
||||
int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE, cv::BORDER_REFLECT, cv::BORDER_WRAP, cv::BORDER_REFLECT_101};
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
int top = rng.uniform(0, 10);
|
||||
int bottom = rng.uniform(0, 10);
|
||||
int left = rng.uniform(0, 10);
|
||||
@@ -535,7 +532,7 @@ TEST_P(CopyMakeBorder, Mat)
|
||||
|
||||
struct cornerMinEigenVal : ImgprocTestBase {};
|
||||
|
||||
TEST_P(cornerMinEigenVal, Mat)
|
||||
OCL_TEST_P(cornerMinEigenVal, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -557,7 +554,7 @@ TEST_P(cornerMinEigenVal, Mat)
|
||||
|
||||
struct cornerHarris : ImgprocTestBase {};
|
||||
|
||||
TEST_P(cornerHarris, Mat)
|
||||
OCL_TEST_P(cornerHarris, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -579,7 +576,7 @@ TEST_P(cornerHarris, Mat)
|
||||
|
||||
struct integral : ImgprocTestBase {};
|
||||
|
||||
TEST_P(integral, Mat1)
|
||||
OCL_TEST_P(integral, Mat1)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -591,7 +588,7 @@ TEST_P(integral, Mat1)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(integral, Mat2)
|
||||
OCL_TEST_P(integral, Mat2)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -646,22 +643,17 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int)
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
//dsize = GET_PARAM(1);
|
||||
interpolation = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src_roicols = rng.uniform(1, mat1.cols);
|
||||
src_roirows = rng.uniform(1, mat1.rows);
|
||||
dst_roicols = rng.uniform(1, dst.cols);
|
||||
@@ -698,7 +690,7 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int)
|
||||
|
||||
struct WarpAffine : WarpTestBase {};
|
||||
|
||||
TEST_P(WarpAffine, Mat)
|
||||
OCL_TEST_P(WarpAffine, Mat)
|
||||
{
|
||||
static const double coeffs[2][3] =
|
||||
{
|
||||
@@ -726,7 +718,7 @@ TEST_P(WarpAffine, Mat)
|
||||
|
||||
struct WarpPerspective : WarpTestBase {};
|
||||
|
||||
TEST_P(WarpPerspective, Mat)
|
||||
OCL_TEST_P(WarpPerspective, Mat)
|
||||
{
|
||||
static const double coeffs[3][3] =
|
||||
{
|
||||
@@ -810,23 +802,22 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
interpolation = GET_PARAM(3);
|
||||
bordertype = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size srcSize = cv::Size(MWIDTH, MHEIGHT);
|
||||
cv::Size map1Size = cv::Size(MWIDTH, MHEIGHT);
|
||||
double min = 5, max = 16;
|
||||
|
||||
if(srcType != nulltype)
|
||||
{
|
||||
src = randomMat(rng, srcSize, srcType, min, max, false);
|
||||
src = randomMat(srcSize, srcType, min, max, false);
|
||||
}
|
||||
if((map1Type == CV_16SC2 && map2Type == nulltype) || (map1Type == CV_32FC2 && map2Type == nulltype))
|
||||
{
|
||||
map1 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map1 = randomMat(map1Size, map1Type, min, max, false);
|
||||
}
|
||||
else if (map1Type == CV_32FC1 && map2Type == CV_32FC1)
|
||||
{
|
||||
map1 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map2 = randomMat(rng, map1Size, map1Type, min, max, false);
|
||||
map1 = randomMat(map1Size, map1Type, min, max, false);
|
||||
map2 = randomMat(map1Size, map1Type, min, max, false);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -835,7 +826,7 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
return;
|
||||
}
|
||||
|
||||
dst = randomMat(rng, map1Size, srcType, min, max, false);
|
||||
dst = randomMat(map1Size, srcType, min, max, false);
|
||||
switch (src.channels())
|
||||
{
|
||||
case 1:
|
||||
@@ -855,8 +846,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
}
|
||||
void random_roi()
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
dst_roicols = rng.uniform(1, dst.cols);
|
||||
dst_roirows = rng.uniform(1, dst.rows);
|
||||
|
||||
@@ -898,7 +887,7 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Remap, Mat)
|
||||
OCL_TEST_P(Remap, Mat)
|
||||
{
|
||||
if((interpolation == 1 && map1Type == CV_16SC2) || (map1Type == CV_32FC1 && map2Type == nulltype) || (map1Type == CV_16SC2 && map2Type == CV_32FC1) || (map1Type == CV_32FC2 && map2Type == CV_32FC1))
|
||||
{
|
||||
@@ -966,8 +955,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
fy = GET_PARAM(3);
|
||||
interpolation = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
if(dsize == cv::Size() && !(fx > 0 && fy > 0))
|
||||
@@ -982,8 +969,8 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
dsize.height = (int)(size.height * fy);
|
||||
}
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, dsize, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(dsize, type, 5, 16, false);
|
||||
|
||||
}
|
||||
|
||||
@@ -991,7 +978,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src_roicols = rng.uniform(1, mat1.cols);
|
||||
src_roirows = rng.uniform(1, mat1.rows);
|
||||
dst_roicols = (int)(src_roicols * fx);
|
||||
@@ -1026,7 +1012,7 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
|
||||
|
||||
};
|
||||
|
||||
TEST_P(Resize, Mat)
|
||||
OCL_TEST_P(Resize, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -1082,18 +1068,16 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp)
|
||||
type = GET_PARAM(0);
|
||||
threshOp = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
roirows = rng.uniform(1, mat1.rows);
|
||||
src1x = rng.uniform(0, mat1.cols - roicols);
|
||||
@@ -1121,7 +1105,7 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp)
|
||||
|
||||
};
|
||||
|
||||
TEST_P(Threshold, Mat)
|
||||
OCL_TEST_P(Threshold, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -1179,22 +1163,18 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria)
|
||||
sr = GET_PARAM(3);
|
||||
crit = GET_PARAM(4);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
// MWIDTH=256, MHEIGHT=256. defined in utility.hpp
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
src = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
dstCoor = randomMat(rng, size, typeCoor, 5, 16, false);
|
||||
src = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
dstCoor = randomMat(size, typeCoor, 5, 16, false);
|
||||
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
@@ -1226,7 +1206,7 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria)
|
||||
/////////////////////////meanShiftFiltering/////////////////////////////
|
||||
struct meanShiftFiltering : meanShiftTestBase {};
|
||||
|
||||
TEST_P(meanShiftFiltering, Mat)
|
||||
OCL_TEST_P(meanShiftFiltering, Mat)
|
||||
{
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
@@ -1247,7 +1227,7 @@ TEST_P(meanShiftFiltering, Mat)
|
||||
///////////////////////////meanShiftProc//////////////////////////////////
|
||||
struct meanShiftProc : meanShiftTestBase {};
|
||||
|
||||
TEST_P(meanShiftProc, Mat)
|
||||
OCL_TEST_P(meanShiftProc, Mat)
|
||||
{
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
@@ -1307,18 +1287,15 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType)
|
||||
{
|
||||
type_src = GET_PARAM(0);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
|
||||
src = randomMat(rng, size, type_src, 0, 256, false);
|
||||
src = randomMat(size, type_src, 0, 256, false);
|
||||
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
#ifdef RANDOMROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
@@ -1338,7 +1315,7 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType)
|
||||
///////////////////////////calcHist///////////////////////////////////////
|
||||
struct calcHist : histTestBase {};
|
||||
|
||||
TEST_P(calcHist, Mat)
|
||||
OCL_TEST_P(calcHist, Mat)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -1372,13 +1349,12 @@ PARAM_TEST_CASE(CLAHE, cv::Size, double)
|
||||
gridSize = GET_PARAM(0);
|
||||
clipLimit = GET_PARAM(1);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src = randomMat(rng, cv::Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false);
|
||||
src = randomMat(cv::Size(MWIDTH, MHEIGHT), CV_8UC1, 0, 256, false);
|
||||
g_src.upload(src);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(CLAHE, Accuracy)
|
||||
OCL_TEST_P(CLAHE, Accuracy)
|
||||
{
|
||||
cv::Ptr<cv::CLAHE> clahe = cv::ocl::createCLAHE(clipLimit, gridSize);
|
||||
clahe->apply(g_src, g_dst);
|
||||
@@ -1425,19 +1401,15 @@ PARAM_TEST_CASE(ConvolveTestBase, MatType, bool)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat2 = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
dst1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
mat2 = randomMat(size, type, 5, 16, false);
|
||||
dst = randomMat(size, type, 5, 16, false);
|
||||
dst1 = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
void random_roi()
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
#ifdef RANDOMROI
|
||||
//randomize ROI
|
||||
roicols = rng.uniform(1, mat1.cols);
|
||||
@@ -1505,7 +1477,7 @@ void conv2( cv::Mat x, cv::Mat y, cv::Mat z)
|
||||
dstdata[i * (z.step >> 2) + j] = temp;
|
||||
}
|
||||
}
|
||||
TEST_P(Convolve, Mat)
|
||||
OCL_TEST_P(Convolve, Mat)
|
||||
{
|
||||
if(mat1.type() != CV_32FC1)
|
||||
{
|
||||
@@ -1540,9 +1512,9 @@ PARAM_TEST_CASE(ColumnSum, cv::Size)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ColumnSum, Accuracy)
|
||||
OCL_TEST_P(ColumnSum, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, CV_32FC1);
|
||||
cv::Mat src = randomMat(size, CV_32FC1, 0, 255);
|
||||
cv::ocl::oclMat d_dst;
|
||||
cv::ocl::oclMat d_src(src);
|
||||
|
||||
|
@@ -43,7 +43,9 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
@@ -51,6 +53,7 @@ using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PARAM_TEST_CASE(Kalman, int, int)
|
||||
{
|
||||
int size_;
|
||||
@@ -62,15 +65,13 @@ PARAM_TEST_CASE(Kalman, int, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Kalman, Accuracy)
|
||||
OCL_TEST_P(Kalman, Accuracy)
|
||||
{
|
||||
const int Dim = size_;
|
||||
const int Steps = iteration;
|
||||
const double max_init = 1;
|
||||
const double max_noise = 0.1;
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
Mat sample_mat(Dim, 1, CV_32F), temp_mat;
|
||||
oclMat Sample(Dim, 1, CV_32F);
|
||||
oclMat Temp(Dim, 1, CV_32F);
|
||||
@@ -78,7 +79,7 @@ TEST_P(Kalman, Accuracy)
|
||||
|
||||
Size size(Sample.cols, Sample.rows);
|
||||
|
||||
sample_mat = randomMat(rng, size, Sample.type(), -max_init, max_init, false);
|
||||
sample_mat = randomMat(size, Sample.type(), -max_init, max_init, false);
|
||||
Sample.upload(sample_mat);
|
||||
|
||||
//ocl start
|
||||
@@ -120,7 +121,7 @@ TEST_P(Kalman, Accuracy)
|
||||
cv::gemm(kalman_filter_cpu.transitionMatrix, sample_mat, 1, cv::Mat(), 0, Temp_cpu);
|
||||
|
||||
Size size1(Temp.cols, Temp.rows);
|
||||
Mat temp = randomMat(rng, size1, Temp.type(), 0, 0xffff, false);
|
||||
Mat temp = randomMat(size1, Temp.type(), 0, 0xffff, false);
|
||||
|
||||
|
||||
cv::multiply(2, temp, temp);
|
||||
@@ -141,6 +142,7 @@ TEST_P(Kalman, Accuracy)
|
||||
//test end
|
||||
EXPECT_MAT_NEAR(kalman_filter_cpu.statePost, kalman_filter_ocl.statePost, 0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_Video, Kalman, Combine(Values(3, 7), Values(30)));
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
#endif // HAVE_OPENCL
|
||||
|
@@ -66,12 +66,11 @@ PARAM_TEST_CASE(Kmeans, int, int, int)
|
||||
|
||||
Mat labels, centers;
|
||||
ocl::oclMat d_labels, d_centers;
|
||||
cv::RNG rng ;
|
||||
virtual void SetUp(){
|
||||
virtual void SetUp()
|
||||
{
|
||||
K = GET_PARAM(0);
|
||||
type = GET_PARAM(1);
|
||||
flags = GET_PARAM(2);
|
||||
rng = TS::ptr()->get_rng();
|
||||
|
||||
// MWIDTH=256, MHEIGHT=256. defined in utility.hpp
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
@@ -92,14 +91,14 @@ PARAM_TEST_CASE(Kmeans, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = src.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), -200, 200, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), -200, 200, false);
|
||||
cur_row_header += tmpmat;
|
||||
}
|
||||
row_idx += 1 + max_neighbour;
|
||||
}
|
||||
}
|
||||
};
|
||||
TEST_P(Kmeans, Mat){
|
||||
OCL_TEST_P(Kmeans, Mat){
|
||||
|
||||
if(flags & KMEANS_USE_INITIAL_LABELS)
|
||||
{
|
||||
|
@@ -70,10 +70,10 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::Size, TemplateSize, Channels, TemplateMetho
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(MatchTemplate8U, Accuracy)
|
||||
OCL_TEST_P(MatchTemplate8U, Accuracy)
|
||||
{
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn), 0, 255);
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn), 0, 255);
|
||||
|
||||
cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
@@ -103,10 +103,10 @@ PARAM_TEST_CASE(MatchTemplate32F, cv::Size, TemplateSize, Channels, TemplateMeth
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(MatchTemplate32F, Accuracy)
|
||||
OCL_TEST_P(MatchTemplate32F, Accuracy)
|
||||
{
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn), 0, 255);
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn), 0, 255);
|
||||
|
||||
cv::ocl::oclMat dst, ocl_image(image), ocl_templ(templ);
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
|
@@ -90,10 +90,8 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
||||
|
||||
use_roi = GET_PARAM(3);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
mat = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), src_type, 5, 136, false);
|
||||
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : mat.size(), dst_type, 5, 136, false);
|
||||
mat = randomMat(randomSize(MIN_VALUE, MAX_VALUE), src_type, 5, 136, false);
|
||||
dst = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : mat.size(), dst_type, 5, 136, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@@ -101,7 +99,6 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, mat.cols - roicols);
|
||||
@@ -129,7 +126,7 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType, int, bool)
|
||||
|
||||
typedef ConvertToTestBase ConvertTo;
|
||||
|
||||
TEST_P(ConvertTo, Accuracy)
|
||||
OCL_TEST_P(ConvertTo, Accuracy)
|
||||
{
|
||||
if((src_depth == CV_64F || dst_depth == CV_64F) &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
@@ -178,11 +175,9 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
||||
int type = CV_MAKETYPE(GET_PARAM(0), GET_PARAM(1));
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
|
||||
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
dst = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), type, 5, 16, false);
|
||||
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
src = randomMat(randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
dst = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), type, 5, 16, false);
|
||||
mask = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
}
|
||||
@@ -192,7 +187,6 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
@@ -225,7 +219,7 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, int, bool)
|
||||
|
||||
typedef CopyToTestBase CopyTo;
|
||||
|
||||
TEST_P(CopyTo, Without_mask)
|
||||
OCL_TEST_P(CopyTo, Without_mask)
|
||||
{
|
||||
if((src.depth() == CV_64F) &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
@@ -243,7 +237,7 @@ TEST_P(CopyTo, Without_mask)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(CopyTo, With_mask)
|
||||
OCL_TEST_P(CopyTo, With_mask)
|
||||
{
|
||||
if(src.depth() == CV_64F &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
@@ -295,11 +289,10 @@ PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
int type = CV_MAKE_TYPE(depth, channels);
|
||||
|
||||
src = randomMat(rng, randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
mask = randomMat(rng, use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
src = randomMat(randomSize(MIN_VALUE, MAX_VALUE), type, 5, 16, false);
|
||||
mask = randomMat(use_roi ? randomSize(MIN_VALUE, MAX_VALUE) : src.size(), CV_8UC1, 0, 2, false);
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
val = cv::Scalar(rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0),
|
||||
@@ -311,7 +304,6 @@ PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
// randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, MIN_VALUE);
|
||||
roirows = rng.uniform(1, MIN_VALUE);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
@@ -339,7 +331,7 @@ PARAM_TEST_CASE(SetToTestBase, MatType, int, bool)
|
||||
|
||||
typedef SetToTestBase SetTo;
|
||||
|
||||
TEST_P(SetTo, Without_mask)
|
||||
OCL_TEST_P(SetTo, Without_mask)
|
||||
{
|
||||
if(depth == CV_64F &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
@@ -357,7 +349,7 @@ TEST_P(SetTo, Without_mask)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(SetTo, With_mask)
|
||||
OCL_TEST_P(SetTo, With_mask)
|
||||
{
|
||||
if(depth == CV_64F &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
@@ -401,8 +393,7 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
||||
use_roi = GET_PARAM(1);
|
||||
int type = CV_MAKE_TYPE(depth, 3);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
src = randomMat(rng, randomSize(1, MAX_VALUE), type, 0, 40, false);
|
||||
src = randomMat(randomSize(1, MAX_VALUE), type, 0, 40, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@@ -410,7 +401,6 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, src.cols);
|
||||
roirows = rng.uniform(1, src.rows);
|
||||
srcx = rng.uniform(0, src.cols - roicols);
|
||||
@@ -427,7 +417,7 @@ PARAM_TEST_CASE(convertC3C4, MatType, bool)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(convertC3C4, Accuracy)
|
||||
OCL_TEST_P(convertC3C4, Accuracy)
|
||||
{
|
||||
if(depth == CV_64F &&
|
||||
!cv::ocl::Context::getContext()->supportsFeature(cv::ocl::FEATURE_CL_DOUBLE))
|
||||
|
@@ -44,16 +44,19 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
///////K-NEAREST NEIGHBOR//////////////////////////
|
||||
static void genTrainData(Mat& trainData, int trainDataRow, int trainDataCol,
|
||||
|
||||
static void genTrainData(cv::RNG& rng, Mat& trainData, int trainDataRow, int trainDataCol,
|
||||
Mat& trainLabel = Mat().setTo(Scalar::all(0)), int nClasses = 0)
|
||||
{
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(trainDataCol, trainDataRow);
|
||||
trainData = randomMat(rng, size, CV_32FC1, 1.0, 1000.0, false);
|
||||
if(nClasses != 0)
|
||||
@@ -81,14 +84,14 @@ PARAM_TEST_CASE(KNN, int, Size, int, bool)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(KNN, Accuracy)
|
||||
OCL_TEST_P(KNN, Accuracy)
|
||||
{
|
||||
Mat trainData, trainLabels;
|
||||
const int trainDataRow = 500;
|
||||
genTrainData(trainData, trainDataRow, trainDataCol, trainLabels, nClass);
|
||||
genTrainData(rng, trainData, trainDataRow, trainDataCol, trainLabels, nClass);
|
||||
|
||||
Mat testData, testLabels;
|
||||
genTrainData(testData, testDataRow, trainDataCol);
|
||||
genTrainData(rng, testData, testDataRow, trainDataCol);
|
||||
|
||||
KNearestNeighbour knn_ocl;
|
||||
CvKNearest knn_cpu;
|
||||
@@ -119,10 +122,14 @@ TEST_P(KNN, Accuracy)
|
||||
EXPECT_MAT_NEAR(Mat(best_label_ocl), best_label_cpu, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ML, KNN, Combine(Values(6, 5), Values(Size(200, 400), Size(300, 600)),
|
||||
Values(4, 3), Values(false, true)));
|
||||
|
||||
#ifdef HAVE_CLAMDBLAS // TODO does not work non-blas version of SVM
|
||||
|
||||
////////////////////////////////SVM/////////////////////////////////////////////////
|
||||
|
||||
PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
{
|
||||
cv::Size size;
|
||||
@@ -130,7 +137,6 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
int svm_type;
|
||||
Mat src, labels, samples, labels_predict;
|
||||
int K;
|
||||
cv::RNG rng ;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
@@ -138,7 +144,6 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
kernel_type = GET_PARAM(0);
|
||||
svm_type = GET_PARAM(1);
|
||||
K = GET_PARAM(2);
|
||||
rng = TS::ptr()->get_rng();
|
||||
cv::Size size = cv::Size(MWIDTH, MHEIGHT);
|
||||
src.create(size, CV_32FC1);
|
||||
labels.create(1, size.height, CV_32SC1);
|
||||
@@ -160,7 +165,7 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = src.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
cur_row_header += tmpmat;
|
||||
labels.at<int>(0, row_idx + 1 + j) = i;
|
||||
}
|
||||
@@ -187,7 +192,7 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
{
|
||||
Mat cur_row_header = samples.row(row_idx + 1 + j);
|
||||
center_row_header.copyTo(cur_row_header);
|
||||
Mat tmpmat = randomMat(rng, cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
Mat tmpmat = randomMat(cur_row_header.size(), cur_row_header.type(), 1, 100, false);
|
||||
cur_row_header += tmpmat;
|
||||
labels_predict.at<int>(0, row_idx + 1 + j) = i;
|
||||
}
|
||||
@@ -196,7 +201,8 @@ PARAM_TEST_CASE(SVM_OCL, int, int, int)
|
||||
labels_predict.convertTo(labels_predict, CV_32FC1);
|
||||
}
|
||||
};
|
||||
TEST_P(SVM_OCL, Accuracy)
|
||||
|
||||
OCL_TEST_P(SVM_OCL, Accuracy)
|
||||
{
|
||||
CvSVMParams params;
|
||||
params.degree = 0.4;
|
||||
@@ -292,9 +298,16 @@ TEST_P(SVM_OCL, Accuracy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO FIXIT: CvSVM::EPS_SVR case is crashed inside CPU implementation
|
||||
// Anonymous enums are not supported well so cast them to 'int'
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ML, SVM_OCL, testing::Combine(
|
||||
Values(CvSVM::LINEAR, CvSVM::POLY, CvSVM::RBF, CvSVM::SIGMOID),
|
||||
Values(CvSVM::C_SVC, CvSVM::NU_SVC, CvSVM::ONE_CLASS, CvSVM::EPS_SVR, CvSVM::NU_SVR),
|
||||
Values((int)CvSVM::LINEAR, (int)CvSVM::POLY, (int)CvSVM::RBF, (int)CvSVM::SIGMOID),
|
||||
Values((int)CvSVM::C_SVC, (int)CvSVM::NU_SVC, (int)CvSVM::ONE_CLASS, (int)CvSVM::NU_SVR),
|
||||
Values(2, 3, 4)
|
||||
));
|
||||
|
||||
#endif // HAVE_CLAMDBLAS
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
@@ -7,7 +7,6 @@ using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
{
|
||||
int type;
|
||||
@@ -18,9 +17,8 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
test_contours = GET_PARAM(1);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(10*MWIDTH, 10*MHEIGHT);
|
||||
mat1 = randomMat(rng, size, type, 5, 16, false);
|
||||
mat1 = randomMat(size, type, 5, 16, false);
|
||||
}
|
||||
|
||||
void Compare(Moments& cpu_moments, Moments& gpu_moments)
|
||||
@@ -34,10 +32,9 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
|
||||
};
|
||||
|
||||
|
||||
TEST_P(MomentsTest, Mat)
|
||||
OCL_TEST_P(MomentsTest, Mat)
|
||||
{
|
||||
bool binaryImage = 0;
|
||||
SetUp();
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
|
@@ -49,8 +49,6 @@
|
||||
using namespace cv;
|
||||
using namespace testing;
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
///////////////////// HOG /////////////////////////////
|
||||
PARAM_TEST_CASE(HOG, Size, int)
|
||||
{
|
||||
@@ -66,7 +64,7 @@ PARAM_TEST_CASE(HOG, Size, int)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HOG, GetDescriptors)
|
||||
OCL_TEST_P(HOG, GetDescriptors)
|
||||
{
|
||||
// Convert image
|
||||
Mat img;
|
||||
@@ -112,7 +110,7 @@ TEST_P(HOG, GetDescriptors)
|
||||
EXPECT_MAT_SIMILAR(down_descriptors, cpu_descriptors, 1e-2);
|
||||
}
|
||||
|
||||
TEST_P(HOG, Detect)
|
||||
OCL_TEST_P(HOG, Detect)
|
||||
{
|
||||
// Convert image
|
||||
Mat img;
|
||||
@@ -210,13 +208,14 @@ PARAM_TEST_CASE(Haar, int, CascadeName)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Haar, FaceDetect)
|
||||
OCL_TEST_P(Haar, FaceDetect)
|
||||
{
|
||||
cascade.detectMultiScale(d_img, oclfaces, 1.1, 3,
|
||||
flags, Size(30, 30));
|
||||
|
||||
cpucascade.detectMultiScale(img, faces, 1.1, 3,
|
||||
flags, Size(30, 30));
|
||||
cpucascade.detectMultiScale(img, faces, 1.1, 3,
|
||||
flags,
|
||||
Size(30, 30), Size(0, 0));
|
||||
|
||||
EXPECT_LT(checkRectSimilarity(img.size(), faces, oclfaces), 1.0);
|
||||
}
|
||||
@@ -224,6 +223,3 @@ TEST_P(Haar, FaceDetect)
|
||||
INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, Haar,
|
||||
Combine(Values((int)CASCADE_SCALE_IMAGE, 0),
|
||||
Values(cascade_frontalface_alt, cascade_frontalface_alt2)));
|
||||
|
||||
|
||||
#endif //HAVE_OPENCL
|
||||
|
@@ -52,6 +52,7 @@ using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// GoodFeaturesToTrack
|
||||
@@ -69,7 +70,7 @@ PARAM_TEST_CASE(GoodFeaturesToTrack, MinDistance)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(GoodFeaturesToTrack, Accuracy)
|
||||
OCL_TEST_P(GoodFeaturesToTrack, Accuracy)
|
||||
{
|
||||
cv::Mat frame = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame.empty());
|
||||
@@ -110,7 +111,7 @@ TEST_P(GoodFeaturesToTrack, Accuracy)
|
||||
ASSERT_LE(bad_ratio, 0.01);
|
||||
}
|
||||
|
||||
TEST_P(GoodFeaturesToTrack, EmptyCorners)
|
||||
OCL_TEST_P(GoodFeaturesToTrack, EmptyCorners)
|
||||
{
|
||||
int maxCorners = 1000;
|
||||
double qualityLevel = 0.01;
|
||||
@@ -140,7 +141,7 @@ PARAM_TEST_CASE(TVL1, bool)
|
||||
|
||||
};
|
||||
|
||||
TEST_P(TVL1, DISABLED_Accuracy) // TODO implementations of TV1 in video module are different in 2.4 and master branches
|
||||
OCL_TEST_P(TVL1, DISABLED_Accuracy) // TODO implementations of TV1 in video module are different in 2.4 and master branches
|
||||
{
|
||||
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame0.empty());
|
||||
@@ -149,9 +150,8 @@ TEST_P(TVL1, DISABLED_Accuracy) // TODO implementations of TV1 in video module a
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
|
||||
cv::ocl::OpticalFlowDual_TVL1_OCL d_alg;
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Mat flowx = randomMat(rng, frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowy = randomMat(rng, frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowx = randomMat(frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::Mat flowy = randomMat(frame0.size(), CV_32FC1, 0, 0, useRoi);
|
||||
cv::ocl::oclMat d_flowx(flowx), d_flowy(flowy);
|
||||
d_alg(oclMat(frame0), oclMat(frame1), d_flowx, d_flowy);
|
||||
|
||||
@@ -182,7 +182,7 @@ PARAM_TEST_CASE(Sparse, bool, bool)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Sparse, Mat)
|
||||
OCL_TEST_P(Sparse, Mat)
|
||||
{
|
||||
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
|
||||
ASSERT_FALSE(frame0.empty());
|
||||
@@ -292,7 +292,7 @@ PARAM_TEST_CASE(Farneback, PyrScale, PolyN, FarnebackOptFlowFlags, UseInitFlow)
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Farneback, Accuracy)
|
||||
OCL_TEST_P(Farneback, Accuracy)
|
||||
{
|
||||
cv::Mat frame0 = readImage("gpu/opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame0.empty());
|
||||
|
@@ -72,4 +72,6 @@
|
||||
|
||||
#include "opencv2/core/private.hpp"
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
#endif
|
||||
|
@@ -74,12 +74,12 @@ PARAM_TEST_CASE(PyrBase, MatType, int)
|
||||
|
||||
typedef PyrBase PyrDown;
|
||||
|
||||
TEST_P(PyrDown, Mat)
|
||||
OCL_TEST_P(PyrDown, Mat)
|
||||
{
|
||||
for (int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
Size size(MWIDTH, MHEIGHT);
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels), 0, 255);
|
||||
oclMat gsrc(src);
|
||||
|
||||
pyrDown(src, dst_cpu);
|
||||
@@ -97,12 +97,12 @@ INSTANTIATE_TEST_CASE_P(OCL_ImgProc, PyrDown, Combine(
|
||||
|
||||
typedef PyrBase PyrUp;
|
||||
|
||||
TEST_P(PyrUp, Accuracy)
|
||||
OCL_TEST_P(PyrUp, Accuracy)
|
||||
{
|
||||
for (int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
Size size(MWIDTH, MHEIGHT);
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels));
|
||||
Mat src = randomMat(size, CV_MAKETYPE(depth, channels), 0, 255);
|
||||
oclMat gsrc(src);
|
||||
|
||||
pyrUp(src, dst_cpu);
|
||||
|
@@ -229,7 +229,7 @@ PARAM_TEST_CASE(SortByKey, InputSize, MatType, MatType, SortMethod, IsGreaterTha
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(SortByKey, Accuracy)
|
||||
OCL_TEST_P(SortByKey, Accuracy)
|
||||
{
|
||||
using namespace cv;
|
||||
ocl::oclMat oclmat_key(mat_key);
|
||||
|
@@ -90,12 +90,11 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
for (int i = 0; i < channels; ++i)
|
||||
mat[i] = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
mat[i] = randomMat(size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst = randomMat(size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
}
|
||||
|
||||
void random_roi()
|
||||
@@ -103,7 +102,6 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int, bool)
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat[0].cols);
|
||||
roirows = rng.uniform(1, mat[0].rows);
|
||||
|
||||
@@ -141,7 +139,7 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int, bool)
|
||||
|
||||
struct Merge : MergeTestBase {};
|
||||
|
||||
TEST_P(Merge, Accuracy)
|
||||
OCL_TEST_P(Merge, Accuracy)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
@@ -191,19 +189,17 @@ PARAM_TEST_CASE(SplitTestBase, MatType, int, bool)
|
||||
channels = GET_PARAM(1);
|
||||
use_roi = GET_PARAM(2);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
mat = randomMat(size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
for (int i = 0; i < channels; ++i)
|
||||
dst[i] = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false); }
|
||||
dst[i] = randomMat(size, CV_MAKETYPE(type, 1), 5, 16, false); }
|
||||
|
||||
void random_roi()
|
||||
{
|
||||
if (use_roi)
|
||||
{
|
||||
//randomize ROI
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
roicols = rng.uniform(1, mat.cols);
|
||||
roirows = rng.uniform(1, mat.rows);
|
||||
srcx = rng.uniform(0, mat.cols - roicols);
|
||||
@@ -242,7 +238,7 @@ PARAM_TEST_CASE(SplitTestBase, MatType, int, bool)
|
||||
|
||||
struct Split : SplitTestBase {};
|
||||
|
||||
TEST_P(Split, Accuracy)
|
||||
OCL_TEST_P(Split, Accuracy)
|
||||
{
|
||||
for(int j = 0; j < LOOP_TIMES; j++)
|
||||
{
|
||||
|
@@ -45,7 +45,7 @@ using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cvtest;
|
||||
|
||||
|
||||
namespace cvtest {
|
||||
//std::string generateVarList(int first,...)
|
||||
//{
|
||||
// vector<std::string> varname;
|
||||
@@ -72,41 +72,14 @@ using namespace cvtest;
|
||||
// return ss.str();
|
||||
//};
|
||||
|
||||
int randomInt(int minVal, int maxVal)
|
||||
{
|
||||
RNG &rng = TS::ptr()->get_rng();
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
double randomDouble(double minVal, double maxVal)
|
||||
{
|
||||
RNG &rng = TS::ptr()->get_rng();
|
||||
return rng.uniform(minVal, maxVal);
|
||||
}
|
||||
|
||||
Size randomSize(int minVal, int maxVal)
|
||||
{
|
||||
return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat createMat_ocl(Size size, int type, bool useRoi)
|
||||
cv::ocl::oclMat createMat_ocl(cv::RNG& rng, Size size, int type, bool useRoi)
|
||||
{
|
||||
Size size0 = size;
|
||||
|
||||
if (useRoi)
|
||||
{
|
||||
size0.width += randomInt(5, 15);
|
||||
size0.height += randomInt(5, 15);
|
||||
size0.width += rng.uniform(5, 15);
|
||||
size0.height += rng.uniform(5, 15);
|
||||
}
|
||||
|
||||
cv::ocl::oclMat d_m(size0, type);
|
||||
@@ -117,11 +90,11 @@ cv::ocl::oclMat createMat_ocl(Size size, int type, bool useRoi)
|
||||
return d_m;
|
||||
}
|
||||
|
||||
cv::ocl::oclMat loadMat_ocl(const Mat& m, bool useRoi)
|
||||
cv::ocl::oclMat loadMat_ocl(cv::RNG& rng, const Mat& m, bool useRoi)
|
||||
{
|
||||
CV_Assert(m.type() == CV_8UC1 || m.type() == CV_8UC3);
|
||||
cv::ocl::oclMat d_m;
|
||||
d_m = createMat_ocl(m.size(), m.type(), useRoi);
|
||||
d_m = createMat_ocl(rng, m.size(), m.type(), useRoi);
|
||||
|
||||
Size ls;
|
||||
Point pt;
|
||||
@@ -137,38 +110,6 @@ cv::ocl::oclMat loadMat_ocl(const Mat& m, bool useRoi)
|
||||
m_ocl.copyTo(d_m);
|
||||
return d_m;
|
||||
}
|
||||
/*
|
||||
void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||
{
|
||||
Mat gold;
|
||||
if (gold_.kind() == _InputArray::MAT)
|
||||
gold = gold_.getMat();
|
||||
else
|
||||
gold_.getGpuMat().download(gold);
|
||||
|
||||
Mat actual;
|
||||
if (actual_.kind() == _InputArray::MAT)
|
||||
actual = actual_.getMat();
|
||||
else
|
||||
actual_.getGpuMat().download(actual);
|
||||
|
||||
Mat diff;
|
||||
absdiff(gold, actual, diff);
|
||||
threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);
|
||||
|
||||
namedWindow("gold", WINDOW_NORMAL);
|
||||
namedWindow("actual", WINDOW_NORMAL);
|
||||
namedWindow("diff", WINDOW_NORMAL);
|
||||
|
||||
imshow("gold", gold);
|
||||
imshow("actual", actual);
|
||||
imshow("diff", diff);
|
||||
|
||||
waitKey();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
||||
{
|
||||
@@ -288,3 +229,5 @@ double checkRectSimilarity(Size sz, std::vector<Rect>& ob1, std::vector<Rect>& o
|
||||
}
|
||||
return final_test_result;
|
||||
}
|
||||
|
||||
} // namespace cvtest
|
||||
|
@@ -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