Commit 5e0e1fac authored by Roman Donchenko's avatar Roman Donchenko

Merge commit 'b51a1a7d' (PR #895 from 2.4)

Conflicts:
	modules/ocl/CMakeLists.txt
	modules/ocl/perf/perf_color.cpp
	modules/ocl/perf/perf_match_template.cpp
	modules/ocl/perf/precomp.cpp
	modules/ocl/perf/precomp.hpp
parents 61567adc b51a1a7d
...@@ -3,5 +3,5 @@ if(NOT HAVE_OPENCL) ...@@ -3,5 +3,5 @@ if(NOT HAVE_OPENCL)
endif() endif()
set(the_description "OpenCL-accelerated Computer Vision") set(the_description "OpenCL-accelerated Computer Vision")
ocv_define_module(ocl opencv_core opencv_imgproc opencv_objdetect opencv_video opencv_features2d) ocv_define_module(ocl opencv_core opencv_imgproc opencv_features2d opencv_objdetect opencv_video opencv_calib3d)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -68,7 +69,7 @@ void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &we ...@@ -68,7 +69,7 @@ void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &we
} }
} }
} }
TEST(blend) PERFTEST(blend)
{ {
Mat src1, src2, weights1, weights2, dst; Mat src1, src2, weights1, weights2, dst;
ocl::oclMat d_src1, d_src2, d_weights1, d_weights2, d_dst; ocl::oclMat d_src1, d_src2, d_weights1, d_weights2, d_dst;
...@@ -102,9 +103,12 @@ TEST(blend) ...@@ -102,9 +103,12 @@ TEST(blend)
ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst); ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst);
WARMUP_OFF; WARMUP_OFF;
cv::Mat ocl_mat;
d_dst.download(ocl_mat);
TestSystem::instance().setAccurate(ExpectedMatNear(dst, ocl_mat, 1.f));
GPU_ON; GPU_ON;
ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst); ocl::blendLinear(d_src1, d_src2, d_weights1, d_weights2, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
//////////////////// BruteForceMatch ///////////////// //////////////////// BruteForceMatch /////////////////
TEST(BruteForceMatcher) PERFTEST(BruteForceMatcher)
{ {
Mat trainIdx_cpu; Mat trainIdx_cpu;
Mat distance_cpu; Mat distance_cpu;
...@@ -66,6 +67,7 @@ TEST(BruteForceMatcher) ...@@ -66,6 +67,7 @@ TEST(BruteForceMatcher)
gen(train, size, desc_len, CV_32F, 0, 1); gen(train, size, desc_len, CV_32F, 0, 1);
// Output // Output
vector< vector<DMatch> > matches(2); vector< vector<DMatch> > matches(2);
vector< vector<DMatch> > d_matches(2);
// Init GPU matcher // Init GPU matcher
ocl::BruteForceMatcher_OCL_base d_matcher(ocl::BruteForceMatcher_OCL_base::L2Dist); ocl::BruteForceMatcher_OCL_base d_matcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
...@@ -86,9 +88,11 @@ TEST(BruteForceMatcher) ...@@ -86,9 +88,11 @@ TEST(BruteForceMatcher)
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
WARMUP_OFF; WARMUP_OFF;
d_matcher.match(d_query, d_train, d_matches[0]);
TestSystem::instance().setAccurate(AssertEQ<size_t>(d_matches[0].size(), matches[0].size()));
GPU_ON; GPU_ON;
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance); d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -111,15 +115,16 @@ TEST(BruteForceMatcher) ...@@ -111,15 +115,16 @@ TEST(BruteForceMatcher)
GPU_ON; GPU_ON;
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2); d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, 2);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
d_query.upload(query); d_query.upload(query);
d_train.upload(train); d_train.upload(train);
d_matcher.knnMatch(d_query, d_train, matches, 2); d_matcher.knnMatch(d_query, d_train, d_matches, 2);
GPU_FULL_OFF; GPU_FULL_OFF;
TestSystem::instance().setAccurate(AssertEQ<size_t>(d_matches[0].size(), matches[0].size()));
SUBTEST << size << "; radiusMatch"; SUBTEST << size << "; radiusMatch";
float max_distance = 2.0f; float max_distance = 2.0f;
...@@ -138,13 +143,14 @@ TEST(BruteForceMatcher) ...@@ -138,13 +143,14 @@ TEST(BruteForceMatcher)
GPU_ON; GPU_ON;
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance); d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, max_distance);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
d_query.upload(query); d_query.upload(query);
d_train.upload(train); d_train.upload(train);
d_matcher.radiusMatch(d_query, d_train, matches, max_distance); d_matcher.radiusMatch(d_query, d_train, d_matches, max_distance);
GPU_FULL_OFF; GPU_FULL_OFF;
TestSystem::instance().setAccurate(AssertEQ<size_t>(d_matches[0].size(), matches[0].size()));
} }
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// Canny //////////////////////// ///////////// Canny ////////////////////////
TEST(Canny) PERFTEST(Canny)
{ {
Mat img = imread(abspath("aloeL.jpg"), IMREAD_GRAYSCALE); Mat img = imread(abspath("aloeL.jpg"), IMREAD_GRAYSCALE);
...@@ -70,9 +71,10 @@ TEST(Canny) ...@@ -70,9 +71,10 @@ TEST(Canny)
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0); ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExceptedMatSimilar(edges, d_edges, 2e-2));
GPU_ON; GPU_ON;
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0); ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// cvtColor//////////////////////// ///////////// cvtColor////////////////////////
TEST(cvtColor) PERFTEST(cvtColor)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -72,9 +73,12 @@ TEST(cvtColor) ...@@ -72,9 +73,12 @@ TEST(cvtColor)
ocl::cvtColor(d_src, d_dst, COLOR_RGBA2GRAY, 4); ocl::cvtColor(d_src, d_dst, COLOR_RGBA2GRAY, 4);
WARMUP_OFF; WARMUP_OFF;
cv::Mat ocl_mat;
d_dst.download(ocl_mat);
TestSystem::instance().setAccurate(ExceptedMatSimilar(dst, ocl_mat, 1e-5));
GPU_ON; GPU_ON;
ocl::cvtColor(d_src, d_dst, COLOR_RGBA2GRAY, 4); ocl::cvtColor(d_src, d_dst, COLOR_RGBA2GRAY, 4);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -88,4 +92,4 @@ TEST(cvtColor) ...@@ -88,4 +92,4 @@ TEST(cvtColor)
} }
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// columnSum//////////////////////// ///////////// columnSum////////////////////////
TEST(columnSum) PERFTEST(columnSum)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -58,12 +59,13 @@ TEST(columnSum) ...@@ -58,12 +59,13 @@ TEST(columnSum)
CPU_ON; CPU_ON;
dst.create(src.size(), src.type()); dst.create(src.size(), src.type());
for (int j = 0; j < src.cols; j++)
dst.at<float>(0, j) = src.at<float>(0, j);
for (int i = 1; i < src.rows; ++i) for (int i = 1; i < src.rows; ++i)
{ {for (int j = 0; j < src.cols; ++j)
for (int j = 0; j < src.cols; ++j)
{ {
dst.at<float>(i, j) = src.at<float>(i, j) += src.at<float>(i - 1, j); dst.at<float>(i, j) = dst.at<float>(i - 1 , j) + src.at<float>(i , j);
} }
} }
...@@ -74,9 +76,12 @@ TEST(columnSum) ...@@ -74,9 +76,12 @@ TEST(columnSum)
ocl::columnSum(d_src, d_dst); ocl::columnSum(d_src, d_dst);
WARMUP_OFF; WARMUP_OFF;
cv::Mat ocl_mat;
d_dst.download(ocl_mat);
TestSystem::instance().setAccurate(ExpectedMatNear(dst, ocl_mat, 5e-1));
GPU_ON; GPU_ON;
ocl::columnSum(d_src, d_dst); ocl::columnSum(d_src, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,13 +46,13 @@ ...@@ -45,13 +46,13 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// dft //////////////////////// ///////////// dft ////////////////////////
TEST(dft) PERFTEST(dft)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
int all_type[] = {CV_32FC1, CV_32FC2}; int all_type[] = {CV_32FC2};
std::string type_name[] = {"CV_32FC1", "CV_32FC2"}; std::string type_name[] = {"CV_32FC2"};
for (int size = Min_Size; size <= Max_Size; size *= Multiple) for (int size = Min_Size; size <= Max_Size; size *= Multiple)
{ {
...@@ -73,9 +74,10 @@ TEST(dft) ...@@ -73,9 +74,10 @@ TEST(dft)
ocl::dft(d_src, d_dst, Size(size, size)); ocl::dft(d_src, d_dst, Size(size, size));
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), src.size().area() * 1e-4));
GPU_ON; GPU_ON;
ocl::dft(d_src, d_dst, Size(size, size)); ocl::dft(d_src, d_dst, Size(size, size));
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// Blur//////////////////////// ///////////// Blur////////////////////////
TEST(Blur) PERFTEST(Blur)
{ {
Mat src1, dst; Mat src1, dst;
ocl::oclMat d_src1, d_dst; ocl::oclMat d_src1, d_dst;
...@@ -77,9 +78,10 @@ TEST(Blur) ...@@ -77,9 +78,10 @@ TEST(Blur)
ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype); ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1.0));
GPU_ON; GPU_ON;
ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype); ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -92,7 +94,7 @@ TEST(Blur) ...@@ -92,7 +94,7 @@ TEST(Blur)
} }
} }
///////////// Laplacian//////////////////////// ///////////// Laplacian////////////////////////
TEST(Laplacian) PERFTEST(Laplacian)
{ {
Mat src1, dst; Mat src1, dst;
ocl::oclMat d_src1, d_dst; ocl::oclMat d_src1, d_dst;
...@@ -123,9 +125,10 @@ TEST(Laplacian) ...@@ -123,9 +125,10 @@ TEST(Laplacian)
ocl::Laplacian(d_src1, d_dst, -1, ksize, 1); ocl::Laplacian(d_src1, d_dst, -1, ksize, 1);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1e-5));
GPU_ON; GPU_ON;
ocl::Laplacian(d_src1, d_dst, -1, ksize, 1); ocl::Laplacian(d_src1, d_dst, -1, ksize, 1);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -139,7 +142,7 @@ TEST(Laplacian) ...@@ -139,7 +142,7 @@ TEST(Laplacian)
} }
///////////// Erode //////////////////// ///////////// Erode ////////////////////
TEST(Erode) PERFTEST(Erode)
{ {
Mat src, dst, ker; Mat src, dst, ker;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -168,9 +171,10 @@ TEST(Erode) ...@@ -168,9 +171,10 @@ TEST(Erode)
ocl::erode(d_src, d_dst, ker); ocl::erode(d_src, d_dst, ker);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1e-5));
GPU_ON; GPU_ON;
ocl::erode(d_src, d_dst, ker); ocl::erode(d_src, d_dst, ker);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -184,7 +188,7 @@ TEST(Erode) ...@@ -184,7 +188,7 @@ TEST(Erode)
} }
///////////// Sobel //////////////////////// ///////////// Sobel ////////////////////////
TEST(Sobel) PERFTEST(Sobel)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -214,9 +218,10 @@ TEST(Sobel) ...@@ -214,9 +218,10 @@ TEST(Sobel)
ocl::Sobel(d_src, d_dst, -1, dx, dy); ocl::Sobel(d_src, d_dst, -1, dx, dy);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1));
GPU_ON; GPU_ON;
ocl::Sobel(d_src, d_dst, -1, dx, dy); ocl::Sobel(d_src, d_dst, -1, dx, dy);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -229,7 +234,7 @@ TEST(Sobel) ...@@ -229,7 +234,7 @@ TEST(Sobel)
} }
} }
///////////// Scharr //////////////////////// ///////////// Scharr ////////////////////////
TEST(Scharr) PERFTEST(Scharr)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -259,9 +264,10 @@ TEST(Scharr) ...@@ -259,9 +264,10 @@ TEST(Scharr)
ocl::Scharr(d_src, d_dst, -1, dx, dy); ocl::Scharr(d_src, d_dst, -1, dx, dy);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1));
GPU_ON; GPU_ON;
ocl::Scharr(d_src, d_dst, -1, dx, dy); ocl::Scharr(d_src, d_dst, -1, dx, dy);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -275,7 +281,7 @@ TEST(Scharr) ...@@ -275,7 +281,7 @@ TEST(Scharr)
} }
///////////// GaussianBlur //////////////////////// ///////////// GaussianBlur ////////////////////////
TEST(GaussianBlur) PERFTEST(GaussianBlur)
{ {
Mat src, dst; Mat src, dst;
int all_type[] = {CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4}; int all_type[] = {CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4};
...@@ -288,6 +294,8 @@ TEST(GaussianBlur) ...@@ -288,6 +294,8 @@ TEST(GaussianBlur)
SUBTEST << size << 'x' << size << "; " << type_name[j] ; SUBTEST << size << 'x' << size << "; " << type_name[j] ;
gen(src, size, size, all_type[j], 0, 256); gen(src, size, size, all_type[j], 0, 256);
dst = src;
dst.setTo(0);
GaussianBlur(src, dst, Size(9, 9), 0); GaussianBlur(src, dst, Size(9, 9), 0);
...@@ -303,9 +311,11 @@ TEST(GaussianBlur) ...@@ -303,9 +311,11 @@ TEST(GaussianBlur)
ocl::GaussianBlur(d_src, d_dst, Size(9, 9), 0); ocl::GaussianBlur(d_src, d_dst, Size(9, 9), 0);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1.0));
GPU_ON; GPU_ON;
ocl::GaussianBlur(d_src, d_dst, Size(9, 9), 0); ocl::GaussianBlur(d_src, d_dst, Size(9, 9), 0);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -319,7 +329,7 @@ TEST(GaussianBlur) ...@@ -319,7 +329,7 @@ TEST(GaussianBlur)
} }
///////////// filter2D//////////////////////// ///////////// filter2D////////////////////////
TEST(filter2D) PERFTEST(filter2D)
{ {
Mat src; Mat src;
...@@ -339,7 +349,8 @@ TEST(filter2D) ...@@ -339,7 +349,8 @@ TEST(filter2D)
Mat kernel; Mat kernel;
gen(kernel, ksize, ksize, CV_32FC1, 0.0, 1.0); gen(kernel, ksize, ksize, CV_32FC1, 0.0, 1.0);
Mat dst; Mat dst(src);
dst.setTo(0);
cv::filter2D(src, dst, -1, kernel); cv::filter2D(src, dst, -1, kernel);
CPU_ON; CPU_ON;
...@@ -347,15 +358,18 @@ TEST(filter2D) ...@@ -347,15 +358,18 @@ TEST(filter2D)
CPU_OFF; CPU_OFF;
ocl::oclMat d_src(src); ocl::oclMat d_src(src);
ocl::oclMat d_dst; ocl::oclMat d_dst(d_src);
d_dst.setTo(0);
WARMUP_ON; WARMUP_ON;
ocl::filter2D(d_src, d_dst, -1, kernel); ocl::filter2D(d_src, d_dst, -1, kernel);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, 1e-5));
GPU_ON; GPU_ON;
ocl::filter2D(d_src, d_dst, -1, kernel); ocl::filter2D(d_src, d_dst, -1, kernel);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// gemm //////////////////////// ///////////// gemm ////////////////////////
TEST(gemm) PERFTEST(gemm)
{ {
Mat src1, src2, src3, dst; Mat src1, src2, src3, dst;
ocl::oclMat d_src1, d_src2, d_src3, d_dst; ocl::oclMat d_src1, d_src2, d_src3, d_dst;
...@@ -71,10 +72,10 @@ TEST(gemm) ...@@ -71,10 +72,10 @@ TEST(gemm)
WARMUP_ON; WARMUP_ON;
ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst); ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(d_dst), dst, src1.cols * src1.rows * 1e-4));
GPU_ON; GPU_ON;
ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst); ocl::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -84,7 +85,7 @@ public: ...@@ -84,7 +85,7 @@ public:
} }
} }
TEST(Haar) PERFTEST(Haar)
{ {
Mat img = imread(abspath("basketball1.png"), IMREAD_GRAYSCALE); Mat img = imread(abspath("basketball1.png"), IMREAD_GRAYSCALE);
...@@ -108,6 +109,8 @@ TEST(Haar) ...@@ -108,6 +109,8 @@ TEST(Haar)
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
CPU_OFF; CPU_OFF;
vector<Rect> oclfaces;
ocl::CascadeClassifier_GPU faceCascade; ocl::CascadeClassifier_GPU faceCascade;
if (!faceCascade.load(abspath("haarcascade_frontalface_alt.xml"))) if (!faceCascade.load(abspath("haarcascade_frontalface_alt.xml")))
...@@ -117,24 +120,24 @@ TEST(Haar) ...@@ -117,24 +120,24 @@ TEST(Haar)
ocl::oclMat d_img(img); ocl::oclMat d_img(img);
faces.clear();
WARMUP_ON; WARMUP_ON;
faceCascade.detectMultiScale(d_img, faces, faceCascade.detectMultiScale(d_img, oclfaces,
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
WARMUP_OFF; WARMUP_OFF;
//Testing whether the expected is equal to the actual.
TestSystem::instance().setAccurate(ExpectedEQ<vector<Rect>::size_type, vector<Rect>::size_type>(faces.size(), oclfaces.size()));
faces.clear(); faces.clear();
GPU_ON; GPU_ON;
faceCascade.detectMultiScale(d_img, faces, faceCascade.detectMultiScale(d_img, oclfaces,
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
d_img.upload(img); d_img.upload(img);
faceCascade.detectMultiScale(d_img, faces, faceCascade.detectMultiScale(d_img, oclfaces,
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30)); 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
GPU_FULL_OFF; GPU_FULL_OFF;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,13 @@ ...@@ -45,7 +46,13 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// HOG//////////////////////// ///////////// HOG////////////////////////
TEST(HOG) bool match_rect(cv::Rect r1, cv::Rect r2, int threshold)
{
return ((abs(r1.x - r2.x) < threshold) && (abs(r1.y - r2.y) < threshold) &&
(abs(r1.width - r2.width) < threshold) && (abs(r1.height - r2.height) < threshold));
}
PERFTEST(HOG)
{ {
Mat src = imread(abspath("road.png"), cv::IMREAD_GRAYSCALE); Mat src = imread(abspath("road.png"), cv::IMREAD_GRAYSCALE);
...@@ -58,6 +65,7 @@ TEST(HOG) ...@@ -58,6 +65,7 @@ TEST(HOG)
cv::HOGDescriptor hog; cv::HOGDescriptor hog;
hog.setSVMDetector(hog.getDefaultPeopleDetector()); hog.setSVMDetector(hog.getDefaultPeopleDetector());
std::vector<cv::Rect> found_locations; std::vector<cv::Rect> found_locations;
std::vector<cv::Rect> d_found_locations;
SUBTEST << 768 << 'x' << 576 << "; road.png"; SUBTEST << 768 << 'x' << 576 << "; road.png";
...@@ -73,12 +81,78 @@ TEST(HOG) ...@@ -73,12 +81,78 @@ TEST(HOG)
d_src.upload(src); d_src.upload(src);
WARMUP_ON; WARMUP_ON;
ocl_hog.detectMultiScale(d_src, found_locations); ocl_hog.detectMultiScale(d_src, d_found_locations);
WARMUP_OFF; WARMUP_OFF;
// Ground-truth rectangular people window
cv::Rect win1_64x128(231, 190, 72, 144);
cv::Rect win2_64x128(621, 156, 97, 194);
cv::Rect win1_48x96(238, 198, 63, 126);
cv::Rect win2_48x96(619, 161, 92, 185);
cv::Rect win3_48x96(488, 136, 56, 112);
// Compare whether ground-truth windows are detected and compare the number of windows detected.
std::vector<int> d_comp(4);
std::vector<int> comp(4);
for(int i = 0; i < (int)d_comp.size(); i++)
{
d_comp[i] = 0;
comp[i] = 0;
}
int threshold = 10;
int val = 32;
d_comp[0] = (int)d_found_locations.size();
comp[0] = (int)found_locations.size();
cv::Size winSize = hog.winSize;
if (winSize == cv::Size(48, 96))
{
for(int i = 0; i < (int)d_found_locations.size(); i++)
{
if (match_rect(d_found_locations[i], win1_48x96, threshold))
d_comp[1] = val;
if (match_rect(d_found_locations[i], win2_48x96, threshold))
d_comp[2] = val;
if (match_rect(d_found_locations[i], win3_48x96, threshold))
d_comp[3] = val;
}
for(int i = 0; i < (int)found_locations.size(); i++)
{
if (match_rect(found_locations[i], win1_48x96, threshold))
comp[1] = val;
if (match_rect(found_locations[i], win2_48x96, threshold))
comp[2] = val;
if (match_rect(found_locations[i], win3_48x96, threshold))
comp[3] = val;
}
}
else if (winSize == cv::Size(64, 128))
{
for(int i = 0; i < (int)d_found_locations.size(); i++)
{
if (match_rect(d_found_locations[i], win1_64x128, threshold))
d_comp[1] = val;
if (match_rect(d_found_locations[i], win2_64x128, threshold))
d_comp[2] = val;
}
for(int i = 0; i < (int)found_locations.size(); i++)
{
if (match_rect(found_locations[i], win1_64x128, threshold))
comp[1] = val;
if (match_rect(found_locations[i], win2_64x128, threshold))
comp[2] = val;
}
}
cv::Mat ocl_mat;
ocl_mat = cv::Mat(d_comp);
ocl_mat.convertTo(ocl_mat, cv::Mat(comp).type());
TestSystem::instance().setAccurate(ExpectedMatNear(ocl_mat, cv::Mat(comp), 3));
GPU_ON; GPU_ON;
ocl_hog.detectMultiScale(d_src, found_locations); ocl_hog.detectMultiScale(d_src, found_locations);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -80,18 +80,18 @@ PERF_TEST_P(Size_Dp_MinDist, OCL_HoughCircles, ...@@ -80,18 +80,18 @@ PERF_TEST_P(Size_Dp_MinDist, OCL_HoughCircles,
cv::circle(src, center, radius, cv::Scalar::all(255), -1); cv::circle(src, center, radius, cv::Scalar::all(255), -1);
} }
cv::ocl::oclMat ocl_src(src); cv::ocl::oclMat ocl_src(src);
cv::ocl::oclMat ocl_circles; cv::ocl::oclMat ocl_circles;
declare.time(10.0).iterations(25); declare.time(10.0).iterations(25);
TEST_CYCLE() TEST_CYCLE()
{ {
cv::ocl::HoughCircles(ocl_src, ocl_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius); cv::ocl::HoughCircles(ocl_src, ocl_circles, HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
} }
cv::Mat circles(ocl_circles); cv::Mat circles(ocl_circles);
SANITY_CHECK(circles); SANITY_CHECK(circles);
} }
......
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -52,7 +53,7 @@ ...@@ -52,7 +53,7 @@
// ocl::oclMat d_src(src), d_templ(templ), d_dst; // ocl::oclMat d_src(src), d_templ(templ), d_dst;
// ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR); // ocl::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
//} //}
TEST(matchTemplate) PERFTEST(matchTemplate)
{ {
//InitMatchTemplate(); //InitMatchTemplate();
...@@ -89,9 +90,10 @@ TEST(matchTemplate) ...@@ -89,9 +90,10 @@ TEST(matchTemplate)
ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR); ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), templ.rows * templ.cols * 1e-1));
GPU_ON; GPU_ON;
ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR); ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -129,9 +131,10 @@ TEST(matchTemplate) ...@@ -129,9 +131,10 @@ TEST(matchTemplate)
ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR_NORMED); ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR_NORMED);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), templ.rows * templ.cols * 1e-1));
GPU_ON; GPU_ON;
ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR_NORMED); ocl::matchTemplate(d_src, d_templ, d_dst, TM_CCORR_NORMED);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -143,4 +146,4 @@ TEST(matchTemplate) ...@@ -143,4 +146,4 @@ TEST(matchTemplate)
} }
} }
} }
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// ConvertTo//////////////////////// ///////////// ConvertTo////////////////////////
TEST(ConvertTo) PERFTEST(ConvertTo)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -76,9 +77,11 @@ TEST(ConvertTo) ...@@ -76,9 +77,11 @@ TEST(ConvertTo)
d_src.convertTo(d_dst, CV_32FC1); d_src.convertTo(d_dst, CV_32FC1);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), 0.0));
GPU_ON; GPU_ON;
d_src.convertTo(d_dst, CV_32FC1); d_src.convertTo(d_dst, CV_32FC1);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -91,7 +94,7 @@ TEST(ConvertTo) ...@@ -91,7 +94,7 @@ TEST(ConvertTo)
} }
} }
///////////// copyTo//////////////////////// ///////////// copyTo////////////////////////
TEST(copyTo) PERFTEST(copyTo)
{ {
Mat src, dst; Mat src, dst;
ocl::oclMat d_src, d_dst; ocl::oclMat d_src, d_dst;
...@@ -122,9 +125,11 @@ TEST(copyTo) ...@@ -122,9 +125,11 @@ TEST(copyTo)
d_src.copyTo(d_dst); d_src.copyTo(d_dst);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), 0.0));
GPU_ON; GPU_ON;
d_src.copyTo(d_dst); d_src.copyTo(d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -137,7 +142,7 @@ TEST(copyTo) ...@@ -137,7 +142,7 @@ TEST(copyTo)
} }
} }
///////////// setTo//////////////////////// ///////////// setTo////////////////////////
TEST(setTo) PERFTEST(setTo)
{ {
Mat src, dst; Mat src, dst;
Scalar val(1, 2, 3, 4); Scalar val(1, 2, 3, 4);
...@@ -166,9 +171,11 @@ TEST(setTo) ...@@ -166,9 +171,11 @@ TEST(setTo)
d_src.setTo(val); d_src.setTo(val);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(src, cv::Mat(d_src), 1.0));
GPU_ON; GPU_ON;
d_src.setTo(val); d_src.setTo(val);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// norm//////////////////////// ///////////// norm////////////////////////
TEST(norm) PERFTEST(norm)
{ {
Mat src, buf; Mat src, buf;
ocl::oclMat d_src, d_buf; ocl::oclMat d_src, d_buf;
...@@ -71,9 +72,10 @@ TEST(norm) ...@@ -71,9 +72,10 @@ TEST(norm)
ocl::norm(d_src, d_buf, NORM_INF); ocl::norm(d_src, d_buf, NORM_INF);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(src, cv::Mat(d_buf), .5));
GPU_ON; GPU_ON;
ocl::norm(d_src, d_buf, NORM_INF); ocl::norm(d_src, d_buf, NORM_INF);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// pyrDown ////////////////////// ///////////// pyrDown //////////////////////
TEST(pyrDown) PERFTEST(pyrDown)
{ {
Mat src, dst; Mat src, dst;
int all_type[] = {CV_8UC1, CV_8UC4}; int all_type[] = {CV_8UC1, CV_8UC4};
...@@ -72,9 +73,11 @@ TEST(pyrDown) ...@@ -72,9 +73,11 @@ TEST(pyrDown)
ocl::pyrDown(d_src, d_dst); ocl::pyrDown(d_src, d_dst);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), dst.depth() == CV_32F ? 1e-4f : 1.0f));
GPU_ON; GPU_ON;
ocl::pyrDown(d_src, d_dst); ocl::pyrDown(d_src, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// PyrLKOpticalFlow //////////////////////// ///////////// PyrLKOpticalFlow ////////////////////////
TEST(PyrLKOpticalFlow) PERFTEST(PyrLKOpticalFlow)
{ {
std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"}; std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"};
std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"}; std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"};
...@@ -115,9 +116,14 @@ TEST(PyrLKOpticalFlow) ...@@ -115,9 +116,14 @@ TEST(PyrLKOpticalFlow)
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err); d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err);
WARMUP_OFF; WARMUP_OFF;
std::vector<cv::Point2f> ocl_nextPts(d_nextPts.cols);
std::vector<unsigned char> ocl_status(d_status.cols);
TestSystem::instance().setAccurate(AssertEQ<size_t>(nextPts.size(), ocl_nextPts.size()));
TestSystem::instance().setAccurate(AssertEQ<size_t>(status.size(), ocl_status.size()));
GPU_ON; GPU_ON;
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err); d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status, &d_err);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// pyrUp //////////////////////// ///////////// pyrUp ////////////////////////
TEST(pyrUp) PERFTEST(pyrUp)
{ {
Mat src, dst; Mat src, dst;
int all_type[] = {CV_8UC1, CV_8UC4}; int all_type[] = {CV_8UC1, CV_8UC4};
...@@ -72,9 +73,10 @@ TEST(pyrUp) ...@@ -72,9 +73,10 @@ TEST(pyrUp)
ocl::pyrUp(d_src, d_dst); ocl::pyrUp(d_src, d_dst);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(dst, cv::Mat(d_dst), (src.depth() == CV_32F ? 1e-4f : 1.0)));
GPU_ON; GPU_ON;
ocl::pyrUp(d_src, d_dst); ocl::pyrUp(d_src, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// //
// @Authors // @Authors
// Fangfang Bai, fangfang@multicorewareinc.com // Fangfang Bai, fangfang@multicorewareinc.com
// Jin Ma, jin@multicorewareinc.com
// //
// Redistribution and use in source and binary forms, with or without modification, // Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met: // are permitted provided that the following conditions are met:
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
#include "precomp.hpp" #include "precomp.hpp"
///////////// Merge//////////////////////// ///////////// Merge////////////////////////
TEST(Merge) PERFTEST(Merge)
{ {
Mat dst; Mat dst;
ocl::oclMat d_dst; ocl::oclMat d_dst;
...@@ -84,9 +85,10 @@ TEST(Merge) ...@@ -84,9 +85,10 @@ TEST(Merge)
ocl::merge(d_src, d_dst); ocl::merge(d_src, d_dst);
WARMUP_OFF; WARMUP_OFF;
TestSystem::instance().setAccurate(ExpectedMatNear(cv::Mat(dst), cv::Mat(d_dst), 0.0));
GPU_ON; GPU_ON;
ocl::merge(d_src, d_dst); ocl::merge(d_src, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
...@@ -105,7 +107,7 @@ TEST(Merge) ...@@ -105,7 +107,7 @@ TEST(Merge)
} }
///////////// Split//////////////////////// ///////////// Split////////////////////////
TEST(Split) PERFTEST(Split)
{ {
//int channels = 4; //int channels = 4;
int all_type[] = {CV_8UC1, CV_32FC1}; int all_type[] = {CV_8UC1, CV_32FC1};
...@@ -135,9 +137,23 @@ TEST(Split) ...@@ -135,9 +137,23 @@ TEST(Split)
ocl::split(d_src, d_dst); ocl::split(d_src, d_dst);
WARMUP_OFF; WARMUP_OFF;
if(d_dst.size() == dst.size())
{
TestSystem::instance().setAccurate(1);
for(size_t i = 0; i < dst.size(); i++)
{
if(ExpectedMatNear(dst[i], cv::Mat(d_dst[i]), 0.0) == 0)
{
TestSystem::instance().setAccurate(0);
break;
}
}
}else
TestSystem::instance().setAccurate(0);
GPU_ON; GPU_ON;
ocl::split(d_src, d_dst); ocl::split(d_src, d_dst);
;
GPU_OFF; GPU_OFF;
GPU_FULL_ON; GPU_FULL_ON;
......
This diff is collapsed.
...@@ -40,6 +40,14 @@ ...@@ -40,6 +40,14 @@
// //
//M*/ //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
#include <iomanip> #include <iomanip>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
...@@ -50,10 +58,14 @@ ...@@ -50,10 +58,14 @@
#include "opencv2/core.hpp" #include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/video.hpp" #include "opencv2/video.hpp"
#include "opencv2/objdetect.hpp" #include "opencv2/objdetect.hpp"
#include "opencv2/features2d.hpp" #include "opencv2/features2d.hpp"
#include "opencv2/ocl.hpp" #include "opencv2/ocl.hpp"
#include "opencv2/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
#include "opencv2/ts/ts_gtest.h"
#include "opencv2/core/utility.hpp" #include "opencv2/core/utility.hpp"
...@@ -66,6 +78,8 @@ using namespace std; ...@@ -66,6 +78,8 @@ using namespace std;
using namespace cv; using namespace cv;
void gen(Mat &mat, int rows, int cols, int type, Scalar low, Scalar high); void gen(Mat &mat, int rows, int cols, int type, Scalar low, Scalar high);
void gen(Mat &mat, int rows, int cols, int type, int low, int high, int n);
string abspath(const string &relpath); string abspath(const string &relpath);
typedef struct typedef struct
...@@ -78,6 +92,50 @@ COOR do_meanShift(int x0, int y0, uchar *sptr, uchar *dptr, int sstep, ...@@ -78,6 +92,50 @@ COOR do_meanShift(int x0, int y0, uchar *sptr, uchar *dptr, int sstep,
void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi,
int sp, int sr, cv::TermCriteria crit); int sp, int sr, cv::TermCriteria crit);
template<class T1, class T2>
int ExpectedEQ(T1 expected, T2 actual)
{
if(expected == actual)
return 1;
return 0;
}
template<class T1>
int EeceptDoubleEQ(T1 expected, T1 actual)
{
testing::internal::Double lhs(expected);
testing::internal::Double rhs(actual);
if (lhs.AlmostEquals(rhs))
{
return 1;
}
return 0;
}
template<class T>
int AssertEQ(T expected, T actual)
{
if(expected == actual)
{
return 1;
}
return 0;
}
int ExceptDoubleNear(double val1, double val2, double abs_error);
bool match_rect(cv::Rect r1, cv::Rect r2, int threshold);
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);
int ExpectedMatNear(cv::Mat dst, cv::Mat cpu_dst, double eps);
int ExceptedMatSimilar(cv::Mat dst, cv::Mat cpu_dst, double eps);
class Runnable class Runnable
{ {
public: public:
...@@ -173,6 +231,16 @@ public: ...@@ -173,6 +231,16 @@ public:
return cur_iter_idx_ >= cpu_num_iters_; return cur_iter_idx_ >= cpu_num_iters_;
} }
int get_cur_iter_idx()
{
return cur_iter_idx_;
}
int get_cpu_num_iters()
{
return cpu_num_iters_;
}
bool warmupStop() bool warmupStop()
{ {
return cur_warmup_idx_++ >= gpu_warmup_iters_; return cur_warmup_idx_++ >= gpu_warmup_iters_;
...@@ -254,6 +322,16 @@ public: ...@@ -254,6 +322,16 @@ public:
itname_changed_ = true; itname_changed_ = true;
} }
void setAccurate(int is_accurate = -1)
{
is_accurate_ = is_accurate;
}
std::stringstream &getCurSubtestDescription()
{
return cur_subtest_description_;
}
private: private:
TestSystem(): TestSystem():
cur_subtest_is_empty_(true), cpu_elapsed_(0), cur_subtest_is_empty_(true), cpu_elapsed_(0),
...@@ -263,7 +341,8 @@ private: ...@@ -263,7 +341,8 @@ private:
speedup_full_faster_count_(0), speedup_full_slower_count_(0), speedup_full_equal_count_(0), is_list_mode_(false), 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), num_iters_(10), cpu_num_iters_(2),
gpu_warmup_iters_(1), cur_iter_idx_(0), cur_warmup_idx_(0), gpu_warmup_iters_(1), cur_iter_idx_(0), cur_warmup_idx_(0),
record_(0), recordname_("performance"), itname_changed_(true) record_(0), recordname_("performance"), itname_changed_(true),
is_accurate_(-1)
{ {
cpu_times_.reserve(num_iters_); cpu_times_.reserve(num_iters_);
gpu_times_.reserve(num_iters_); gpu_times_.reserve(num_iters_);
...@@ -279,20 +358,22 @@ private: ...@@ -279,20 +358,22 @@ private:
cur_subtest_description_.str(""); cur_subtest_description_.str("");
cur_subtest_is_empty_ = true; cur_subtest_is_empty_ = true;
cur_iter_idx_ = 0; cur_iter_idx_ = 0;
cur_warmup_idx_ = 0;
cpu_times_.clear(); cpu_times_.clear();
gpu_times_.clear(); gpu_times_.clear();
gpu_full_times_.clear(); gpu_full_times_.clear();
is_accurate_ = -1;
} }
double meanTime(const std::vector<int64> &samples); double meanTime(const std::vector<int64> &samples);
void printHeading(); void printHeading();
void printSummary(); 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 printMetrics(int is_accurate, 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 writeHeading();
void writeSummary(); void writeSummary();
void writeMetrics(double cpu_time, double gpu_time = 0.0f, double gpu_full_time = 0.0f, void writeMetrics(int is_accurate, double cpu_time, double gpu_time = 0.0f, double gpu_full_time = 0.0f,
double speedup = 0.0f, double fullspeedup = 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); double gpu_min = 0.0f, double gpu_max = 0.0f, double std_dev = 0.0f);
...@@ -342,6 +423,8 @@ private: ...@@ -342,6 +423,8 @@ private:
std::string recordname_; std::string recordname_;
std::string itname_; std::string itname_;
bool itname_changed_; bool itname_changed_;
int is_accurate_;
}; };
...@@ -355,7 +438,7 @@ struct name##_init: Runnable { \ ...@@ -355,7 +438,7 @@ struct name##_init: Runnable { \
void name##_init::run() void name##_init::run()
#define TEST(name) \ #define PERFTEST(name) \
struct name##_test: Runnable { \ struct name##_test: Runnable { \
name##_test(): Runnable(#name) { \ name##_test(): Runnable(#name) { \
TestSystem::instance().addTest(this); \ TestSystem::instance().addTest(this); \
......
...@@ -74,7 +74,7 @@ TEST_P(Gemm, Accuracy) ...@@ -74,7 +74,7 @@ TEST_P(Gemm, Accuracy)
cv::gemm(a, b, 1.0, c, 1.0, dst, flags); cv::gemm(a, b, 1.0, c, 1.0, dst, flags);
cv::ocl::gemm(cv::ocl::oclMat(a), cv::ocl::oclMat(b), 1.0, cv::ocl::oclMat(c), 1.0, ocl_dst, flags); cv::ocl::gemm(cv::ocl::oclMat(a), cv::ocl::oclMat(b), 1.0, cv::ocl::oclMat(c), 1.0, ocl_dst, flags);
EXPECT_MAT_NEAR(dst, ocl_dst, mat_size.area() * 1e-4, ""); EXPECT_MAT_NEAR(dst, ocl_dst, mat_size.area() * 1e-4);
} }
INSTANTIATE_TEST_CASE_P(ocl_gemm, Gemm, testing::Combine( INSTANTIATE_TEST_CASE_P(ocl_gemm, Gemm, testing::Combine(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment