mirror of https://github.com/opencv/opencv.git
parent
eccfc90b77
commit
457b8d7bff
12 changed files with 1570 additions and 1362 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,176 +1,185 @@ |
||||
#include "perf_precomp.hpp" |
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType, merge, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))) |
||||
#ifdef HAVE_CUDA |
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Merge
|
||||
|
||||
GPU_PERF_TEST(Merge, cv::gpu::DeviceInfo, cv::Size, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type = std::tr1::get<2>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type = GET_PARAM(2); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
const int num_channels = 4; |
||||
|
||||
vector<GpuMat> src(num_channels); |
||||
std::vector<cv::gpu::GpuMat> src(num_channels); |
||||
for (int i = 0; i < num_channels; ++i) |
||||
src[i] = GpuMat(size, type, cv::Scalar::all(i));
|
||||
src[i] = cv::gpu::GpuMat(size, type, cv::Scalar::all(i));
|
||||
|
||||
GpuMat dst(size, CV_MAKETYPE(type, num_channels)); |
||||
cv::gpu::GpuMat dst; |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
merge(src, dst); |
||||
cv::gpu::merge(src, dst); |
||||
} |
||||
} |
||||
|
||||
Mat dst_host(dst); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, Merge, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); |
||||
|
||||
SANITY_CHECK(dst_host); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Split
|
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType, split, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))) |
||||
GPU_PERF_TEST(Split, cv::gpu::DeviceInfo, cv::Size, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type = std::tr1::get<2>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type = GET_PARAM(2); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
const int num_channels = 4; |
||||
|
||||
GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4)); |
||||
cv::gpu::GpuMat src(size, CV_MAKETYPE(type, num_channels), cv::Scalar(1, 2, 3, 4)); |
||||
|
||||
vector<GpuMat> dst(num_channels); |
||||
std::vector<cv::gpu::GpuMat> dst(num_channels); |
||||
for (int i = 0; i < num_channels; ++i) |
||||
dst[i] = GpuMat(size, type);
|
||||
dst[i] = cv::gpu::GpuMat(size, type);
|
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
split(src, dst); |
||||
cv::gpu::split(src, dst); |
||||
} |
||||
} |
||||
|
||||
vector<Mat> dst_host(dst.size()); |
||||
for (size_t i = 0; i < dst.size(); ++i) |
||||
dst[i].download(dst_host[i]); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, Split, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); |
||||
|
||||
SANITY_CHECK(dst_host); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetTo
|
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType, setTo, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1))) |
||||
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type = std::tr1::get<2>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type = GET_PARAM(2); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
GpuMat src(size, type); |
||||
Scalar val(1, 2, 3, 4); |
||||
cv::gpu::GpuMat src(size, type); |
||||
cv::Scalar val(1, 2, 3, 4); |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
src.setTo(val); |
||||
} |
||||
} |
||||
|
||||
Mat src_host(src); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); |
||||
|
||||
SANITY_CHECK(src_host); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////
|
||||
// SetToMasked
|
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType, setToMasked, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1))) |
||||
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type = std::tr1::get<2>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type = GET_PARAM(2); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
Mat src_host(size, type); |
||||
cv::Mat src_host(size, type); |
||||
cv::Mat mask_host(size, CV_8UC1); |
||||
|
||||
declare.in(src_host, WARMUP_RNG); |
||||
fill(mask_host, 0, 2); |
||||
|
||||
GpuMat src(src_host); |
||||
Scalar val(1, 2, 3, 4); |
||||
|
||||
Mat mask_host(size, CV_8UC1); |
||||
randu(mask_host, 0.0, 2.0); |
||||
GpuMat mask(mask_host); |
||||
cv::gpu::GpuMat src(src_host); |
||||
cv::Scalar val(1, 2, 3, 4); |
||||
cv::gpu::GpuMat mask(mask_host); |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
src.setTo(val, mask); |
||||
} |
||||
} |
||||
|
||||
src.download(src_host); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); |
||||
|
||||
SANITY_CHECK(src_host); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CopyToMasked
|
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType, copyToMasked, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1))) |
||||
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type = std::tr1::get<2>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type = GET_PARAM(2); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
Mat src_host(size, type); |
||||
cv::Mat src_host(size, type); |
||||
cv::Mat mask_host(size, CV_8UC1); |
||||
|
||||
declare.in(src_host, WARMUP_RNG); |
||||
fill(mask_host, 0, 2); |
||||
|
||||
GpuMat src(src_host); |
||||
GpuMat dst(size, type); |
||||
|
||||
Mat mask_host(size, CV_8UC1); |
||||
randu(mask_host, 0.0, 2.0); |
||||
GpuMat mask(mask_host); |
||||
cv::gpu::GpuMat src(src_host); |
||||
cv::gpu::GpuMat mask(mask_host); |
||||
cv::gpu::GpuMat dst; |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
src.copyTo(dst, mask); |
||||
} |
||||
} |
||||
|
||||
Mat dst_host(dst); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4))); |
||||
|
||||
SANITY_CHECK(dst_host); |
||||
} |
||||
//////////////////////////////////////////////////////////////////////
|
||||
// ConvertTo
|
||||
|
||||
PERF_TEST_P(DevInfo_Size_MatType_MatType, convertTo, testing::Combine(testing::ValuesIn(devices()),
|
||||
testing::Values(GPU_TYPICAL_MAT_SIZES),
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1), |
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))) |
||||
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, perf::MatType, perf::MatType) |
||||
{ |
||||
DeviceInfo devInfo = std::tr1::get<0>(GetParam()); |
||||
Size size = std::tr1::get<1>(GetParam()); |
||||
int type1 = std::tr1::get<2>(GetParam()); |
||||
int type2 = std::tr1::get<3>(GetParam()); |
||||
cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
||||
cv::Size size = GET_PARAM(1); |
||||
int type1 = GET_PARAM(2); |
||||
int type2 = GET_PARAM(3); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
Mat src_host(size, type1); |
||||
cv::Mat src_host(size, type1); |
||||
|
||||
declare.in(src_host, WARMUP_RNG); |
||||
|
||||
GpuMat src(src_host); |
||||
GpuMat dst(size, type2); |
||||
|
||||
double a = 0.5; |
||||
double b = 1.0; |
||||
cv::gpu::GpuMat src(src_host); |
||||
cv::gpu::GpuMat dst; |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
src.convertTo(dst, type2, a, b); |
||||
src.convertTo(dst, type2, 0.5, 1.0); |
||||
} |
||||
} |
||||
|
||||
Mat dst_host(dst); |
||||
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine( |
||||
ALL_DEVICES,
|
||||
GPU_TYPICAL_MAT_SIZES,
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),
|
||||
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1))); |
||||
|
||||
SANITY_CHECK(dst_host); |
||||
} |
||||
#endif |
||||
|
@ -1,21 +1,27 @@ |
||||
#include "perf_precomp.hpp" |
||||
|
||||
PERF_TEST_P(DevInfo, HOGDescriptor, testing::ValuesIn(devices())) |
||||
#ifdef HAVE_CUDA |
||||
|
||||
GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo) |
||||
{ |
||||
DeviceInfo devInfo = GetParam(); |
||||
cv::gpu::DeviceInfo devInfo = GetParam(); |
||||
|
||||
setDevice(devInfo.deviceID()); |
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
Mat img_host = readImage("gpu/hog/road.png", CV_LOAD_IMAGE_GRAYSCALE); |
||||
cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE); |
||||
|
||||
GpuMat img(img_host); |
||||
vector<Rect> found_locations; |
||||
cv::gpu::GpuMat img(img_host); |
||||
std::vector<cv::Rect> found_locations; |
||||
|
||||
gpu::HOGDescriptor hog; |
||||
hog.setSVMDetector(gpu::HOGDescriptor::getDefaultPeopleDetector()); |
||||
cv::gpu::HOGDescriptor hog; |
||||
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector()); |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
hog.detectMultiScale(img, found_locations); |
||||
} |
||||
} |
||||
|
||||
INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES); |
||||
|
||||
#endif |
||||
|
@ -0,0 +1,81 @@ |
||||
#include "perf_precomp.hpp" |
||||
|
||||
#ifdef HAVE_CUDA |
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// BroxOpticalFlow
|
||||
|
||||
GPU_PERF_TEST_1(BroxOpticalFlow, cv::gpu::DeviceInfo) |
||||
{ |
||||
cv::gpu::DeviceInfo devInfo = GetParam(); |
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); |
||||
cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); |
||||
|
||||
ASSERT_FALSE(frame0_host.empty()); |
||||
ASSERT_FALSE(frame1_host.empty()); |
||||
|
||||
frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); |
||||
frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); |
||||
|
||||
cv::gpu::GpuMat frame0(frame0_host); |
||||
cv::gpu::GpuMat frame1(frame1_host); |
||||
cv::gpu::GpuMat u;
|
||||
cv::gpu::GpuMat v; |
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); |
||||
|
||||
declare.time(10); |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
d_flow(frame0, frame1, u, v); |
||||
} |
||||
} |
||||
|
||||
INSTANTIATE_TEST_CASE_P(Video, BroxOpticalFlow, ALL_DEVICES); |
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// InterpolateFrames
|
||||
|
||||
GPU_PERF_TEST_1(InterpolateFrames, cv::gpu::DeviceInfo) |
||||
{ |
||||
cv::gpu::DeviceInfo devInfo = GetParam(); |
||||
|
||||
cv::gpu::setDevice(devInfo.deviceID()); |
||||
|
||||
cv::Mat frame0_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE); |
||||
cv::Mat frame1_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE); |
||||
|
||||
ASSERT_FALSE(frame0_host.empty()); |
||||
ASSERT_FALSE(frame1_host.empty()); |
||||
|
||||
frame0_host.convertTo(frame0_host, CV_32FC1, 1.0 / 255.0); |
||||
frame1_host.convertTo(frame1_host, CV_32FC1, 1.0 / 255.0); |
||||
|
||||
cv::gpu::GpuMat frame0(frame0_host); |
||||
cv::gpu::GpuMat frame1(frame1_host); |
||||
cv::gpu::GpuMat fu, fv;
|
||||
cv::gpu::GpuMat bu, bv; |
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/); |
||||
|
||||
d_flow(frame0, frame1, fu, fv); |
||||
d_flow(frame1, frame0, bu, bv); |
||||
|
||||
cv::gpu::GpuMat newFrame; |
||||
cv::gpu::GpuMat buf; |
||||
|
||||
TEST_CYCLE(100) |
||||
{ |
||||
cv::gpu::interpolateFrames(frame0, frame1, fu, fv, bu, bv, 0.5f, newFrame, buf); |
||||
} |
||||
} |
||||
|
||||
INSTANTIATE_TEST_CASE_P(Video, InterpolateFrames, ALL_DEVICES); |
||||
|
||||
#endif |
Loading…
Reference in new issue