mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
Merge pull request #713 from bitwangyaoyao:2.4_perf
This commit is contained in:
commit
2a1cf23fab
@ -1,120 +0,0 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation 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 the Intel Corporation or 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*/
|
||||
|
||||
#ifndef __OPENCV_TEST_INTERPOLATION_HPP__
|
||||
#define __OPENCV_TEST_INTERPOLATION_HPP__
|
||||
|
||||
template <typename T> T readVal(const cv::Mat &src, int y, int x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
|
||||
{
|
||||
if (border_type == cv::BORDER_CONSTANT)
|
||||
return (y >= 0 && y < src.rows && x >= 0 && x < src.cols) ? src.at<T>(y, x * src.channels() + c) : cv::saturate_cast<T>(borderVal.val[c]);
|
||||
|
||||
return src.at<T>(cv::borderInterpolate(y, src.rows, border_type), cv::borderInterpolate(x, src.cols, border_type) * src.channels() + c);
|
||||
}
|
||||
|
||||
template <typename T> struct NearestInterpolator
|
||||
{
|
||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
|
||||
{
|
||||
return readVal<T>(src, cvFloor(y), cvFloor(x), c, border_type, borderVal);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct LinearInterpolator
|
||||
{
|
||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
|
||||
{
|
||||
x -= 0.5f;
|
||||
y -= 0.5f;
|
||||
|
||||
int x1 = cvFloor(x);
|
||||
int y1 = cvFloor(y);
|
||||
int x2 = x1 + 1;
|
||||
int y2 = y1 + 1;
|
||||
|
||||
float res = 0;
|
||||
|
||||
res += readVal<T>(src, y1, x1, c, border_type, borderVal) * ((x2 - x) * (y2 - y));
|
||||
res += readVal<T>(src, y1, x2, c, border_type, borderVal) * ((x - x1) * (y2 - y));
|
||||
res += readVal<T>(src, y2, x1, c, border_type, borderVal) * ((x2 - x) * (y - y1));
|
||||
res += readVal<T>(src, y2, x2, c, border_type, borderVal) * ((x - x1) * (y - y1));
|
||||
|
||||
return cv::saturate_cast<T>(res);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct CubicInterpolator
|
||||
{
|
||||
static float getValue(float p[4], float x)
|
||||
{
|
||||
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
||||
}
|
||||
|
||||
static float getValue(float p[4][4], float x, float y)
|
||||
{
|
||||
float arr[4];
|
||||
|
||||
arr[0] = getValue(p[0], x);
|
||||
arr[1] = getValue(p[1], x);
|
||||
arr[2] = getValue(p[2], x);
|
||||
arr[3] = getValue(p[3], x);
|
||||
|
||||
return getValue(arr, y);
|
||||
}
|
||||
|
||||
static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
|
||||
{
|
||||
int ix = cvRound(x);
|
||||
int iy = cvRound(y);
|
||||
|
||||
float vals[4][4] =
|
||||
{
|
||||
{readVal<T>(src, iy - 2, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 2, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 2, ix, c, border_type, borderVal), readVal<T>(src, iy - 2, ix + 1, c, border_type, borderVal)},
|
||||
{readVal<T>(src, iy - 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 1, ix, c, border_type, borderVal), readVal<T>(src, iy - 1, ix + 1, c, border_type, borderVal)},
|
||||
{readVal<T>(src, iy , ix - 2, c, border_type, borderVal), readVal<T>(src, iy , ix - 1, c, border_type, borderVal), readVal<T>(src, iy , ix, c, border_type, borderVal), readVal<T>(src, iy , ix + 1, c, border_type, borderVal)},
|
||||
{readVal<T>(src, iy + 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy + 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy + 1, ix, c, border_type, borderVal), readVal<T>(src, iy + 1, ix + 1, c, border_type, borderVal)},
|
||||
};
|
||||
|
||||
return cv::saturate_cast<T>(getValue(vals, (x - ix + 2.0) / 4.0, (y - iy + 2.0) / 4.0));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __OPENCV_TEST_INTERPOLATION_HPP__
|
@ -7,12 +7,13 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// 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,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
@ -21,12 +22,12 @@
|
||||
//
|
||||
// * 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 materials provided with the distribution.
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -41,129 +42,118 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
void print_info()
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
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
|
||||
vector<ocl::Info> oclinfo;
|
||||
int num_devices = getDevice(oclinfo);
|
||||
|
||||
if (num_devices < 1)
|
||||
{
|
||||
cerr << "no device found\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
int devidx = 0;
|
||||
|
||||
for (size_t i = 0; i < oclinfo.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++)
|
||||
{
|
||||
printf("device %d: %s\n", devidx++, oclinfo[i].DeviceName[j].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
redirectError(cvErrorCallback);
|
||||
|
||||
}
|
||||
std::string workdir;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
TS::ptr()->init("ocl");
|
||||
InitGoogleTest(&argc, argv);
|
||||
const char *keys =
|
||||
|
||||
"{ h | help | false | print help message }"
|
||||
|
||||
"{ w | workdir | ../../../samples/c/| set working directory }"
|
||||
|
||||
"{ t | type | gpu | set device type:cpu or gpu}"
|
||||
|
||||
"{ p | platform | 0 | set platform id }"
|
||||
|
||||
"{ d | device | 0 | set device id }";
|
||||
|
||||
|
||||
"{ h | help | false | print help message }"
|
||||
"{ f | filter | | filter for test }"
|
||||
"{ w | workdir | | set working directory }"
|
||||
"{ l | list | false | show all tests }"
|
||||
"{ d | device | 0 | device id }"
|
||||
"{ i | iters | 10 | iteration count }"
|
||||
"{ m | warmup | 1 | gpu warm up iteration count}"
|
||||
"{ t | xtop | 1.1 | xfactor top boundary}"
|
||||
"{ b | xbottom | 0.9 | xfactor bottom boundary}"
|
||||
"{ v | verify | false | only run gpu once to verify if problems occur}";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
|
||||
{
|
||||
|
||||
cout << "Avaible options besides goole test option:" << endl;
|
||||
|
||||
cout << "Avaible options:" << endl;
|
||||
cmd.printParams();
|
||||
return 0;
|
||||
}
|
||||
|
||||
workdir = cmd.get<string>("workdir");
|
||||
|
||||
string type = cmd.get<string>("type");
|
||||
|
||||
unsigned int pid = cmd.get<unsigned int>("platform");
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
|
||||
|
||||
print_info();
|
||||
// int flag = CVCL_DEVICE_TYPE_GPU;
|
||||
|
||||
// if(type == "cpu")
|
||||
|
||||
// {
|
||||
|
||||
// flag = CVCL_DEVICE_TYPE_CPU;
|
||||
|
||||
// }
|
||||
std::vector<cv::ocl::Info> oclinfo;
|
||||
int devnums = getDevice(oclinfo);
|
||||
if(devnums <= device || device < 0)
|
||||
|
||||
if (device < 0 || device >= num_devices)
|
||||
{
|
||||
|
||||
std::cout << "device invalid\n";
|
||||
|
||||
cerr << "Invalid device ID" << endl;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
if(pid >= oclinfo.size())
|
||||
|
||||
if (cmd.get<bool>("verify"))
|
||||
{
|
||||
|
||||
std::cout << "platform invalid\n";
|
||||
|
||||
return -1;
|
||||
|
||||
TestSystem::instance().setNumIters(1);
|
||||
TestSystem::instance().setGPUWarmupIters(0);
|
||||
TestSystem::instance().setCPUIters(0);
|
||||
}
|
||||
|
||||
if(pid != 0 || device != 0)
|
||||
devidx = 0;
|
||||
|
||||
for (size_t i = 0; i < oclinfo.size(); i++)
|
||||
{
|
||||
|
||||
setDevice(oclinfo[pid], device);
|
||||
|
||||
for (size_t j = 0; j < oclinfo[i].DeviceName.size(); j++, devidx++)
|
||||
{
|
||||
if (device == devidx)
|
||||
{
|
||||
ocl::setDevice(oclinfo[i], (int)j);
|
||||
TestSystem::instance().setRecordName(oclinfo[i].DeviceName[j]);
|
||||
printf("\nuse %d: %s\n", devidx, oclinfo[i].DeviceName[j].c_str());
|
||||
goto END_DEV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
|
||||
setBinpath(CLBINPATH);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
END_DEV:
|
||||
|
||||
#else // DON'T HAVE_OPENCL
|
||||
string filter = cmd.get<string>("filter");
|
||||
string workdir = cmd.get<string>("workdir");
|
||||
bool list = cmd.get<bool>("list");
|
||||
int iters = cmd.get<int>("iters");
|
||||
int wu_iters = cmd.get<int>("warmup");
|
||||
double x_top = cmd.get<double>("xtop");
|
||||
double x_bottom = cmd.get<double>("xbottom");
|
||||
|
||||
TestSystem::instance().setTopThreshold(x_top);
|
||||
TestSystem::instance().setBottomThreshold(x_bottom);
|
||||
|
||||
if (!filter.empty())
|
||||
{
|
||||
TestSystem::instance().setTestFilter(filter);
|
||||
}
|
||||
|
||||
if (!workdir.empty())
|
||||
{
|
||||
if (workdir[workdir.size() - 1] != '/' && workdir[workdir.size() - 1] != '\\')
|
||||
{
|
||||
workdir += '/';
|
||||
}
|
||||
|
||||
TestSystem::instance().setWorkingDir(workdir);
|
||||
}
|
||||
|
||||
if (list)
|
||||
{
|
||||
TestSystem::instance().setListMode(true);
|
||||
}
|
||||
|
||||
TestSystem::instance().setNumIters(iters);
|
||||
TestSystem::instance().setGPUWarmupIters(wu_iters);
|
||||
|
||||
TestSystem::instance().run();
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("OpenCV was built without OpenCL support\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -44,79 +44,77 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
PARAM_TEST_CASE(Blend, MatType, int)
|
||||
///////////// blend ////////////////////////
|
||||
template <typename T>
|
||||
void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &weights1, const cv::Mat &weights2, cv::Mat &result_gold)
|
||||
{
|
||||
int type;
|
||||
int channels;
|
||||
std::vector<cv::ocl::Info> oclinfo;
|
||||
result_gold.create(img1.size(), img1.type());
|
||||
|
||||
virtual void SetUp()
|
||||
int cn = img1.channels();
|
||||
|
||||
for (int y = 0; y < img1.rows; ++y)
|
||||
{
|
||||
const float *weights1_row = weights1.ptr<float>(y);
|
||||
const float *weights2_row = weights2.ptr<float>(y);
|
||||
const T *img1_row = img1.ptr<T>(y);
|
||||
const T *img2_row = img2.ptr<T>(y);
|
||||
T *result_gold_row = result_gold.ptr<T>(y);
|
||||
|
||||
type = GET_PARAM(0);
|
||||
channels = GET_PARAM(1);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
//cv::ocl::setBinpath(CLBINPATH);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Blend, Performance)
|
||||
{
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
cv::Mat img1_host = randomMat(size, CV_MAKETYPE(type, channels), 0, type == CV_8U ? 255.0 : 1.0);
|
||||
cv::Mat img2_host = randomMat(size, CV_MAKETYPE(type, channels), 0, type == CV_8U ? 255.0 : 1.0);
|
||||
cv::Mat weights1 = randomMat(size, CV_32F, 0, 1);
|
||||
cv::Mat weights2 = randomMat(size, CV_32F, 0, 1);
|
||||
cv::ocl::oclMat gimg1(size, CV_MAKETYPE(type, channels)), gimg2(size, CV_MAKETYPE(type, channels)), gweights1(size, CV_32F), gweights2(size, CV_32F);
|
||||
cv::ocl::oclMat gdst(size, CV_MAKETYPE(type, channels));
|
||||
|
||||
|
||||
double totalgputick_all = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
|
||||
for (int j = 0; j < LOOP_TIMES + 1; j ++) //LOOP_TIMES=100
|
||||
{
|
||||
t1 = (double)cvGetTickCount();
|
||||
cv::ocl::oclMat gimg1 = cv::ocl::oclMat(img1_host);
|
||||
cv::ocl::oclMat gimg2 = cv::ocl::oclMat(img2_host);
|
||||
cv::ocl::oclMat gweights1 = cv::ocl::oclMat(weights1);
|
||||
cv::ocl::oclMat gweights2 = cv::ocl::oclMat(weights1);
|
||||
|
||||
t2 = (double)cvGetTickCount();
|
||||
cv::ocl::blendLinear(gimg1, gimg2, gweights1, gweights2, gdst);
|
||||
t2 = (double)cvGetTickCount() - t2;
|
||||
|
||||
cv::Mat m;
|
||||
gdst.download(m);
|
||||
t1 = (double)cvGetTickCount() - t1;
|
||||
|
||||
if (j == 0)
|
||||
for (int x = 0; x < img1.cols * cn; ++x)
|
||||
{
|
||||
continue;
|
||||
float w1 = weights1_row[x / cn];
|
||||
float w2 = weights2_row[x / cn];
|
||||
result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));
|
||||
}
|
||||
|
||||
totalgputick_all = t1 + totalgputick_all;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
};
|
||||
|
||||
cout << "average gpu total runtime is " << totalgputick_all / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
cout << "average gpu runtime without data transfering is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
}
|
||||
}
|
||||
TEST(blend)
|
||||
{
|
||||
Mat src1, src2, weights1, weights2, dst;
|
||||
ocl::oclMat d_src1, d_src2, d_weights1, d_weights2, d_dst;
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, Combine(
|
||||
Values(CV_8U, CV_32F), Values(1, 4)));
|
||||
#endif
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " and CV_32FC1";
|
||||
|
||||
gen(src1, size, size, all_type[j], 0, 256);
|
||||
gen(src2, size, size, all_type[j], 0, 256);
|
||||
gen(weights1, size, size, CV_32FC1, 0, 1);
|
||||
gen(weights2, size, size, CV_32FC1, 0, 1);
|
||||
|
||||
blendLinearGold<uchar>(src1, src2, weights1, weights2, dst);
|
||||
|
||||
CPU_ON;
|
||||
blendLinearGold<uchar>(src1, src2, weights1, weights2, dst);
|
||||
CPU_OFF;
|
||||
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
d_weights1.upload(weights1);
|
||||
d_weights2.upload(weights2);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
d_weights1.upload(weights1);
|
||||
d_weights2.upload(weights2);
|
||||
ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
}
|
||||
}
|
150
modules/ocl/perf/perf_brute_force_matcher.cpp
Normal file
150
modules/ocl/perf/perf_brute_force_matcher.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
/*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-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.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// 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 the Intel Corporation or 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 "precomp.hpp"
|
||||
|
||||
//////////////////// BruteForceMatch /////////////////
|
||||
TEST(BruteForceMatcher)
|
||||
{
|
||||
Mat trainIdx_cpu;
|
||||
Mat distance_cpu;
|
||||
Mat allDist_cpu;
|
||||
Mat nMatches_cpu;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
// Init CPU matcher
|
||||
int desc_len = 64;
|
||||
|
||||
BFMatcher matcher(NORM_L2);
|
||||
|
||||
Mat query;
|
||||
gen(query, size, desc_len, CV_32F, 0, 1);
|
||||
|
||||
Mat train;
|
||||
gen(train, size, desc_len, CV_32F, 0, 1);
|
||||
// Output
|
||||
vector< vector<DMatch> > matches(2);
|
||||
// Init GPU matcher
|
||||
ocl::BruteForceMatcher_OCL_base d_matcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
|
||||
|
||||
ocl::oclMat d_query(query);
|
||||
ocl::oclMat d_train(train);
|
||||
|
||||
ocl::oclMat d_trainIdx, d_distance, d_allDist, d_nMatches;
|
||||
|
||||
SUBTEST << size << "; match";
|
||||
|
||||
matcher.match(query, train, matches[0]);
|
||||
|
||||
CPU_ON;
|
||||
matcher.match(query, train, matches[0]);
|
||||
CPU_OFF;
|
||||
|
||||
WARMUP_ON;
|
||||
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_query.upload(query);
|
||||
d_train.upload(train);
|
||||
d_matcher.match(d_query, d_train, matches[0]);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
SUBTEST << size << "; knnMatch";
|
||||
|
||||
matcher.knnMatch(query, train, matches, 2);
|
||||
|
||||
CPU_ON;
|
||||
matcher.knnMatch(query, train, matches, 2);
|
||||
CPU_OFF;
|
||||
|
||||
WARMUP_ON;
|
||||
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_query.upload(query);
|
||||
d_train.upload(train);
|
||||
d_matcher.knnMatch(d_query, d_train, matches, 2);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
SUBTEST << size << "; radiusMatch";
|
||||
|
||||
float max_distance = 2.0f;
|
||||
|
||||
matcher.radiusMatch(query, train, matches, max_distance);
|
||||
|
||||
CPU_ON;
|
||||
matcher.radiusMatch(query, train, matches, max_distance);
|
||||
CPU_OFF;
|
||||
|
||||
d_trainIdx.release();
|
||||
|
||||
WARMUP_ON;
|
||||
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_query.upload(query);
|
||||
d_train.upload(train);
|
||||
d_matcher.radiusMatch(d_query, d_train, matches, max_distance);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
}
|
@ -42,112 +42,42 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
#ifdef HAVE_OPENCL
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
#ifndef MWC_TEST_UTILITY
|
||||
#define MWC_TEST_UTILITY
|
||||
|
||||
// Param class
|
||||
#ifndef IMPLEMENT_PARAM_CLASS
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name ( type arg = type ()) : val_(arg) {} \
|
||||
operator type () const {return val_;} \
|
||||
private: \
|
||||
type val_; \
|
||||
}; \
|
||||
inline void PrintTo( name param, std::ostream* os) \
|
||||
{ \
|
||||
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
|
||||
}
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
#endif // IMPLEMENT_PARAM_CLASS
|
||||
#endif // MWC_TEST_UTILITY
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Canny1
|
||||
extern std::string workdir;
|
||||
IMPLEMENT_PARAM_CLASS(AppertureSize, int);
|
||||
IMPLEMENT_PARAM_CLASS(L2gradient, bool);
|
||||
|
||||
PARAM_TEST_CASE(Canny1, AppertureSize, L2gradient)
|
||||
///////////// Canny ////////////////////////
|
||||
TEST(Canny)
|
||||
{
|
||||
int apperture_size;
|
||||
bool useL2gradient;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
Mat img = imread(abspath("aloeL.jpg"), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
virtual void SetUp()
|
||||
if (img.empty())
|
||||
{
|
||||
apperture_size = GET_PARAM(0);
|
||||
useL2gradient = GET_PARAM(1);
|
||||
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Canny1, Performance)
|
||||
{
|
||||
cv::Mat img = readImage(workdir + "fruits.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
double low_thresh = 100.0;
|
||||
double high_thresh = 150.0;
|
||||
|
||||
cv::Mat edges_gold;
|
||||
cv::ocl::oclMat edges;
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat ocl_img = cv::ocl::oclMat(img);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::Canny(ocl_img, edges, low_thresh, high_thresh, apperture_size, useL2gradient);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
edges.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
throw runtime_error("can't open aloeL.jpg");
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
SUBTEST << img.cols << 'x' << img.rows << "; aloeL.jpg" << "; edges" << "; CV_8UC1";
|
||||
|
||||
Mat edges(img.size(), CV_8UC1);
|
||||
|
||||
}
|
||||
CPU_ON;
|
||||
Canny(img, edges, 50.0, 100.0);
|
||||
CPU_OFF;
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Canny1, testing::Combine(
|
||||
testing::Values(AppertureSize(3), AppertureSize(5)),
|
||||
testing::Values(L2gradient(false), L2gradient(true))));
|
||||
ocl::oclMat d_img(img);
|
||||
ocl::oclMat d_edges;
|
||||
ocl::CannyBuf d_buf;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
#endif //Have opencl
|
||||
GPU_FULL_ON;
|
||||
d_img.upload(img);
|
||||
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
|
||||
d_edges.download(edges);
|
||||
GPU_FULL_OFF;
|
||||
}
|
91
modules/ocl/perf/perf_color.cpp
Normal file
91
modules/ocl/perf/perf_color.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
/*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-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.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// 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 the Intel Corporation or 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 "precomp.hpp"
|
||||
|
||||
///////////// cvtColor////////////////////////
|
||||
TEST(cvtColor)
|
||||
{
|
||||
Mat src, dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
int all_type[] = {CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC4"};
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
SUBTEST << size << "x" << size << "; " << type_name[j] << " ; CV_RGBA2GRAY";
|
||||
|
||||
cvtColor(src, dst, CV_RGBA2GRAY, 4);
|
||||
|
||||
CPU_ON;
|
||||
cvtColor(src, dst, CV_RGBA2GRAY, 4);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::cvtColor(d_src, d_dst, CV_RGBA2GRAY, 4);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -15,8 +15,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai fangfang@multicorewareinc.com
|
||||
//
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -31,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -43,78 +42,47 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// ColumnSum
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ColumnSum
|
||||
|
||||
PARAM_TEST_CASE(ColumnSum)
|
||||
///////////// columnSum////////////////////////
|
||||
TEST(columnSum)
|
||||
{
|
||||
cv::Mat src;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
Mat src, dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
SUBTEST << size << 'x' << size << "; CV_32FC1";
|
||||
|
||||
gen(src, size, size, CV_32FC1, 0, 256);
|
||||
|
||||
CPU_ON;
|
||||
dst.create(src.size(), src.type());
|
||||
|
||||
for (int i = 1; i < src.rows; ++i)
|
||||
{
|
||||
for (int j = 0; j < src.cols; ++j)
|
||||
{
|
||||
dst.at<float>(i, j) = src.at<float>(i, j) += src.at<float>(i - 1, j);
|
||||
}
|
||||
}
|
||||
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
WARMUP_ON;
|
||||
ocl::columnSum(d_src, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::columnSum(d_src, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::columnSum(d_src, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ColumnSum, Performance)
|
||||
{
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
cv::Mat src = randomMat(size, CV_32FC1);
|
||||
cv::ocl::oclMat d_dst;
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat d_src(src);
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::columnSum(d_src, d_dst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
d_dst.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfangbai, fangfang@multicorewareinc.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -42,85 +42,48 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
using namespace std;
|
||||
#ifdef HAVE_CLAMDFFT
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Dft
|
||||
PARAM_TEST_CASE(Dft, cv::Size, bool)
|
||||
|
||||
///////////// dft ////////////////////////
|
||||
TEST(dft)
|
||||
{
|
||||
cv::Size dft_size;
|
||||
bool dft_rows;
|
||||
vector<cv::ocl::Info> info;
|
||||
virtual void SetUp()
|
||||
Mat src, dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
int all_type[] = {CV_32FC1, CV_32FC2};
|
||||
std::string type_name[] = {"CV_32FC1", "CV_32FC2"};
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
dft_size = GET_PARAM(0);
|
||||
dft_rows = GET_PARAM(1);
|
||||
cv::ocl::getDevice(info);
|
||||
}
|
||||
};
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " ; complex-to-complex";
|
||||
|
||||
TEST_P(Dft, C2C)
|
||||
{
|
||||
cv::Mat a = randomMat(dft_size, CV_32FC2, 0.0, 10.0);
|
||||
int flags = 0;
|
||||
flags |= dft_rows ? cv::DFT_ROWS : 0;
|
||||
gen(src, size, size, all_type[j], Scalar::all(0), Scalar::all(1));
|
||||
|
||||
cv::ocl::oclMat d_b;
|
||||
dft(src, dst);
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
CPU_ON;
|
||||
dft(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
d_src.upload(src);
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
WARMUP_ON;
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
WARMUP_OFF;
|
||||
|
||||
cv::ocl::oclMat ga = cv::ocl::oclMat(a); //upload
|
||||
GPU_ON;
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::dft(ga, d_b, a.size(), flags);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
d_b.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST_P(Dft, R2CthenC2R)
|
||||
{
|
||||
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 10.0);
|
||||
|
||||
int flags = 0;
|
||||
//flags |= dft_rows ? cv::DFT_ROWS : 0; // not supported yet
|
||||
|
||||
cv::ocl::oclMat d_b, d_c;
|
||||
|
||||
cv::ocl::dft(cv::ocl::oclMat(a), d_b, a.size(), flags);
|
||||
cv::ocl::dft(d_b, d_c, a.size(), flags + cv::DFT_INVERSE + cv::DFT_REAL_OUTPUT);
|
||||
|
||||
EXPECT_MAT_NEAR(a, d_c, a.size().area() * 1e-4, "");
|
||||
}
|
||||
|
||||
//INSTANTIATE_TEST_CASE_P(ocl_DFT, Dft, testing::Combine(
|
||||
// testing::Values(cv::Size(1280, 1024), cv::Size(1920, 1080),cv::Size(1800, 1500)),
|
||||
// testing::Values(false, true)));
|
||||
|
||||
#endif // HAVE_CLAMDFFT
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,7 @@
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
@ -41,73 +42,47 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
|
||||
#include "precomp.hpp"
|
||||
using namespace std;
|
||||
#ifdef HAVE_CLAMDBLAS
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// GEMM
|
||||
PARAM_TEST_CASE(Gemm, int, cv::Size, int)
|
||||
|
||||
///////////// gemm ////////////////////////
|
||||
TEST(gemm)
|
||||
{
|
||||
int type;
|
||||
cv::Size mat_size;
|
||||
int flags;
|
||||
vector<cv::ocl::Info> info;
|
||||
virtual void SetUp()
|
||||
Mat src1, src2, src3, dst;
|
||||
ocl::oclMat d_src1, d_src2, d_src3, d_dst;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
mat_size = GET_PARAM(1);
|
||||
flags = GET_PARAM(2);
|
||||
SUBTEST << size << 'x' << size;
|
||||
|
||||
cv::ocl::getDevice(info);
|
||||
gen(src1, size, size, CV_32FC1, Scalar::all(-10), Scalar::all(10));
|
||||
gen(src2, size, size, CV_32FC1, Scalar::all(-10), Scalar::all(10));
|
||||
gen(src3, size, size, CV_32FC1, Scalar::all(-10), Scalar::all(10));
|
||||
|
||||
gemm(src1, src2, 1.0, src3, 1.0, dst);
|
||||
|
||||
CPU_ON;
|
||||
gemm(src1, src2, 1.0, src3, 1.0, dst);
|
||||
CPU_OFF;
|
||||
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
d_src3.upload(src3);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
d_src3.upload(src3);
|
||||
ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(Gemm, Performance)
|
||||
{
|
||||
cv::Mat a = randomMat(mat_size, type, 0.0, 10.0);
|
||||
cv::Mat b = randomMat(mat_size, type, 0.0, 10.0);
|
||||
cv::Mat c = randomMat(mat_size, type, 0.0, 10.0);
|
||||
cv::ocl::oclMat ocl_dst;
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat ga = cv::ocl::oclMat(a);//upload
|
||||
cv::ocl::oclMat gb = cv::ocl::oclMat(b);//upload
|
||||
cv::ocl::oclMat gc = cv::ocl::oclMat(c);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::gemm(ga, gb, 1.0, gc, 1.0, ocl_dst, flags);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
ocl_dst.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ocl_gemm, Gemm, testing::Combine(
|
||||
testing::Values(CV_32FC1, CV_32FC2/* , CV_64FC1, CV_64FC2*/),
|
||||
testing::Values(cv::Size(512, 512), cv::Size(1024, 1024)),
|
||||
testing::Values(0, (int)cv::GEMM_1_T, (int)cv::GEMM_2_T, (int)(cv::GEMM_1_T + cv::GEMM_2_T))));
|
||||
#endif
|
||||
}
|
@ -10,12 +10,12 @@
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, 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.
|
||||
//
|
||||
// @Authors
|
||||
// Jia Haipeng, jiahaipeng95@gmail.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -42,133 +42,97 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
///////////// Haar ////////////////////////
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
extern std::string workdir;
|
||||
struct getRect
|
||||
{
|
||||
Rect operator ()(const CvAvgComp &e) const
|
||||
Rect operator()(const CvAvgComp &e) const
|
||||
{
|
||||
return e.rect;
|
||||
}
|
||||
};
|
||||
|
||||
PARAM_TEST_CASE(HaarTestBase, int, int)
|
||||
class CascadeClassifier_GPU : public OclCascadeClassifier
|
||||
{
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
cv::ocl::OclCascadeClassifier cascade, nestedCascade;
|
||||
cv::CascadeClassifier cpucascade, cpunestedCascade;
|
||||
// Mat img;
|
||||
|
||||
double scale;
|
||||
int index;
|
||||
|
||||
virtual void SetUp()
|
||||
public:
|
||||
void detectMultiScale(oclMat &image,
|
||||
CV_OUT std::vector<cv::Rect>& faces,
|
||||
double scaleFactor = 1.1,
|
||||
int minNeighbors = 3, int flags = 0,
|
||||
Size minSize = Size(),
|
||||
Size maxSize = Size())
|
||||
{
|
||||
scale = 1.0;
|
||||
index = 0;
|
||||
string cascadeName = "../../../data/haarcascades/haarcascade_frontalface_alt.xml";
|
||||
|
||||
if( (!cascade.load( cascadeName )) || (!cpucascade.load(cascadeName)))
|
||||
{
|
||||
cout << "ERROR: Could not load classifier cascade" << endl;
|
||||
return;
|
||||
}
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums>0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//cv::ocl::setBinpath("E:\\");
|
||||
(void)maxSize;
|
||||
MemStorage storage(cvCreateMemStorage(0));
|
||||
//CvMat img=image;
|
||||
CvSeq *objs = oclHaarDetectObjects(image, storage, scaleFactor, minNeighbors, flags, minSize);
|
||||
vector<CvAvgComp> vecAvgComp;
|
||||
Seq<CvAvgComp>(objs).copyTo(vecAvgComp);
|
||||
faces.resize(vecAvgComp.size());
|
||||
std::transform(vecAvgComp.begin(), vecAvgComp.end(), faces.begin(), getRect());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////faceDetect/////////////////////////////////////////////////
|
||||
|
||||
struct Haar : HaarTestBase {};
|
||||
|
||||
TEST_F(Haar, FaceDetect)
|
||||
{
|
||||
string imgName = workdir + "lena.jpg";
|
||||
Mat img = imread( imgName, 1 );
|
||||
|
||||
if(img.empty())
|
||||
{
|
||||
std::cout << imgName << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
//int i = 0;
|
||||
double t = 0;
|
||||
vector<Rect> faces, oclfaces;
|
||||
|
||||
// const static Scalar colors[] = { CV_RGB(0, 0, 255),
|
||||
// CV_RGB(0, 128, 255),
|
||||
// CV_RGB(0, 255, 255),
|
||||
// CV_RGB(0, 255, 0),
|
||||
// CV_RGB(255, 128, 0),
|
||||
// CV_RGB(255, 255, 0),
|
||||
// CV_RGB(255, 0, 0),
|
||||
// CV_RGB(255, 0, 255)
|
||||
// } ;
|
||||
|
||||
Mat gray, smallImg(cvRound (img.rows / scale), cvRound(img.cols / scale), CV_8UC1 );
|
||||
MemStorage storage(cvCreateMemStorage(0));
|
||||
cvtColor( img, gray, CV_BGR2GRAY );
|
||||
resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR );
|
||||
equalizeHist( smallImg, smallImg );
|
||||
|
||||
t = (double)cvGetTickCount();
|
||||
for(int k = 0; k < LOOP_TIMES; k++)
|
||||
{
|
||||
cpucascade.detectMultiScale( smallImg, faces, 1.1,
|
||||
3, 0
|
||||
| CV_HAAR_SCALE_IMAGE
|
||||
, Size(30, 30), Size(0, 0) );
|
||||
}
|
||||
t = (double)cvGetTickCount() - t ;
|
||||
printf( "cpudetection time = %g ms\n", t / (LOOP_TIMES * (double)cvGetTickFrequency() * 1000.) );
|
||||
|
||||
cv::ocl::oclMat image;
|
||||
CvSeq *_objects=NULL;
|
||||
t = (double)cvGetTickCount();
|
||||
for(int k = 0; k < LOOP_TIMES; k++)
|
||||
{
|
||||
image.upload(smallImg);
|
||||
_objects = cascade.oclHaarDetectObjects( image, storage, 1.1,
|
||||
3, 0
|
||||
| CV_HAAR_SCALE_IMAGE
|
||||
, Size(30, 30), Size(0, 0) );
|
||||
}
|
||||
t = (double)cvGetTickCount() - t ;
|
||||
printf( "ocldetection time = %g ms\n", t / (LOOP_TIMES * (double)cvGetTickFrequency() * 1000.) );
|
||||
vector<CvAvgComp> vecAvgComp;
|
||||
Seq<CvAvgComp>(_objects).copyTo(vecAvgComp);
|
||||
oclfaces.resize(vecAvgComp.size());
|
||||
std::transform(vecAvgComp.begin(), vecAvgComp.end(), oclfaces.begin(), getRect());
|
||||
|
||||
//for( vector<Rect>::const_iterator r = faces.begin(); r != faces.end(); r++, i++ )
|
||||
//{
|
||||
// Mat smallImgROI;
|
||||
// Point center;
|
||||
// Scalar color = colors[i%8];
|
||||
// int radius;
|
||||
// center.x = cvRound((r->x + r->width*0.5)*scale);
|
||||
// center.y = cvRound((r->y + r->height*0.5)*scale);
|
||||
// radius = cvRound((r->width + r->height)*0.25*scale);
|
||||
// circle( img, center, radius, color, 3, 8, 0 );
|
||||
//}
|
||||
//namedWindow("result");
|
||||
//imshow("result",img);
|
||||
//waitKey(0);
|
||||
//destroyAllWindows();
|
||||
|
||||
}
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
||||
TEST(Haar)
|
||||
{
|
||||
Mat img = imread(abspath("basketball1.png"), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
throw runtime_error("can't open basketball1.png");
|
||||
}
|
||||
|
||||
CascadeClassifier faceCascadeCPU;
|
||||
|
||||
if (!faceCascadeCPU.load(abspath("haarcascade_frontalface_alt.xml")))
|
||||
{
|
||||
throw runtime_error("can't load haarcascade_frontalface_alt.xml");
|
||||
}
|
||||
|
||||
vector<Rect> faces;
|
||||
|
||||
SUBTEST << img.cols << "x" << img.rows << "; scale image";
|
||||
CPU_ON;
|
||||
faceCascadeCPU.detectMultiScale(img, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
CPU_OFF;
|
||||
|
||||
ocl::CascadeClassifier_GPU faceCascade;
|
||||
|
||||
if (!faceCascade.load(abspath("haarcascade_frontalface_alt.xml")))
|
||||
{
|
||||
throw runtime_error("can't load haarcascade_frontalface_alt.xml");
|
||||
}
|
||||
|
||||
ocl::oclMat d_img(img);
|
||||
|
||||
faces.clear();
|
||||
|
||||
WARMUP_ON;
|
||||
faceCascade.detectMultiScale(d_img, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
WARMUP_OFF;
|
||||
|
||||
faces.clear();
|
||||
|
||||
GPU_ON;
|
||||
faceCascade.detectMultiScale(d_img, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_img.upload(img);
|
||||
faceCascade.detectMultiScale(d_img, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
GPU_FULL_OFF;
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Peng Xiao, pengxiao@multicorewareinc.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -42,125 +42,47 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
extern std::string workdir;
|
||||
|
||||
#ifndef MWC_TEST_UTILITY
|
||||
#define MWC_TEST_UTILITY
|
||||
|
||||
// Param class
|
||||
#ifndef IMPLEMENT_PARAM_CLASS
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name ( type arg = type ()) : val_(arg) {} \
|
||||
operator type () const {return val_;} \
|
||||
private: \
|
||||
type val_; \
|
||||
}; \
|
||||
inline void PrintTo( name param, std::ostream* os) \
|
||||
{ \
|
||||
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
|
||||
}
|
||||
|
||||
#endif // IMPLEMENT_PARAM_CLASS
|
||||
#endif // MWC_TEST_UTILITY
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(WinSizw48, bool);
|
||||
|
||||
PARAM_TEST_CASE(HOG, WinSizw48, bool)
|
||||
///////////// HOG////////////////////////
|
||||
TEST(HOG)
|
||||
{
|
||||
bool is48;
|
||||
vector<float> detector;
|
||||
virtual void SetUp()
|
||||
Mat src = imread(abspath("road.png"), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
if (src.empty())
|
||||
{
|
||||
is48 = GET_PARAM(0);
|
||||
if(is48)
|
||||
{
|
||||
detector = cv::ocl::HOGDescriptor::getPeopleDetector48x96();
|
||||
}
|
||||
else
|
||||
{
|
||||
detector = cv::ocl::HOGDescriptor::getPeopleDetector64x128();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HOG, Performance)
|
||||
{
|
||||
cv::Mat img = readImage(workdir + "lena.jpg", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
// define HOG related arguments
|
||||
float scale = 1.05f;
|
||||
//int nlevels = 13;
|
||||
int gr_threshold = 8;
|
||||
float hit_threshold = 1.4f;
|
||||
//bool hit_threshold_auto = true;
|
||||
|
||||
int win_width = is48 ? 48 : 64;
|
||||
int win_stride_width = 8;
|
||||
int win_stride_height = 8;
|
||||
|
||||
bool gamma_corr = true;
|
||||
|
||||
Size win_size(win_width, win_width * 2); //(64, 128) or (48, 96)
|
||||
Size win_stride(win_stride_width, win_stride_height);
|
||||
|
||||
cv::ocl::HOGDescriptor gpu_hog(win_size, Size(16, 16), Size(8, 8), Size(8, 8), 9,
|
||||
cv::ocl::HOGDescriptor::DEFAULT_WIN_SIGMA, 0.2, gamma_corr,
|
||||
cv::ocl::HOGDescriptor::DEFAULT_NLEVELS);
|
||||
|
||||
gpu_hog.setSVMDetector(detector);
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
ocl::oclMat d_src(img);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
|
||||
vector<Rect> found;
|
||||
gpu_hog.detectMultiScale(d_src, found, hit_threshold, win_stride,
|
||||
Size(0, 0), scale, gr_threshold);
|
||||
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
// no download time for HOG
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
throw runtime_error("can't open road.png");
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
|
||||
cv::HOGDescriptor hog;
|
||||
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||
std::vector<cv::Rect> found_locations;
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, HOG, testing::Combine(testing::Values(WinSizw48(false), WinSizw48(true)), testing::Values(false)));
|
||||
SUBTEST << 768 << 'x' << 576 << "; road.png";
|
||||
|
||||
#endif //Have opencl
|
||||
hog.detectMultiScale(src, found_locations);
|
||||
|
||||
CPU_ON;
|
||||
hog.detectMultiScale(src, found_locations);
|
||||
CPU_OFF;
|
||||
|
||||
cv::ocl::HOGDescriptor ocl_hog;
|
||||
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector());
|
||||
ocl::oclMat d_src;
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl_hog.detectMultiScale(d_src, found_locations);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl_hog.detectMultiScale(d_src, found_locations);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl_hog.detectMultiScale(d_src, found_locations);
|
||||
GPU_FULL_OFF;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -42,191 +42,105 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
#ifdef HAVE_OPENCL
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
#ifndef MWC_TEST_UTILITY
|
||||
#define MWC_TEST_UTILITY
|
||||
//////// Utility
|
||||
#ifndef DIFFERENT_SIZES
|
||||
#else
|
||||
#undef DIFFERENT_SIZES
|
||||
#endif
|
||||
#define DIFFERENT_SIZES testing::Values(cv::Size(256, 256), cv::Size(3000, 3000))
|
||||
|
||||
// Param class
|
||||
#ifndef IMPLEMENT_PARAM_CLASS
|
||||
#define IMPLEMENT_PARAM_CLASS(name, type) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name ( type arg = type ()) : val_(arg) {} \
|
||||
operator type () const {return val_;} \
|
||||
private: \
|
||||
type val_; \
|
||||
}; \
|
||||
inline void PrintTo( name param, std::ostream* os) \
|
||||
{ \
|
||||
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
|
||||
}
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(Channels, int)
|
||||
#endif // IMPLEMENT_PARAM_CLASS
|
||||
#endif // MWC_TEST_UTILITY
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MatchTemplate
|
||||
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF_NORMED))
|
||||
|
||||
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size);
|
||||
|
||||
const char *TEMPLATE_METHOD_NAMES[6] = {"TM_SQDIFF", "TM_SQDIFF_NORMED", "TM_CCORR", "TM_CCORR_NORMED", "TM_CCOEFF", "TM_CCOEFF_NORMED"};
|
||||
|
||||
PARAM_TEST_CASE(MatchTemplate, cv::Size, TemplateSize, Channels, TemplateMethod)
|
||||
/////////// matchTemplate ////////////////////////
|
||||
//void InitMatchTemplate()
|
||||
//{
|
||||
// Mat src; gen(src, 500, 500, CV_32F, 0, 1);
|
||||
// Mat templ; gen(templ, 500, 500, CV_32F, 0, 1);
|
||||
// ocl::oclMat d_src(src), d_templ(templ), d_dst;
|
||||
// ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
||||
//}
|
||||
TEST(matchTemplate)
|
||||
{
|
||||
cv::Size size;
|
||||
cv::Size templ_size;
|
||||
int cn;
|
||||
int method;
|
||||
//vector<cv::ocl::Info> oclinfo;
|
||||
//InitMatchTemplate();
|
||||
|
||||
virtual void SetUp()
|
||||
Mat src, templ, dst;
|
||||
int templ_size = 5;
|
||||
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
size = GET_PARAM(0);
|
||||
templ_size = GET_PARAM(1);
|
||||
cn = GET_PARAM(2);
|
||||
method = GET_PARAM(3);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
int all_type[] = {CV_32FC1, CV_32FC4};
|
||||
std::string type_name[] = {"CV_32FC1", "CV_32FC4"};
|
||||
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
for(templ_size = 5; templ_size <= 5; templ_size *= 5)
|
||||
{
|
||||
gen(src, size, size, all_type[j], 0, 1);
|
||||
|
||||
SUBTEST << src.cols << 'x' << src.rows << "; " << type_name[j] << "; templ " << templ_size << 'x' << templ_size << "; CCORR";
|
||||
|
||||
gen(templ, templ_size, templ_size, all_type[j], 0, 1);
|
||||
|
||||
matchTemplate(src, templ, dst, CV_TM_CCORR);
|
||||
|
||||
CPU_ON;
|
||||
matchTemplate(src, templ, dst, CV_TM_CCORR);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src), d_templ, d_dst;
|
||||
|
||||
d_templ.upload(templ);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_templ.upload(templ);
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
int all_type_8U[] = {CV_8UC1};
|
||||
std::string type_name_8U[] = {"CV_8UC1"};
|
||||
|
||||
for (size_t j = 0; j < sizeof(all_type_8U) / sizeof(int); j++)
|
||||
{
|
||||
for(templ_size = 5; templ_size <= 5; templ_size *= 5)
|
||||
{
|
||||
SUBTEST << src.cols << 'x' << src.rows << "; " << type_name_8U[j] << "; templ " << templ_size << 'x' << templ_size << "; CCORR_NORMED";
|
||||
|
||||
gen(src, size, size, all_type_8U[j], 0, 255);
|
||||
|
||||
gen(templ, templ_size, templ_size, all_type_8U[j], 0, 255);
|
||||
|
||||
matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
|
||||
|
||||
CPU_ON;
|
||||
matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src);
|
||||
ocl::oclMat d_templ(templ), d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR_NORMED);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR_NORMED);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_templ.upload(templ);
|
||||
ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR_NORMED);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
struct MatchTemplate8U : MatchTemplate {};
|
||||
|
||||
TEST_P(MatchTemplate8U, Performance)
|
||||
{
|
||||
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
|
||||
std::cout << "Image Size: (" << size.width << ", " << size.height << ")" << std::endl;
|
||||
std::cout << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")" << std::endl;
|
||||
std::cout << "Channels: " << cn << std::endl;
|
||||
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
|
||||
cv::Mat dst_gold;
|
||||
cv::ocl::oclMat dst;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
|
||||
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
dst.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct MatchTemplate32F : MatchTemplate {};
|
||||
TEST_P(MatchTemplate32F, Performance)
|
||||
{
|
||||
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
|
||||
std::cout << "Image Size: (" << size.width << ", " << size.height << ")" << std::endl;
|
||||
std::cout << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")" << std::endl;
|
||||
std::cout << "Channels: " << cn << std::endl;
|
||||
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
|
||||
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
|
||||
|
||||
cv::Mat dst_gold;
|
||||
cv::ocl::oclMat dst;
|
||||
|
||||
|
||||
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int j = 0; j < LOOP_TIMES; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
|
||||
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
dst.download (cpu_dst);//download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U,
|
||||
testing::Combine(
|
||||
testing::Values(cv::Size(1280, 1024), cv::Size(MWIDTH, MHEIGHT), cv::Size(1800, 1500)),
|
||||
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16))/*, TemplateSize(cv::Size(30, 30))*/),
|
||||
testing::Values(Channels(1), Channels(4)/*, Channels(3)*/),
|
||||
ALL_TEMPLATE_METHODS
|
||||
)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate32F, testing::Combine(
|
||||
testing::Values(cv::Size(1280, 1024), cv::Size(MWIDTH, MHEIGHT), cv::Size(1800, 1500)),
|
||||
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16))/*, TemplateSize(cv::Size(30, 30))*/),
|
||||
testing::Values(Channels(1), Channels(4) /*, Channels(3)*/),
|
||||
testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))));
|
||||
|
||||
#endif //HAVE_OPENCL
|
||||
}
|
@ -10,12 +10,12 @@
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, 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.
|
||||
//
|
||||
// @Authors
|
||||
// Jia Haipeng, jiahaipeng95@gmail.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -42,697 +42,140 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
////////////////////////////////converto/////////////////////////////////////////////////
|
||||
PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType)
|
||||
///////////// ConvertTo////////////////////////
|
||||
TEST(ConvertTo)
|
||||
{
|
||||
int type;
|
||||
int dst_type;
|
||||
Mat src, dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
//src mat
|
||||
cv::Mat mat;
|
||||
cv::Mat dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
// set up roi
|
||||
int roicols;
|
||||
int roirows;
|
||||
int srcx;
|
||||
int srcy;
|
||||
int dstx;
|
||||
int dsty;
|
||||
|
||||
//src mat with roi
|
||||
cv::Mat mat_roi;
|
||||
cv::Mat dst_roi;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
cv::ocl::oclMat gdst_whole;
|
||||
|
||||
//ocl mat with roi
|
||||
cv::ocl::oclMat gmat;
|
||||
cv::ocl::oclMat gdst;
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
dst_type = GET_PARAM(1);
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " to 32FC1";
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
//gen(dst, size, size, all_type[j], 0, 256);
|
||||
|
||||
//d_dst.upload(dst);
|
||||
|
||||
src.convertTo(dst, CV_32FC1);
|
||||
|
||||
CPU_ON;
|
||||
src.convertTo(dst, CV_32FC1);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
d_src.convertTo(d_dst, CV_32FC1);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_src.convertTo(d_dst, CV_32FC1);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_src.convertTo(d_dst, CV_32FC1);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
mat = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//setBinpath(CLBINPATH);
|
||||
}
|
||||
|
||||
void Has_roi(int b)
|
||||
{
|
||||
//cv::RNG& rng = TS::ptr()->get_rng();
|
||||
if(b)
|
||||
{
|
||||
//randomize ROI
|
||||
roicols = mat.cols - 1; //start
|
||||
roirows = mat.rows - 1;
|
||||
srcx = 1;
|
||||
srcy = 1;
|
||||
dstx = 1;
|
||||
dsty = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = mat.cols;
|
||||
roirows = mat.rows;
|
||||
srcx = 0;
|
||||
srcy = 0;
|
||||
dstx = 0;
|
||||
dsty = 0;
|
||||
};
|
||||
|
||||
mat_roi = mat(Rect(srcx, srcy, roicols, roirows));
|
||||
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
//gdst_whole = dst;
|
||||
//gdst = gdst_whole(Rect(dstx,dsty,roicols,roirows));
|
||||
|
||||
//gmat = mat_roi;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct ConvertTo : ConvertToTestBase {};
|
||||
|
||||
TEST_P(ConvertTo, Accuracy)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
mat_roi.convertTo(dst_roi, dst_type);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
gmat.convertTo(gdst, dst_type);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gdst_whole.download (cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
gmat.convertTo(gdst, dst_type);
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////copyto/////////////////////////////////////////////////////////////
|
||||
|
||||
PARAM_TEST_CASE(CopyToTestBase, MatType, bool)
|
||||
///////////// copyTo////////////////////////
|
||||
TEST(copyTo)
|
||||
{
|
||||
int type;
|
||||
Mat src, dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
cv::Mat mat;
|
||||
cv::Mat mask;
|
||||
cv::Mat dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
// set up roi
|
||||
int roicols;
|
||||
int roirows;
|
||||
int srcx;
|
||||
int srcy;
|
||||
int dstx;
|
||||
int dsty;
|
||||
int maskx;
|
||||
int masky;
|
||||
|
||||
//src mat with roi
|
||||
cv::Mat mat_roi;
|
||||
cv::Mat mask_roi;
|
||||
cv::Mat dst_roi;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
cv::ocl::oclMat gdst_whole;
|
||||
|
||||
//ocl mat with roi
|
||||
cv::ocl::oclMat gmat;
|
||||
cv::ocl::oclMat gdst;
|
||||
cv::ocl::oclMat gmask;
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
//gen(dst, size, size, all_type[j], 0, 256);
|
||||
|
||||
mat = randomMat(rng, size, type, 5, 16, false);
|
||||
dst = randomMat(rng, size, type, 5, 16, false);
|
||||
mask = randomMat(rng, size, CV_8UC1, 0, 2, false);
|
||||
//d_dst.upload(dst);
|
||||
|
||||
src.copyTo(dst);
|
||||
|
||||
CPU_ON;
|
||||
src.copyTo(dst);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
d_src.copyTo(d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_src.copyTo(d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_src.copyTo(d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
cv::threshold(mask, mask, 0.5, 255., CV_8UC1);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//setBinpath(CLBINPATH);
|
||||
}
|
||||
|
||||
void Has_roi(int b)
|
||||
{
|
||||
//cv::RNG& rng = TS::ptr()->get_rng();
|
||||
if(b)
|
||||
{
|
||||
//randomize ROI
|
||||
roicols = mat.cols - 1; //start
|
||||
roirows = mat.rows - 1;
|
||||
srcx = 1;
|
||||
srcy = 1;
|
||||
dstx = 1;
|
||||
dsty = 1;
|
||||
maskx = 1;
|
||||
masky = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = mat.cols;
|
||||
roirows = mat.rows;
|
||||
srcx = 0;
|
||||
srcy = 0;
|
||||
dstx = 0;
|
||||
dsty = 0;
|
||||
maskx = 0;
|
||||
masky = 0;
|
||||
};
|
||||
|
||||
mat_roi = mat(Rect(srcx, srcy, roicols, roirows));
|
||||
mask_roi = mask(Rect(maskx, masky, roicols, roirows));
|
||||
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
//gdst_whole = dst;
|
||||
//gdst = gdst_whole(Rect(dstx,dsty,roicols,roirows));
|
||||
|
||||
//gmat = mat_roi;
|
||||
//gmask = mask_roi;
|
||||
}
|
||||
};
|
||||
|
||||
struct CopyTo : CopyToTestBase {};
|
||||
|
||||
TEST_P(CopyTo, Without_mask)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
mat_roi.copyTo(dst_roi);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
gmat.copyTo(gdst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gdst_whole.download (cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
gmat.copyTo(gdst);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_P(CopyTo, With_mask)
|
||||
///////////// setTo////////////////////////
|
||||
TEST(setTo)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
Mat src, dst;
|
||||
Scalar val(1, 2, 3, 4);
|
||||
ocl::oclMat d_src, d_dst;
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
Has_roi(k);
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
mat_roi.copyTo(dst_roi, mask_roi);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
src.setTo(val);
|
||||
|
||||
gmat = mat_roi;
|
||||
gmask = mask_roi;
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
gmat.copyTo(gdst, gmask);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gdst_whole.download (cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
CPU_ON;
|
||||
src.setTo(val);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
d_src.setTo(val);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_src.setTo(val);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_src.setTo(val);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
gmask = mask_roi;
|
||||
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
gmat.copyTo(gdst, gmask);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
///////////////////////////////////////////copyto/////////////////////////////////////////////////////////////
|
||||
|
||||
PARAM_TEST_CASE(SetToTestBase, MatType, bool)
|
||||
{
|
||||
int type;
|
||||
cv::Scalar val;
|
||||
|
||||
cv::Mat mat;
|
||||
cv::Mat mask;
|
||||
|
||||
// set up roi
|
||||
int roicols;
|
||||
int roirows;
|
||||
int srcx;
|
||||
int srcy;
|
||||
int maskx;
|
||||
int masky;
|
||||
|
||||
//src mat with roi
|
||||
cv::Mat mat_roi;
|
||||
cv::Mat mask_roi;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
cv::ocl::oclMat gmat_whole;
|
||||
|
||||
//ocl mat with roi
|
||||
cv::ocl::oclMat gmat;
|
||||
cv::ocl::oclMat gmask;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
|
||||
mat = randomMat(rng, size, type, 5, 16, false);
|
||||
mask = randomMat(rng, 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), rng.uniform(-10.0, 10.0), rng.uniform(-10.0, 10.0));
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//setBinpath(CLBINPATH);
|
||||
}
|
||||
|
||||
void Has_roi(int b)
|
||||
{
|
||||
//cv::RNG& rng = TS::ptr()->get_rng();
|
||||
if(b)
|
||||
{
|
||||
//randomize ROI
|
||||
roicols = mat.cols - 1; //start
|
||||
roirows = mat.rows - 1;
|
||||
srcx = 1;
|
||||
srcy = 1;
|
||||
maskx = 1;
|
||||
masky = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = mat.cols;
|
||||
roirows = mat.rows;
|
||||
srcx = 0;
|
||||
srcy = 0;
|
||||
maskx = 0;
|
||||
masky = 0;
|
||||
};
|
||||
|
||||
mat_roi = mat(Rect(srcx, srcy, roicols, roirows));
|
||||
mask_roi = mask(Rect(maskx, masky, roicols, roirows));
|
||||
|
||||
//gmat_whole = mat;
|
||||
//gmat = gmat_whole(Rect(srcx,srcy,roicols,roirows));
|
||||
|
||||
//gmask = mask_roi;
|
||||
}
|
||||
};
|
||||
|
||||
struct SetTo : SetToTestBase {};
|
||||
|
||||
TEST_P(SetTo, Without_mask)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
mat_roi.setTo(val);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gmat_whole = mat;
|
||||
gmat = gmat_whole(Rect(srcx, srcy, roicols, roirows));
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
gmat.setTo(val);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gmat_whole.download(cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gmat_whole = mat;
|
||||
gmat = gmat_whole(Rect(srcx, srcy, roicols, roirows));
|
||||
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
gmat.setTo(val);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_P(SetTo, With_mask)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
mat_roi.setTo(val, mask_roi);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gmat_whole = mat;
|
||||
gmat = gmat_whole(Rect(srcx, srcy, roicols, roirows));
|
||||
|
||||
gmask = mask_roi;
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
gmat.setTo(val, gmask);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gmat_whole.download(cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gmat_whole = mat;
|
||||
gmat = gmat_whole(Rect(srcx, srcy, roicols, roirows));
|
||||
|
||||
gmask = mask_roi;
|
||||
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
gmat.setTo(val, gmask);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
PARAM_TEST_CASE(DataTransfer, MatType, bool)
|
||||
{
|
||||
int type;
|
||||
cv::Mat mat;
|
||||
cv::ocl::oclMat gmat_whole;
|
||||
|
||||
virtual void SetUp()
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
mat = randomMat(rng, size, type, 5, 16, false);
|
||||
}
|
||||
};
|
||||
TEST_P(DataTransfer, perf)
|
||||
{
|
||||
double totaluploadtick = 0;
|
||||
double totaldownloadtick = 0;
|
||||
double totaltick = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
cv::Mat cpu_dst;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
t0 = (double)cvGetTickCount();
|
||||
gmat_whole.upload(mat);//upload
|
||||
t0 = (double)cvGetTickCount() - t0;
|
||||
|
||||
t1 = (double)cvGetTickCount();
|
||||
gmat_whole.download(cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
totaluploadtick = t0 + totaluploadtick;
|
||||
totaldownloadtick = t1 + totaldownloadtick;
|
||||
}
|
||||
totaltick = totaluploadtick + totaldownloadtick;
|
||||
cout << "average upload time is " << totaluploadtick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average download time is " << totaldownloadtick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average data transfer time is " << totaltick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
//**********test************
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatrixOperation, ConvertTo, Combine(
|
||||
Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4),
|
||||
Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatrixOperation, CopyTo, Combine(
|
||||
Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4),
|
||||
Values(false))); // Values(false) is the reserved parameter
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(MatrixOperation, SetTo, Combine(
|
||||
Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4),
|
||||
Values(false))); // Values(false) is the reserved parameter
|
||||
INSTANTIATE_TEST_CASE_P(MatrixOperation, DataTransfer, Combine(
|
||||
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
|
||||
Values(false))); // Values(false) is the reserved parameter
|
||||
#endif
|
||||
}
|
84
modules/ocl/perf/perf_norm.cpp
Normal file
84
modules/ocl/perf/perf_norm.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/*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-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.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// 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 the Intel Corporation or 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 "precomp.hpp"
|
||||
|
||||
///////////// norm////////////////////////
|
||||
TEST(norm)
|
||||
{
|
||||
Mat src, buf;
|
||||
ocl::oclMat d_src, d_buf;
|
||||
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; CV_8UC1; NORM_INF";
|
||||
|
||||
gen(src, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1));
|
||||
gen(buf, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1));
|
||||
|
||||
norm(src, NORM_INF);
|
||||
|
||||
CPU_ON;
|
||||
norm(src, NORM_INF);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
d_buf.upload(buf);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::norm(d_src, d_buf, NORM_INF);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::norm(d_src, d_buf, NORM_INF);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::norm(d_src, d_buf, NORM_INF);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
@ -15,7 +15,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// fangfang bai, fangfang@multicorewareinc.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -42,96 +42,46 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
PARAM_TEST_CASE(PyrDown, MatType, int)
|
||||
///////////// pyrDown //////////////////////
|
||||
TEST(pyrDown)
|
||||
{
|
||||
int type;
|
||||
int channels;
|
||||
//src mat
|
||||
cv::Mat mat1;
|
||||
cv::Mat dst;
|
||||
Mat src, dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
|
||||
cv::ocl::oclMat gmat1;
|
||||
cv::ocl::oclMat gdst;
|
||||
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
channels = GET_PARAM(1);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#define VARNAME(A) string(#A);
|
||||
|
||||
////////////////////////////////PyrDown/////////////////////////////////////////////////
|
||||
TEST_P(PyrDown, Mat)
|
||||
{
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
mat1 = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
|
||||
|
||||
cv::ocl::oclMat gdst;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
|
||||
for (int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat gmat1(mat1);
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::pyrDown(gmat1, gdst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
gdst.download(cpu_dst);
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if (j == 0)
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
continue;
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
pyrDown(src, dst);
|
||||
|
||||
CPU_ON;
|
||||
pyrDown(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src);
|
||||
ocl::oclMat d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::pyrDown(d_src, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::pyrDown(d_src, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::pyrDown(d_src, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
}
|
||||
|
||||
//********test****************
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrDown, Combine(
|
||||
Values(CV_8U, CV_32F), Values(1, 4)));
|
||||
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
143
modules/ocl/perf/perf_pyrlk.cpp
Normal file
143
modules/ocl/perf/perf_pyrlk.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*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-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.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// 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 the Intel Corporation or 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 "precomp.hpp"
|
||||
|
||||
///////////// PyrLKOpticalFlow ////////////////////////
|
||||
TEST(PyrLKOpticalFlow)
|
||||
{
|
||||
std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"};
|
||||
std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"};
|
||||
|
||||
for (size_t i = 0; i < sizeof(images1) / sizeof(std::string); i++)
|
||||
{
|
||||
Mat frame0 = imread(abspath(images1[i]), i == 0 ? IMREAD_COLOR : IMREAD_GRAYSCALE);
|
||||
|
||||
if (frame0.empty())
|
||||
{
|
||||
std::string errstr = "can't open " + images1[i];
|
||||
throw runtime_error(errstr);
|
||||
}
|
||||
|
||||
Mat frame1 = imread(abspath(images2[i]), i == 0 ? IMREAD_COLOR : IMREAD_GRAYSCALE);
|
||||
|
||||
if (frame1.empty())
|
||||
{
|
||||
std::string errstr = "can't open " + images2[i];
|
||||
throw runtime_error(errstr);
|
||||
}
|
||||
|
||||
Mat gray_frame;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
cvtColor(frame0, gray_frame, COLOR_BGR2GRAY);
|
||||
}
|
||||
|
||||
for (int points = Min_Size; points <= Max_Size; points *= Multiple)
|
||||
{
|
||||
if (i == 0)
|
||||
SUBTEST << frame0.cols << "x" << frame0.rows << "; color; " << points << " points";
|
||||
else
|
||||
SUBTEST << frame0.cols << "x" << frame0.rows << "; gray; " << points << " points";
|
||||
Mat nextPts_cpu;
|
||||
Mat status_cpu;
|
||||
|
||||
vector<Point2f> pts;
|
||||
goodFeaturesToTrack(i == 0 ? gray_frame : frame0, pts, points, 0.01, 0.0);
|
||||
|
||||
vector<Point2f> nextPts;
|
||||
vector<unsigned char> status;
|
||||
|
||||
vector<float> err;
|
||||
|
||||
calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, err);
|
||||
|
||||
CPU_ON;
|
||||
calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, err);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::PyrLKOpticalFlow d_pyrLK;
|
||||
|
||||
ocl::oclMat d_frame0(frame0);
|
||||
ocl::oclMat d_frame1(frame1);
|
||||
|
||||
ocl::oclMat d_pts;
|
||||
Mat pts_mat(1, (int)pts.size(), CV_32FC2, (void *)&pts[0]);
|
||||
d_pts.upload(pts_mat);
|
||||
|
||||
ocl::oclMat d_nextPts;
|
||||
ocl::oclMat d_status;
|
||||
ocl::oclMat d_err;
|
||||
|
||||
WARMUP_ON;
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_frame0.upload(frame0);
|
||||
d_frame1.upload(frame1);
|
||||
d_pts.upload(pts_mat);
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err);
|
||||
|
||||
if (!d_nextPts.empty())
|
||||
{
|
||||
d_nextPts.download(nextPts_cpu);
|
||||
}
|
||||
|
||||
if (!d_status.empty())
|
||||
{
|
||||
d_status.download(status_cpu);
|
||||
}
|
||||
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// fangfang bai fangfang@multicorewareinc.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -42,81 +42,46 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "precomp.hpp"
|
||||
#include <iomanip>
|
||||
#ifdef HAVE_OPENCL
|
||||
using namespace cv;
|
||||
using namespace cv::ocl;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
|
||||
|
||||
PARAM_TEST_CASE(PyrUp, MatType, int)
|
||||
///////////// pyrUp ////////////////////////
|
||||
TEST(pyrUp)
|
||||
{
|
||||
int type;
|
||||
int channels;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
Mat src, dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = 500; size <= 2000; size *= 2)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
channels = GET_PARAM(1);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(PyrUp, Performance)
|
||||
{
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
cv::Mat src = randomMat(size, CV_MAKETYPE(type, channels));
|
||||
cv::Mat dst_gold;
|
||||
cv::ocl::oclMat dst;
|
||||
|
||||
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
|
||||
for (int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
|
||||
cv::ocl::oclMat srcMat = cv::ocl::oclMat(src);//upload
|
||||
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::pyrUp(srcMat, dst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
|
||||
cv::Mat cpu_dst;
|
||||
dst.download(cpu_dst); //download
|
||||
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if (j == 0)
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
continue;
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
pyrUp(src, dst);
|
||||
|
||||
CPU_ON;
|
||||
pyrUp(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src);
|
||||
ocl::oclMat d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::pyrUp(d_src, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::pyrUp(d_src, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::pyrUp(d_src, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrUp, Combine(
|
||||
Values(CV_8U, CV_32F), Values(1, 4)));
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
}
|
@ -10,12 +10,12 @@
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, 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.
|
||||
//
|
||||
// @Authors
|
||||
// Jia Haipeng, jiahaipeng95@gmail.com
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -42,446 +42,109 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
PARAM_TEST_CASE(MergeTestBase, MatType, int)
|
||||
///////////// Merge////////////////////////
|
||||
TEST(Merge)
|
||||
{
|
||||
int type;
|
||||
int channels;
|
||||
Mat dst;
|
||||
ocl::oclMat d_dst;
|
||||
|
||||
//src mat
|
||||
cv::Mat mat1;
|
||||
cv::Mat mat2;
|
||||
cv::Mat mat3;
|
||||
cv::Mat mat4;
|
||||
int channels = 4;
|
||||
int all_type[] = {CV_8UC1, CV_32FC1};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
|
||||
|
||||
//dst mat
|
||||
cv::Mat dst;
|
||||
|
||||
// set up roi
|
||||
int roicols;
|
||||
int roirows;
|
||||
int src1x;
|
||||
int src1y;
|
||||
int src2x;
|
||||
int src2y;
|
||||
int src3x;
|
||||
int src3y;
|
||||
int src4x;
|
||||
int src4y;
|
||||
int dstx;
|
||||
int dsty;
|
||||
|
||||
//src mat with roi
|
||||
cv::Mat mat1_roi;
|
||||
cv::Mat mat2_roi;
|
||||
cv::Mat mat3_roi;
|
||||
cv::Mat mat4_roi;
|
||||
|
||||
//dst mat with roi
|
||||
cv::Mat dst_roi;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
cv::ocl::oclMat gdst_whole;
|
||||
|
||||
//ocl mat with roi
|
||||
cv::ocl::oclMat gmat1;
|
||||
cv::ocl::oclMat gmat2;
|
||||
cv::ocl::oclMat gmat3;
|
||||
cv::ocl::oclMat gmat4;
|
||||
cv::ocl::oclMat gdst;
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
channels = GET_PARAM(1);
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
Size size1 = Size(size, size);
|
||||
std::vector<Mat> src(channels);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
for (int i = 0; i < channels; ++i)
|
||||
{
|
||||
src[i] = Mat(size1, all_type[j], cv::Scalar::all(i));
|
||||
}
|
||||
|
||||
merge(src, dst);
|
||||
|
||||
CPU_ON;
|
||||
merge(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
std::vector<ocl::oclMat> d_src(channels);
|
||||
|
||||
for (int i = 0; i < channels; ++i)
|
||||
{
|
||||
d_src[i] = ocl::oclMat(size1, all_type[j], cv::Scalar::all(i));
|
||||
}
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::merge(d_src, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::merge(d_src, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
|
||||
for (int i = 0; i < channels; ++i)
|
||||
{
|
||||
d_src[i] = ocl::oclMat(size1, CV_8U, cv::Scalar::all(i));
|
||||
}
|
||||
|
||||
ocl::merge(d_src, d_dst);
|
||||
d_dst.download(dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
mat1 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
mat2 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
mat3 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
mat4 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//setBinpath(CLBINPATH);
|
||||
}
|
||||
void Has_roi(int b)
|
||||
{
|
||||
//cv::RNG& rng = TS::ptr()->get_rng();
|
||||
if(b)
|
||||
{
|
||||
//randomize ROI
|
||||
roicols = mat1.cols - 1; //start
|
||||
roirows = mat1.rows - 1;
|
||||
src1x = 1;
|
||||
src1y = 1;
|
||||
src2x = 1;
|
||||
src2y = 1;
|
||||
src3x = 1;
|
||||
src3y = 1;
|
||||
src4x = 1;
|
||||
src4y = 1;
|
||||
dstx = 1;
|
||||
dsty = 1;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = mat1.cols;
|
||||
roirows = mat1.rows;
|
||||
src1x = 0;
|
||||
src1y = 0;
|
||||
src2x = 0;
|
||||
src2y = 0;
|
||||
src3x = 0;
|
||||
src3y = 0;
|
||||
src4x = 0;
|
||||
src4y = 0;
|
||||
dstx = 0;
|
||||
dsty = 0;
|
||||
};
|
||||
|
||||
mat1_roi = mat1(Rect(src1x, src1y, roicols, roirows));
|
||||
mat2_roi = mat2(Rect(src2x, src2y, roicols, roirows));
|
||||
mat3_roi = mat3(Rect(src3x, src3y, roicols, roirows));
|
||||
mat4_roi = mat4(Rect(src4x, src4y, roicols, roirows));
|
||||
|
||||
|
||||
dst_roi = dst(Rect(dstx, dsty, roicols, roirows));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Merge : MergeTestBase {};
|
||||
|
||||
TEST_P(Merge, Accuracy)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
std::vector<cv::Mat> dev_src;
|
||||
dev_src.push_back(mat1_roi);
|
||||
dev_src.push_back(mat2_roi);
|
||||
dev_src.push_back(mat3_roi);
|
||||
dev_src.push_back(mat4_roi);
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
cv::merge(dev_src, dst_roi);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1 ]
|
||||
gmat1 = mat1_roi;
|
||||
gmat2 = mat2_roi;
|
||||
gmat3 = mat3_roi;
|
||||
gmat4 = mat4_roi;
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
std::vector<cv::ocl::oclMat> dev_gsrc;
|
||||
dev_gsrc.push_back(gmat1);
|
||||
dev_gsrc.push_back(gmat2);
|
||||
dev_gsrc.push_back(gmat3);
|
||||
dev_gsrc.push_back(gmat4);
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::merge(dev_gsrc, gdst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst;
|
||||
gdst_whole.download (cpu_dst);//download
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
|
||||
if(j == 0)
|
||||
continue;
|
||||
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
gmat1 = mat1_roi;
|
||||
gmat2 = mat2_roi;
|
||||
gmat3 = mat3_roi;
|
||||
gmat4 = mat4_roi;
|
||||
gdst_whole = dst;
|
||||
gdst = gdst_whole(Rect(dstx, dsty, roicols, roirows));
|
||||
std::vector<cv::ocl::oclMat> dev_gsrc;
|
||||
dev_gsrc.push_back(gmat1);
|
||||
dev_gsrc.push_back(gmat2);
|
||||
dev_gsrc.push_back(gmat3);
|
||||
dev_gsrc.push_back(gmat4);
|
||||
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
cv::ocl::merge(dev_gsrc, gdst);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
PARAM_TEST_CASE(SplitTestBase, MatType, int)
|
||||
///////////// Split////////////////////////
|
||||
TEST(Split)
|
||||
{
|
||||
int type;
|
||||
int channels;
|
||||
//int channels = 4;
|
||||
int all_type[] = {CV_8UC1, CV_32FC1};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
|
||||
|
||||
//src mat
|
||||
cv::Mat mat;
|
||||
|
||||
//dstmat
|
||||
cv::Mat dst1;
|
||||
cv::Mat dst2;
|
||||
cv::Mat dst3;
|
||||
cv::Mat dst4;
|
||||
|
||||
// set up roi
|
||||
int roicols;
|
||||
int roirows;
|
||||
int srcx;
|
||||
int srcy;
|
||||
int dst1x;
|
||||
int dst1y;
|
||||
int dst2x;
|
||||
int dst2y;
|
||||
int dst3x;
|
||||
int dst3y;
|
||||
int dst4x;
|
||||
int dst4y;
|
||||
|
||||
//src mat with roi
|
||||
cv::Mat mat_roi;
|
||||
|
||||
//dst mat with roi
|
||||
cv::Mat dst1_roi;
|
||||
cv::Mat dst2_roi;
|
||||
cv::Mat dst3_roi;
|
||||
cv::Mat dst4_roi;
|
||||
//std::vector<cv::ocl::Info> oclinfo;
|
||||
//ocl dst mat for testing
|
||||
cv::ocl::oclMat gdst1_whole;
|
||||
cv::ocl::oclMat gdst2_whole;
|
||||
cv::ocl::oclMat gdst3_whole;
|
||||
cv::ocl::oclMat gdst4_whole;
|
||||
|
||||
//ocl mat with roi
|
||||
cv::ocl::oclMat gmat;
|
||||
cv::ocl::oclMat gdst1;
|
||||
cv::ocl::oclMat gdst2;
|
||||
cv::ocl::oclMat gdst3;
|
||||
cv::ocl::oclMat gdst4;
|
||||
|
||||
virtual void SetUp()
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
{
|
||||
type = GET_PARAM(0);
|
||||
channels = GET_PARAM(1);
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j];
|
||||
Size size1 = Size(size, size);
|
||||
|
||||
cv::RNG &rng = TS::ptr()->get_rng();
|
||||
cv::Size size(MWIDTH, MHEIGHT);
|
||||
Mat src(size1, CV_MAKE_TYPE(all_type[j], 4), cv::Scalar(1, 2, 3, 4));
|
||||
|
||||
std::vector<cv::Mat> dst;
|
||||
|
||||
split(src, dst);
|
||||
|
||||
CPU_ON;
|
||||
split(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(size1, CV_MAKE_TYPE(all_type[j], 4), cv::Scalar(1, 2, 3, 4));
|
||||
std::vector<cv::ocl::oclMat> d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::split(d_src, d_dst);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::split(d_src, d_dst);
|
||||
;
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::split(d_src, d_dst);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
|
||||
mat = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false);
|
||||
dst1 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst2 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst3 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
dst4 = randomMat(rng, size, CV_MAKETYPE(type, 1), 5, 16, false);
|
||||
//int devnums = getDevice(oclinfo);
|
||||
//CV_Assert(devnums > 0);
|
||||
////if you want to use undefault device, set it here
|
||||
////setDevice(oclinfo[0]);
|
||||
//setBinpath(CLBINPATH);
|
||||
}
|
||||
|
||||
void Has_roi(int b)
|
||||
{
|
||||
//cv::RNG& rng = TS::ptr()->get_rng();
|
||||
if(b)
|
||||
{
|
||||
//randomize ROI
|
||||
roicols = mat.cols - 1; //start
|
||||
roirows = mat.rows - 1;
|
||||
srcx = 1;
|
||||
srcx = 1;
|
||||
dst1x = 1;
|
||||
dst1y = 1;
|
||||
dst2x = 1;
|
||||
dst2y = 1;
|
||||
dst3x = 1;
|
||||
dst3y = 1;
|
||||
dst4x = 1;
|
||||
dst4y = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
roicols = mat.cols;
|
||||
roirows = mat.rows;
|
||||
srcx = 0;
|
||||
srcy = 0;
|
||||
dst1x = 0;
|
||||
dst1y = 0;
|
||||
dst2x = 0;
|
||||
dst2y = 0;
|
||||
dst3x = 0;
|
||||
dst3y = 0;
|
||||
dst4x = 0;
|
||||
dst4y = 0;
|
||||
};
|
||||
|
||||
mat_roi = mat(Rect(srcx, srcy, roicols, roirows));
|
||||
|
||||
dst1_roi = dst1(Rect(dst1x, dst1y, roicols, roirows));
|
||||
dst2_roi = dst2(Rect(dst2x, dst2y, roicols, roirows));
|
||||
dst3_roi = dst3(Rect(dst3x, dst3y, roicols, roirows));
|
||||
dst4_roi = dst4(Rect(dst4x, dst4y, roicols, roirows));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Split : SplitTestBase {};
|
||||
|
||||
TEST_P(Split, Accuracy)
|
||||
{
|
||||
#ifndef PRINT_KERNEL_RUN_TIME
|
||||
double totalcputick = 0;
|
||||
double totalgputick = 0;
|
||||
double totalgputick_kernel = 0;
|
||||
double t0 = 0;
|
||||
double t1 = 0;
|
||||
double t2 = 0;
|
||||
for(int k = LOOPROISTART; k < LOOPROIEND; k++)
|
||||
{
|
||||
totalcputick = 0;
|
||||
totalgputick = 0;
|
||||
totalgputick_kernel = 0;
|
||||
for(int j = 0; j < LOOP_TIMES + 1; j ++)
|
||||
{
|
||||
Has_roi(k);
|
||||
cv::Mat dev_dst[4] = {dst1_roi, dst2_roi, dst3_roi, dst4_roi};
|
||||
cv::ocl::oclMat dev_gdst[4] = {gdst1, gdst2, gdst3, gdst4};
|
||||
t0 = (double)cvGetTickCount();//cpu start
|
||||
cv::split(mat_roi, dev_dst);
|
||||
t0 = (double)cvGetTickCount() - t0;//cpu end
|
||||
|
||||
t1 = (double)cvGetTickCount();//gpu start1
|
||||
gdst1_whole = dst1;
|
||||
gdst1 = gdst1_whole(Rect(dst1x, dst1y, roicols, roirows));
|
||||
|
||||
gdst2_whole = dst2;
|
||||
gdst2 = gdst2_whole(Rect(dst2x, dst2y, roicols, roirows));
|
||||
|
||||
gdst3_whole = dst3;
|
||||
gdst3 = gdst3_whole(Rect(dst3x, dst3y, roicols, roirows));
|
||||
|
||||
gdst4_whole = dst4;
|
||||
gdst4 = gdst4_whole(Rect(dst4x, dst4y, roicols, roirows));
|
||||
|
||||
gmat = mat_roi;
|
||||
t2 = (double)cvGetTickCount(); //kernel
|
||||
cv::ocl::split(gmat, dev_gdst);
|
||||
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||
cv::Mat cpu_dst1;
|
||||
cv::Mat cpu_dst2;
|
||||
cv::Mat cpu_dst3;
|
||||
cv::Mat cpu_dst4;
|
||||
gdst1_whole.download(cpu_dst1);
|
||||
gdst2_whole.download(cpu_dst2);
|
||||
gdst3_whole.download(cpu_dst3);
|
||||
gdst4_whole.download(cpu_dst4);
|
||||
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||
if(j == 0)
|
||||
continue;
|
||||
totalgputick = t1 + totalgputick;
|
||||
totalcputick = t0 + totalcputick;
|
||||
totalgputick_kernel = t2 + totalgputick_kernel;
|
||||
|
||||
}
|
||||
if(k == 0)
|
||||
{
|
||||
cout << "no roi\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "with roi\n";
|
||||
};
|
||||
cout << "average cpu runtime is " << totalcputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
|
||||
}
|
||||
#else
|
||||
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
|
||||
{
|
||||
Has_roi(j);
|
||||
//cv::Mat dev_dst[4] = {dst1_roi, dst2_roi, dst3_roi, dst4_roi};
|
||||
cv::ocl::oclMat dev_gdst[4] = {gdst1, gdst2, gdst3, gdst4};
|
||||
gdst1_whole = dst1;
|
||||
gdst1 = gdst1_whole(Rect(dst1x, dst1y, roicols, roirows));
|
||||
|
||||
gdst2_whole = dst2;
|
||||
gdst2 = gdst2_whole(Rect(dst2x, dst2y, roicols, roirows));
|
||||
|
||||
gdst3_whole = dst3;
|
||||
gdst3 = gdst3_whole(Rect(dst3x, dst3y, roicols, roirows));
|
||||
|
||||
gdst4_whole = dst4;
|
||||
gdst4 = gdst4_whole(Rect(dst4x, dst4y, roicols, roirows));
|
||||
gmat = mat_roi;
|
||||
if(j == 0)
|
||||
{
|
||||
cout << "no roi:";
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "\nwith roi:";
|
||||
};
|
||||
cv::ocl::split(gmat, dev_gdst);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************test*****************
|
||||
INSTANTIATE_TEST_CASE_P(SplitMerge, Merge, Combine(
|
||||
Values(CV_8UC4, CV_32FC4), Values(1, 4)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SplitMerge, Split , Combine(
|
||||
Values(CV_8U, CV_32S, CV_32F), Values(1, 4)));
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
@ -7,12 +7,13 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// 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,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
@ -21,12 +22,12 @@
|
||||
//
|
||||
// * 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 materials provided with the distribution.
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -41,4 +42,321 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
// This program test most of the functions in ocl module and generate data metrix of x-factor in .csv files
|
||||
// All images needed in this test are in samples/gpu folder.
|
||||
// For haar template, haarcascade_frontalface_alt.xml shouold be in working directory
|
||||
void TestSystem::run()
|
||||
{
|
||||
if (is_list_mode_)
|
||||
{
|
||||
for (vector<Runnable *>::iterator it = tests_.begin(); it != tests_.end(); ++it)
|
||||
{
|
||||
cout << (*it)->name() << endl;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Run test initializers
|
||||
for (vector<Runnable *>::iterator it = inits_.begin(); it != inits_.end(); ++it)
|
||||
{
|
||||
if ((*it)->name().find(test_filter_, 0) != string::npos)
|
||||
{
|
||||
(*it)->run();
|
||||
}
|
||||
}
|
||||
|
||||
printHeading();
|
||||
writeHeading();
|
||||
|
||||
// Run tests
|
||||
for (vector<Runnable *>::iterator it = tests_.begin(); it != tests_.end(); ++it)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((*it)->name().find(test_filter_, 0) != string::npos)
|
||||
{
|
||||
cout << endl << (*it)->name() << ":\n";
|
||||
|
||||
setCurrentTest((*it)->name());
|
||||
//fprintf(record_,"%s\n",(*it)->name().c_str());
|
||||
|
||||
(*it)->run();
|
||||
finishCurrentSubtest();
|
||||
}
|
||||
}
|
||||
catch (const Exception &)
|
||||
{
|
||||
// Message is printed via callback
|
||||
resetCurrentSubtest();
|
||||
}
|
||||
catch (const runtime_error &e)
|
||||
{
|
||||
printError(e.what());
|
||||
resetCurrentSubtest();
|
||||
}
|
||||
}
|
||||
|
||||
printSummary();
|
||||
writeSummary();
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::finishCurrentSubtest()
|
||||
{
|
||||
if (cur_subtest_is_empty_)
|
||||
// There is no need to print subtest statistics
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double cpu_time = cpu_elapsed_ / getTickFrequency() * 1000.0;
|
||||
double gpu_time = gpu_elapsed_ / getTickFrequency() * 1000.0;
|
||||
double gpu_full_time = gpu_full_elapsed_ / getTickFrequency() * 1000.0;
|
||||
|
||||
double speedup = static_cast<double>(cpu_elapsed_) / std::max(1.0, gpu_elapsed_);
|
||||
speedup_total_ += speedup;
|
||||
|
||||
double fullspeedup = static_cast<double>(cpu_elapsed_) / std::max(1.0, gpu_full_elapsed_);
|
||||
speedup_full_total_ += fullspeedup;
|
||||
|
||||
if (speedup > top_)
|
||||
{
|
||||
speedup_faster_count_++;
|
||||
}
|
||||
else if (speedup < bottom_)
|
||||
{
|
||||
speedup_slower_count_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
speedup_equal_count_++;
|
||||
}
|
||||
|
||||
if (fullspeedup > top_)
|
||||
{
|
||||
speedup_full_faster_count_++;
|
||||
}
|
||||
else if (fullspeedup < bottom_)
|
||||
{
|
||||
speedup_full_slower_count_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
speedup_full_equal_count_++;
|
||||
}
|
||||
|
||||
// compute min, max and
|
||||
std::sort(gpu_times_.begin(), gpu_times_.end());
|
||||
double gpu_min = gpu_times_.front() / getTickFrequency() * 1000.0;
|
||||
double gpu_max = gpu_times_.back() / getTickFrequency() * 1000.0;
|
||||
double deviation = 0;
|
||||
|
||||
if (gpu_times_.size() > 1)
|
||||
{
|
||||
double sum = 0;
|
||||
|
||||
for (size_t i = 0; i < gpu_times_.size(); i++)
|
||||
{
|
||||
int64 diff = gpu_times_[i] - static_cast<int64>(gpu_elapsed_);
|
||||
double diff_time = diff * 1000 / getTickFrequency();
|
||||
sum += diff_time * diff_time;
|
||||
}
|
||||
|
||||
deviation = std::sqrt(sum / gpu_times_.size());
|
||||
}
|
||||
|
||||
printMetrics(cpu_time, gpu_time, gpu_full_time, speedup, fullspeedup);
|
||||
writeMetrics(cpu_time, gpu_time, gpu_full_time, speedup, fullspeedup, gpu_min, gpu_max, deviation);
|
||||
|
||||
num_subtests_called_++;
|
||||
resetCurrentSubtest();
|
||||
}
|
||||
|
||||
|
||||
double TestSystem::meanTime(const vector<int64> &samples)
|
||||
{
|
||||
double sum = accumulate(samples.begin(), samples.end(), 0.);
|
||||
return sum / samples.size();
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::printHeading()
|
||||
{
|
||||
cout << endl;
|
||||
cout << setiosflags(ios_base::left);
|
||||
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
|
||||
<< setw(14) << "SPEEDUP" << setw(14) << "GPUTOTAL, ms" << setw(14) << "TOTALSPEEDUP"
|
||||
<< "DESCRIPTION\n";
|
||||
|
||||
cout << resetiosflags(ios_base::left);
|
||||
}
|
||||
|
||||
void TestSystem::writeHeading()
|
||||
{
|
||||
if (!record_)
|
||||
{
|
||||
recordname_ += "_OCL.csv";
|
||||
record_ = fopen(recordname_.c_str(), "w");
|
||||
}
|
||||
|
||||
fprintf(record_, "NAME,DESCRIPTION,CPU (ms),GPU (ms),SPEEDUP,GPUTOTAL (ms),TOTALSPEEDUP,GPU Min (ms),GPU Max (ms), Standard deviation (ms)\n");
|
||||
|
||||
fflush(record_);
|
||||
}
|
||||
|
||||
void TestSystem::printSummary()
|
||||
{
|
||||
cout << setiosflags(ios_base::fixed);
|
||||
cout << "\naverage GPU speedup: x"
|
||||
<< setprecision(3) << speedup_total_ / std::max(1, num_subtests_called_)
|
||||
<< endl;
|
||||
cout << "\nGPU exceeded: "
|
||||
<< setprecision(3) << speedup_faster_count_
|
||||
<< "\nGPU passed: "
|
||||
<< setprecision(3) << speedup_equal_count_
|
||||
<< "\nGPU failed: "
|
||||
<< setprecision(3) << speedup_slower_count_
|
||||
<< endl;
|
||||
cout << "\nGPU exceeded rate: "
|
||||
<< setprecision(3) << (float)speedup_faster_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< "\nGPU passed rate: "
|
||||
<< setprecision(3) << (float)speedup_equal_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< "\nGPU failed rate: "
|
||||
<< setprecision(3) << (float)speedup_slower_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< endl;
|
||||
cout << "\naverage GPUTOTAL speedup: x"
|
||||
<< setprecision(3) << speedup_full_total_ / std::max(1, num_subtests_called_)
|
||||
<< endl;
|
||||
cout << "\nGPUTOTAL exceeded: "
|
||||
<< setprecision(3) << speedup_full_faster_count_
|
||||
<< "\nGPUTOTAL passed: "
|
||||
<< setprecision(3) << speedup_full_equal_count_
|
||||
<< "\nGPUTOTAL failed: "
|
||||
<< setprecision(3) << speedup_full_slower_count_
|
||||
<< endl;
|
||||
cout << "\nGPUTOTAL exceeded rate: "
|
||||
<< setprecision(3) << (float)speedup_full_faster_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< "\nGPUTOTAL passed rate: "
|
||||
<< setprecision(3) << (float)speedup_full_equal_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< "\nGPUTOTAL failed rate: "
|
||||
<< setprecision(3) << (float)speedup_full_slower_count_ / std::max(1, num_subtests_called_) * 100
|
||||
<< "%"
|
||||
<< endl;
|
||||
cout << resetiosflags(ios_base::fixed);
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::printMetrics(double cpu_time, double gpu_time, double gpu_full_time, double speedup, double fullspeedup)
|
||||
{
|
||||
cout << TAB << setiosflags(ios_base::left);
|
||||
stringstream stream;
|
||||
|
||||
stream << cpu_time;
|
||||
cout << setw(10) << stream.str();
|
||||
|
||||
stream.str("");
|
||||
stream << gpu_time;
|
||||
cout << setw(10) << stream.str();
|
||||
|
||||
stream.str("");
|
||||
stream << "x" << setprecision(3) << speedup;
|
||||
cout << setw(14) << stream.str();
|
||||
|
||||
stream.str("");
|
||||
stream << gpu_full_time;
|
||||
cout << setw(14) << stream.str();
|
||||
|
||||
stream.str("");
|
||||
stream << "x" << setprecision(3) << fullspeedup;
|
||||
cout << setw(14) << stream.str();
|
||||
|
||||
cout << cur_subtest_description_.str();
|
||||
cout << resetiosflags(ios_base::left) << endl;
|
||||
}
|
||||
|
||||
void TestSystem::writeMetrics(double cpu_time, double gpu_time, double gpu_full_time, double speedup, double fullspeedup, double gpu_min, double gpu_max, double std_dev)
|
||||
{
|
||||
if (!record_)
|
||||
{
|
||||
recordname_ += ".csv";
|
||||
record_ = fopen(recordname_.c_str(), "w");
|
||||
}
|
||||
|
||||
fprintf(record_, "%s,%s,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f\n", itname_changed_ ? itname_.c_str() : "",
|
||||
cur_subtest_description_.str().c_str(),
|
||||
cpu_time, gpu_time, speedup, gpu_full_time, fullspeedup,
|
||||
gpu_min, gpu_max, std_dev);
|
||||
|
||||
if (itname_changed_)
|
||||
{
|
||||
itname_changed_ = false;
|
||||
}
|
||||
|
||||
fflush(record_);
|
||||
}
|
||||
|
||||
void TestSystem::writeSummary()
|
||||
{
|
||||
if (!record_)
|
||||
{
|
||||
recordname_ += ".csv";
|
||||
record_ = fopen(recordname_.c_str(), "w");
|
||||
}
|
||||
|
||||
fprintf(record_, "\nAverage GPU speedup: %.3f\n"
|
||||
"exceeded: %d (%.3f%%)\n"
|
||||
"passed: %d (%.3f%%)\n"
|
||||
"failed: %d (%.3f%%)\n"
|
||||
"\nAverage GPUTOTAL speedup: %.3f\n"
|
||||
"exceeded: %d (%.3f%%)\n"
|
||||
"passed: %d (%.3f%%)\n"
|
||||
"failed: %d (%.3f%%)\n",
|
||||
speedup_total_ / std::max(1, num_subtests_called_),
|
||||
speedup_faster_count_, (float)speedup_faster_count_ / std::max(1, num_subtests_called_) * 100,
|
||||
speedup_equal_count_, (float)speedup_equal_count_ / std::max(1, num_subtests_called_) * 100,
|
||||
speedup_slower_count_, (float)speedup_slower_count_ / std::max(1, num_subtests_called_) * 100,
|
||||
speedup_full_total_ / std::max(1, num_subtests_called_),
|
||||
speedup_full_faster_count_, (float)speedup_full_faster_count_ / std::max(1, num_subtests_called_) * 100,
|
||||
speedup_full_equal_count_, (float)speedup_full_equal_count_ / std::max(1, num_subtests_called_) * 100,
|
||||
speedup_full_slower_count_, (float)speedup_full_slower_count_ / std::max(1, num_subtests_called_) * 100
|
||||
);
|
||||
fflush(record_);
|
||||
}
|
||||
|
||||
void TestSystem::printError(const std::string &msg)
|
||||
{
|
||||
if(msg != "CL_INVALID_BUFFER_SIZE")
|
||||
{
|
||||
cout << TAB << "[error: " << msg << "] " << cur_subtest_description_.str() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void gen(Mat &mat, int rows, int cols, int type, Scalar low, Scalar high)
|
||||
{
|
||||
mat.create(rows, cols, type);
|
||||
RNG rng(0);
|
||||
rng.fill(mat, RNG::UNIFORM, low, high);
|
||||
}
|
||||
|
||||
|
||||
string abspath(const string &relpath)
|
||||
{
|
||||
return TestSystem::instance().workingDir() + relpath;
|
||||
}
|
||||
|
||||
|
||||
int CV_CDECL cvErrorCallback(int /*status*/, const char * /*func_name*/,
|
||||
const char *err_msg, const char * /*file_name*/,
|
||||
int /*line*/, void * /*userdata*/)
|
||||
{
|
||||
TestSystem::instance().printError(err_msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,12 +7,13 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// 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,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
@ -21,12 +22,12 @@
|
||||
//
|
||||
// * 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 materials provided with the distribution.
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// * 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
|
||||
// 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 the Intel Corporation or contributors be liable for any direct,
|
||||
@ -39,43 +40,352 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include "cvconfig.h"
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
//#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/video/video.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/ocl/ocl.hpp"
|
||||
//#include "opencv2/nonfree/nonfree.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
#include "interpolation.hpp"
|
||||
//#include "add_test_info.h"
|
||||
//#define PERF_TEST_OCL 1
|
||||
#define Min_Size 1000
|
||||
#define Max_Size 4000
|
||||
#define Multiple 2
|
||||
#define TAB " "
|
||||
|
||||
#endif
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
void gen(Mat &mat, int rows, int cols, int type, Scalar low, Scalar high);
|
||||
string abspath(const string &relpath);
|
||||
int CV_CDECL cvErrorCallback(int, const char *, const char *, const char *, int, void *);
|
||||
typedef struct
|
||||
{
|
||||
short x;
|
||||
short y;
|
||||
} COOR;
|
||||
COOR do_meanShift(int x0, int y0, uchar *sptr, uchar *dptr, int sstep,
|
||||
cv::Size size, int sp, int sr, int maxIter, float eps, int *tab);
|
||||
void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi,
|
||||
int sp, int sr, cv::TermCriteria crit);
|
||||
|
||||
class Runnable
|
||||
{
|
||||
public:
|
||||
explicit Runnable(const std::string &runname): name_(runname) {}
|
||||
virtual ~Runnable() {}
|
||||
|
||||
const std::string &name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
virtual void run() = 0;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
class TestSystem
|
||||
{
|
||||
public:
|
||||
static TestSystem &instance()
|
||||
{
|
||||
static TestSystem me;
|
||||
return me;
|
||||
}
|
||||
|
||||
void setWorkingDir(const std::string &val)
|
||||
{
|
||||
working_dir_ = val;
|
||||
}
|
||||
const std::string &workingDir() const
|
||||
{
|
||||
return working_dir_;
|
||||
}
|
||||
|
||||
void setTestFilter(const std::string &val)
|
||||
{
|
||||
test_filter_ = val;
|
||||
}
|
||||
const std::string &testFilter() const
|
||||
{
|
||||
return test_filter_;
|
||||
}
|
||||
|
||||
void setNumIters(int num_iters)
|
||||
{
|
||||
num_iters_ = num_iters;
|
||||
}
|
||||
void setGPUWarmupIters(int num_iters)
|
||||
{
|
||||
gpu_warmup_iters_ = num_iters;
|
||||
}
|
||||
void setCPUIters(int num_iters)
|
||||
{
|
||||
cpu_num_iters_ = num_iters;
|
||||
}
|
||||
|
||||
void setTopThreshold(double top)
|
||||
{
|
||||
top_ = top;
|
||||
}
|
||||
void setBottomThreshold(double bottom)
|
||||
{
|
||||
bottom_ = bottom;
|
||||
}
|
||||
|
||||
void addInit(Runnable *init)
|
||||
{
|
||||
inits_.push_back(init);
|
||||
}
|
||||
void addTest(Runnable *test)
|
||||
{
|
||||
tests_.push_back(test);
|
||||
}
|
||||
void run();
|
||||
|
||||
// It's public because OpenCV callback uses it
|
||||
void printError(const std::string &msg);
|
||||
|
||||
std::stringstream &startNewSubtest()
|
||||
{
|
||||
finishCurrentSubtest();
|
||||
return cur_subtest_description_;
|
||||
}
|
||||
|
||||
bool stop() const
|
||||
{
|
||||
return cur_iter_idx_ >= num_iters_;
|
||||
}
|
||||
|
||||
bool cpu_stop() const
|
||||
{
|
||||
return cur_iter_idx_ >= cpu_num_iters_;
|
||||
}
|
||||
|
||||
bool warmupStop()
|
||||
{
|
||||
return cur_warmup_idx_++ >= gpu_warmup_iters_;
|
||||
}
|
||||
|
||||
void warmupComplete()
|
||||
{
|
||||
cur_warmup_idx_ = 0;
|
||||
}
|
||||
|
||||
void cpuOn()
|
||||
{
|
||||
cpu_started_ = cv::getTickCount();
|
||||
}
|
||||
void cpuOff()
|
||||
{
|
||||
int64 delta = cv::getTickCount() - cpu_started_;
|
||||
cpu_times_.push_back(delta);
|
||||
++cur_iter_idx_;
|
||||
}
|
||||
void cpuComplete()
|
||||
{
|
||||
cpu_elapsed_ += meanTime(cpu_times_);
|
||||
cur_subtest_is_empty_ = false;
|
||||
cur_iter_idx_ = 0;
|
||||
}
|
||||
|
||||
void gpuOn()
|
||||
{
|
||||
gpu_started_ = cv::getTickCount();
|
||||
}
|
||||
void gpuOff()
|
||||
{
|
||||
int64 delta = cv::getTickCount() - gpu_started_;
|
||||
gpu_times_.push_back(delta);
|
||||
++cur_iter_idx_;
|
||||
}
|
||||
void gpuComplete()
|
||||
{
|
||||
gpu_elapsed_ += meanTime(gpu_times_);
|
||||
cur_subtest_is_empty_ = false;
|
||||
cur_iter_idx_ = 0;
|
||||
}
|
||||
|
||||
void gpufullOn()
|
||||
{
|
||||
gpu_full_started_ = cv::getTickCount();
|
||||
}
|
||||
void gpufullOff()
|
||||
{
|
||||
int64 delta = cv::getTickCount() - gpu_full_started_;
|
||||
gpu_full_times_.push_back(delta);
|
||||
++cur_iter_idx_;
|
||||
}
|
||||
void gpufullComplete()
|
||||
{
|
||||
gpu_full_elapsed_ += meanTime(gpu_full_times_);
|
||||
cur_subtest_is_empty_ = false;
|
||||
cur_iter_idx_ = 0;
|
||||
}
|
||||
|
||||
bool isListMode() const
|
||||
{
|
||||
return is_list_mode_;
|
||||
}
|
||||
void setListMode(bool value)
|
||||
{
|
||||
is_list_mode_ = value;
|
||||
}
|
||||
|
||||
void setRecordName(const std::string &name)
|
||||
{
|
||||
recordname_ = name;
|
||||
}
|
||||
|
||||
void setCurrentTest(const std::string &name)
|
||||
{
|
||||
itname_ = name;
|
||||
itname_changed_ = true;
|
||||
}
|
||||
|
||||
private:
|
||||
TestSystem():
|
||||
cur_subtest_is_empty_(true), cpu_elapsed_(0),
|
||||
gpu_elapsed_(0), gpu_full_elapsed_(0), speedup_total_(0.0),
|
||||
num_subtests_called_(0),
|
||||
speedup_faster_count_(0), speedup_slower_count_(0), speedup_equal_count_(0),
|
||||
speedup_full_faster_count_(0), speedup_full_slower_count_(0), speedup_full_equal_count_(0), is_list_mode_(false),
|
||||
num_iters_(10), cpu_num_iters_(2),
|
||||
gpu_warmup_iters_(1), cur_iter_idx_(0), cur_warmup_idx_(0),
|
||||
record_(0), recordname_("performance"), itname_changed_(true)
|
||||
{
|
||||
cpu_times_.reserve(num_iters_);
|
||||
gpu_times_.reserve(num_iters_);
|
||||
gpu_full_times_.reserve(num_iters_);
|
||||
}
|
||||
|
||||
void finishCurrentSubtest();
|
||||
void resetCurrentSubtest()
|
||||
{
|
||||
cpu_elapsed_ = 0;
|
||||
gpu_elapsed_ = 0;
|
||||
gpu_full_elapsed_ = 0;
|
||||
cur_subtest_description_.str("");
|
||||
cur_subtest_is_empty_ = true;
|
||||
cur_iter_idx_ = 0;
|
||||
cpu_times_.clear();
|
||||
gpu_times_.clear();
|
||||
gpu_full_times_.clear();
|
||||
}
|
||||
|
||||
double meanTime(const std::vector<int64> &samples);
|
||||
|
||||
void printHeading();
|
||||
void printSummary();
|
||||
void printMetrics(double cpu_time, double gpu_time = 0.0f, double gpu_full_time = 0.0f, double speedup = 0.0f, double fullspeedup = 0.0f);
|
||||
|
||||
void writeHeading();
|
||||
void writeSummary();
|
||||
void writeMetrics(double cpu_time, double gpu_time = 0.0f, double gpu_full_time = 0.0f,
|
||||
double speedup = 0.0f, double fullspeedup = 0.0f,
|
||||
double gpu_min = 0.0f, double gpu_max = 0.0f, double std_dev = 0.0f);
|
||||
|
||||
std::string working_dir_;
|
||||
std::string test_filter_;
|
||||
|
||||
std::vector<Runnable *> inits_;
|
||||
std::vector<Runnable *> tests_;
|
||||
|
||||
std::stringstream cur_subtest_description_;
|
||||
bool cur_subtest_is_empty_;
|
||||
|
||||
int64 cpu_started_;
|
||||
int64 gpu_started_;
|
||||
int64 gpu_full_started_;
|
||||
double cpu_elapsed_;
|
||||
double gpu_elapsed_;
|
||||
double gpu_full_elapsed_;
|
||||
|
||||
double speedup_total_;
|
||||
double speedup_full_total_;
|
||||
int num_subtests_called_;
|
||||
|
||||
int speedup_faster_count_;
|
||||
int speedup_slower_count_;
|
||||
int speedup_equal_count_;
|
||||
|
||||
int speedup_full_faster_count_;
|
||||
int speedup_full_slower_count_;
|
||||
int speedup_full_equal_count_;
|
||||
|
||||
bool is_list_mode_;
|
||||
|
||||
double top_;
|
||||
double bottom_;
|
||||
|
||||
int num_iters_;
|
||||
int cpu_num_iters_; //there's no need to set cpu running same times with gpu
|
||||
int gpu_warmup_iters_; //gpu warm up times, default is 1
|
||||
int cur_iter_idx_;
|
||||
int cur_warmup_idx_; //current gpu warm up times
|
||||
std::vector<int64> cpu_times_;
|
||||
std::vector<int64> gpu_times_;
|
||||
std::vector<int64> gpu_full_times_;
|
||||
|
||||
FILE *record_;
|
||||
std::string recordname_;
|
||||
std::string itname_;
|
||||
bool itname_changed_;
|
||||
};
|
||||
|
||||
|
||||
#define GLOBAL_INIT(name) \
|
||||
struct name##_init: Runnable { \
|
||||
name##_init(): Runnable(#name) { \
|
||||
TestSystem::instance().addInit(this); \
|
||||
} \
|
||||
void run(); \
|
||||
} name##_init_instance; \
|
||||
void name##_init::run()
|
||||
|
||||
|
||||
#define TEST(name) \
|
||||
struct name##_test: Runnable { \
|
||||
name##_test(): Runnable(#name) { \
|
||||
TestSystem::instance().addTest(this); \
|
||||
} \
|
||||
void run(); \
|
||||
} name##_test_instance; \
|
||||
void name##_test::run()
|
||||
|
||||
#define SUBTEST TestSystem::instance().startNewSubtest()
|
||||
|
||||
#define CPU_ON \
|
||||
while (!TestSystem::instance().cpu_stop()) { \
|
||||
TestSystem::instance().cpuOn()
|
||||
#define CPU_OFF \
|
||||
TestSystem::instance().cpuOff(); \
|
||||
} TestSystem::instance().cpuComplete()
|
||||
|
||||
#define GPU_ON \
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpuOn()
|
||||
#define GPU_OFF \
|
||||
TestSystem::instance().gpuOff(); \
|
||||
} TestSystem::instance().gpuComplete()
|
||||
|
||||
#define GPU_FULL_ON \
|
||||
while (!TestSystem::instance().stop()) { \
|
||||
TestSystem::instance().gpufullOn()
|
||||
#define GPU_FULL_OFF \
|
||||
TestSystem::instance().gpufullOff(); \
|
||||
} TestSystem::instance().gpufullComplete()
|
||||
|
||||
#define WARMUP_ON \
|
||||
while (!TestSystem::instance().warmupStop()) {
|
||||
#define WARMUP_OFF \
|
||||
} TestSystem::instance().warmupComplete()
|
||||
|
@ -1,265 +0,0 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation 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 the Intel Corporation or 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 "precomp.hpp"
|
||||
#define VARNAME(A) #A
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
using namespace cvtest;
|
||||
|
||||
|
||||
//std::string generateVarList(int first,...)
|
||||
//{
|
||||
// vector<std::string> varname;
|
||||
//
|
||||
// va_list argp;
|
||||
// string s;
|
||||
// stringstream ss;
|
||||
// va_start(argp,first);
|
||||
// int i=first;
|
||||
// while(i!=-1)
|
||||
// {
|
||||
// ss<<i<<",";
|
||||
// i=va_arg(argp,int);
|
||||
// };
|
||||
// s=ss.str();
|
||||
// va_end(argp);
|
||||
// return s;
|
||||
//};
|
||||
|
||||
//std::string generateVarList(int& p1,int& p2)
|
||||
//{
|
||||
// stringstream ss;
|
||||
// ss<<VARNAME(p1)<<":"<<src1x<<","<<VARNAME(p2)<<":"<<src1y;
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
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();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
|
||||
{
|
||||
return TargetArchs::builtWith(feature) && info.supports(feature);
|
||||
}
|
||||
|
||||
const vector<DeviceInfo>& devices()
|
||||
{
|
||||
static vector<DeviceInfo> devs;
|
||||
static bool first = true;
|
||||
|
||||
if (first)
|
||||
{
|
||||
int deviceCount = getCudaEnabledDeviceCount();
|
||||
|
||||
devs.reserve(deviceCount);
|
||||
|
||||
for (int i = 0; i < deviceCount; ++i)
|
||||
{
|
||||
DeviceInfo info(i);
|
||||
if (info.isCompatible())
|
||||
devs.push_back(info);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
return devs;
|
||||
}
|
||||
|
||||
vector<DeviceInfo> devices(FeatureSet feature)
|
||||
{
|
||||
const vector<DeviceInfo>& d = devices();
|
||||
|
||||
vector<DeviceInfo> devs_filtered;
|
||||
|
||||
if (TargetArchs::builtWith(feature))
|
||||
{
|
||||
devs_filtered.reserve(d.size());
|
||||
|
||||
for (size_t i = 0, size = d.size(); i < size; ++i)
|
||||
{
|
||||
const DeviceInfo& info = d[i];
|
||||
|
||||
if (info.supports(feature))
|
||||
devs_filtered.push_back(info);
|
||||
}
|
||||
}
|
||||
|
||||
return devs_filtered;
|
||||
}
|
||||
*/
|
||||
|
||||
vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
|
||||
{
|
||||
vector<MatType> v;
|
||||
|
||||
v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1));
|
||||
|
||||
for (int depth = depth_start; depth <= depth_end; ++depth)
|
||||
{
|
||||
for (int cn = cn_start; cn <= cn_end; ++cn)
|
||||
{
|
||||
v.push_back(CV_MAKETYPE(depth, cn));
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
const vector<MatType> &all_types()
|
||||
{
|
||||
static vector<MatType> v = types(CV_8U, CV_64F, 1, 4);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Mat readImage(const string &fileName, int flags)
|
||||
{
|
||||
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
|
||||
}
|
||||
|
||||
Mat readImageType(const string &fname, int type)
|
||||
{
|
||||
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
|
||||
if (CV_MAT_CN(type) == 4)
|
||||
{
|
||||
Mat temp;
|
||||
cvtColor(src, temp, cv::COLOR_BGR2BGRA);
|
||||
swap(src, temp);
|
||||
}
|
||||
src.convertTo(src, CV_MAT_DEPTH(type));
|
||||
return src;
|
||||
}
|
||||
|
||||
double checkNorm(const Mat &m)
|
||||
{
|
||||
return norm(m, NORM_INF);
|
||||
}
|
||||
|
||||
double checkNorm(const Mat &m1, const Mat &m2)
|
||||
{
|
||||
return norm(m1, m2, NORM_INF);
|
||||
}
|
||||
|
||||
double checkSimilarity(const Mat &m1, const Mat &m2)
|
||||
{
|
||||
Mat diff;
|
||||
matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);
|
||||
return std::abs(diff.at<float>(0, 0) - 1.f);
|
||||
}
|
||||
|
||||
/*
|
||||
void cv::ocl::PrintTo(const DeviceInfo& info, ostream* os)
|
||||
{
|
||||
(*os) << info.name();
|
||||
}
|
||||
*/
|
||||
|
||||
void PrintTo(const Inverse &inverse, std::ostream *os)
|
||||
{
|
||||
if (inverse)
|
||||
(*os) << "inverse";
|
||||
else
|
||||
(*os) << "direct";
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, 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 materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation 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 the Intel Corporation or 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*/
|
||||
|
||||
#ifndef __OPENCV_TEST_UTILITY_HPP__
|
||||
#define __OPENCV_TEST_UTILITY_HPP__
|
||||
//#define PRINT_KERNEL_RUN_TIME
|
||||
#ifdef PRINT_KERNEL_RUN_TIME
|
||||
#define LOOP_TIMES 1
|
||||
#else
|
||||
#define LOOP_TIMES 1
|
||||
#endif
|
||||
#define MWIDTH 1920
|
||||
#define MHEIGHT 1080
|
||||
#define CLBINPATH ".\\"
|
||||
#define LOOPROISTART 0
|
||||
#define LOOPROIEND 1
|
||||
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);
|
||||
|
||||
void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
|
||||
|
||||
//! return true if device supports specified feature and gpu module was built with support the feature.
|
||||
//bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
|
||||
|
||||
//! return all devices compatible with current gpu module build.
|
||||
//const std::vector<cv::ocl::DeviceInfo>& devices();
|
||||
//! return all devices compatible with current gpu module build which support specified feature.
|
||||
//std::vector<cv::ocl::DeviceInfo> devices(cv::gpu::FeatureSet feature);
|
||||
|
||||
//! read image from testdata folder.
|
||||
cv::Mat readImage(const std::string &fileName, int flags = cv::IMREAD_COLOR);
|
||||
cv::Mat readImageType(const std::string &fname, int type);
|
||||
|
||||
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);
|
||||
|
||||
#define EXPECT_MAT_NORM(mat, eps) \
|
||||
{ \
|
||||
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
|
||||
}
|
||||
|
||||
/*#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
|
||||
{ \
|
||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
|
||||
}*/
|
||||
|
||||
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
|
||||
{ \
|
||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps)<<s; \
|
||||
}
|
||||
|
||||
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
|
||||
{ \
|
||||
ASSERT_EQ(mat1.type(), mat2.type()); \
|
||||
ASSERT_EQ(mat1.size(), mat2.size()); \
|
||||
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;
|
||||
|
||||
//! return vector with types from specified range.
|
||||
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end);
|
||||
|
||||
//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
|
||||
const std::vector<MatType> &all_types();
|
||||
|
||||
class Inverse
|
||||
{
|
||||
public:
|
||||
inline Inverse(bool val = false) : val_(val) {}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
private:
|
||||
bool val_;
|
||||
};
|
||||
|
||||
void PrintTo(const Inverse &useRoi, std::ostream *os);
|
||||
|
||||
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
|
||||
|
||||
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
|
||||
|
||||
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
|
||||
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
|
||||
|
||||
CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
|
||||
|
||||
CV_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
|
||||
|
||||
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
|
||||
|
||||
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
|
||||
|
||||
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
|
||||
|
||||
CV_ENUM(Border, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
|
||||
|
||||
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
|
||||
|
||||
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
|
||||
|
||||
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
|
||||
|
||||
void run_perf_test();
|
||||
|
||||
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< 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))
|
||||
|
||||
#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))
|
||||
|
||||
#endif // __OPENCV_TEST_UTILITY_HPP__
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user