This commit is contained in:
Ilya Lavrenov 2014-03-01 13:13:24 +04:00
parent c1c3139368
commit 767b28f2e3
13 changed files with 364 additions and 296 deletions

View File

@ -60,15 +60,14 @@ OCL_PERF_TEST_P(LUTFixture, LUT,
// getting params // getting params
const Size_MatType_t params = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params), cn = CV_MAT_CN(type);
// creating src data // creating src data
Mat src(srcSize, CV_8UC1), lut(1, 256, type); Mat src(srcSize, CV_8UC(cn)), lut(1, 256, type);
int dstType = CV_MAKETYPE(lut.depth(), src.channels()); int dstType = CV_MAKETYPE(lut.depth(), src.channels());
Mat dst(srcSize, dstType); Mat dst(srcSize, dstType);
randu(lut, 0, 2); declare.in(src, lut, WARMUP_RNG).out(dst);
declare.in(src, WARMUP_RNG).in(lut).out(dst);
// select implementation // select implementation
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
@ -564,158 +563,6 @@ OCL_PERF_TEST_P(FlipFixture, Flip,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
///////////// MinMax ////////////////////////
typedef Size_MatType MinMaxFixture;
PERF_TEST_P(MinMaxFixture, MinMax,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
declare.in(src, WARMUP_RNG);
double min_val = std::numeric_limits<double>::max(),
max_val = std::numeric_limits<double>::min();
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
Point min_loc, max_loc;
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// MinMaxLoc ////////////////////////
typedef Size_MatType MinMaxLocFixture;
OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
randu(src, 0, 1);
declare.in(src);
double min_val = 0.0, max_val = 0.0;
Point min_loc, max_loc;
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// Sum ////////////////////////
typedef Size_MatType SumFixture;
OCL_PERF_TEST_P(SumFixture, Sum,
::testing::Combine(OCL_TEST_SIZES,
OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar result;
randu(src, 0, 60);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::sum(src);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else
OCL_PERF_ELSE
}
///////////// countNonZero ////////////////////////
typedef Size_MatType CountNonZeroFixture;
OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero,
::testing::Combine(OCL_TEST_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
int result = 0;
randu(src, 0, 256);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc);
SANITY_CHECK(result);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::countNonZero(src);
SANITY_CHECK(result);
}
else
OCL_PERF_ELSE
}
///////////// Phase //////////////////////// ///////////// Phase ////////////////////////
typedef Size_MatType PhaseFixture; typedef Size_MatType PhaseFixture;
@ -895,6 +742,41 @@ OCL_PERF_TEST_P(BitwiseNotFixture, Bitwise_not,
OCL_PERF_ELSE OCL_PERF_ELSE
} }
///////////// SetIdentity ////////////////////////
typedef Size_MatType SetIdentityFixture;
OCL_PERF_TEST_P(SetIdentityFixture, SetIdentity,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar s = Scalar::all(17);
declare.in(src, WARMUP_RNG).out(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::setIdentity(oclSrc, s);
oclSrc.download(src);
SANITY_CHECK(src);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::setIdentity(src, s);
SANITY_CHECK(src);
}
else
OCL_PERF_ELSE
}
///////////// compare//////////////////////// ///////////// compare////////////////////////
CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT) CV_ENUM(CmpCode, CMP_LT, CMP_LE, CMP_EQ, CMP_NE, CMP_GE, CMP_GT)

View File

@ -46,17 +46,22 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
using namespace perf; using namespace perf;
using std::tr1::get;
//////////////////// BruteForceMatch ///////////////// //////////////////// BruteForceMatch /////////////////
typedef TestBaseWithParam<Size> BruteForceMatcherFixture; typedef Size_MatType BruteForceMatcherFixture;
OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) OCL_PERF_TEST_P(BruteForceMatcherFixture, Match,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
vector<DMatch> matches; vector<DMatch> matches;
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1); Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train); declare.in(query, train);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f); randu(train, 0.0f, 1.0f);
@ -82,12 +87,16 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_S
OCL_PERF_ELSE OCL_PERF_ELSE
} }
OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
vector<vector<DMatch> > matches(2); vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F); Mat query(srcSize, type), train(srcSize, type);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f); randu(train, 0.0f, 1.0f);
@ -121,13 +130,17 @@ OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OC
OCL_PERF_ELSE OCL_PERF_ELSE
} }
OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3)) OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_PERF_ENUM(MatType(CV_32FC1))))
{ {
const Size srcSize = GetParam(); const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const float max_distance = 2.0f; const float max_distance = 2.0f;
vector<vector<DMatch> > matches(2); vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1); Mat query(srcSize, type), train(srcSize, type);
declare.in(query, train); declare.in(query, train);
randu(query, 0.0f, 1.0f); randu(query, 0.0f, 1.0f);

View File

@ -71,9 +71,6 @@ OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1,
randu(src, 0.0f, 1.0f); randu(src, 0.0f, 1.0f);
declare.in(src); declare.in(src);
if (srcSize == OCL_SIZE_4000)
declare.time(7.4);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst; ocl::oclMat oclSrc(src), oclDst;

View File

@ -47,28 +47,32 @@
using namespace perf; using namespace perf;
using std::tr1::get; using std::tr1::get;
using std::tr1::tuple;
///////////// gemm //////////////////////// ///////////// gemm ////////////////////////
typedef Size_MatType GemmFixture;
#ifdef HAVE_CLAMDBLAS #ifdef HAVE_CLAMDBLAS
typedef tuple<Size, int> GemmParams;
typedef TestBaseWithParam<GemmParams> GemmFixture;
OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine( OCL_PERF_TEST_P(GemmFixture, Gemm, ::testing::Combine(
::testing::Values(Size(1000, 1000), Size(1500, 1500)), ::testing::Values(Size(1000, 1000), Size(1500, 1500)),
::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T))) ::testing::Values((int)cv::GEMM_1_T, (int)cv::GEMM_1_T | (int)cv::GEMM_2_T)))
{ {
const Size_MatType_t params = GetParam(); const GemmParams params = GetParam();
const Size srcSize = get<0>(params); const Size srcSize = get<0>(params);
const int type = get<1>(params); const int type = get<1>(params);
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1), Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
declare.in(src1, src2, src3).out(dst).time(srcSize == OCL_SIZE_2000 ? 65 : 8);
randu(src1, -10.0f, 10.0f); randu(src1, -10.0f, 10.0f);
randu(src2, -10.0f, 10.0f); randu(src2, -10.0f, 10.0f);
randu(src3, -10.0f, 10.0f); randu(src3, -10.0f, 10.0f);
declare.in(src1, src2, src3).out(dst);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc1(src1), oclSrc2(src2), ocl::oclMat oclSrc1(src1), oclSrc2(src2),

View File

@ -74,7 +74,7 @@ OCL_PERF_TEST(HOGFixture, HOG)
ASSERT_TRUE(!src.empty()) << "can't open input image road.png"; ASSERT_TRUE(!src.empty()) << "can't open input image road.png";
vector<cv::Rect> found_locations; vector<cv::Rect> found_locations;
declare.in(src).time(5); declare.in(src);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {

View File

@ -133,8 +133,7 @@ OCL_PERF_TEST_P(CornerMinEigenValFixture, CornerMinEigenVal,
const int blockSize = 7, apertureSize = 1 + 2 * 3; const int blockSize = 7, apertureSize = 1 + 2 * 3;
Mat src(srcSize, type), dst(srcSize, CV_32FC1); Mat src(srcSize, type), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst) declare.in(src, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3);
const int depth = CV_MAT_DEPTH(type); const int depth = CV_MAT_DEPTH(type);
const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE; const ERROR_TYPE errorType = depth == CV_8U ? ERROR_ABSOLUTE : ERROR_RELATIVE;
@ -172,8 +171,7 @@ OCL_PERF_TEST_P(CornerHarrisFixture, CornerHarris,
Mat src(srcSize, type), dst(srcSize, CV_32FC1); Mat src(srcSize, type), dst(srcSize, CV_32FC1);
randu(src, 0, 1); randu(src, 0, 1);
declare.in(src).out(dst) declare.in(src).out(dst);
.time(srcSize == OCL_SIZE_4000 ? 20 : srcSize == OCL_SIZE_2000 ? 5 : 3);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
@ -469,9 +467,7 @@ PERF_TEST_P(MeanShiftFilteringFixture, MeanShiftFiltering,
cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1); cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1);
Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4); Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4);
declare.in(src, WARMUP_RNG).out(dst) declare.in(src, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_4000 ?
56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
@ -562,9 +558,7 @@ PERF_TEST_P(MeanShiftProcFixture, MeanShiftProc,
Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4), Mat src(srcSize, CV_8UC4), dst1(srcSize, CV_8UC4),
dst2(srcSize, CV_16SC2); dst2(srcSize, CV_16SC2);
declare.in(src, WARMUP_RNG).out(dst1, dst2) declare.in(src, WARMUP_RNG).out(dst1, dst2);
.time(srcSize == OCL_SIZE_4000 ?
56 : srcSize == OCL_SIZE_2000 ? 15 : 3.8);;
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
@ -603,9 +597,6 @@ OCL_PERF_TEST_P(CLAHEFixture, CLAHE, OCL_TEST_SIZES)
const double clipLimit = 40.0; const double clipLimit = 40.0;
declare.in(src, WARMUP_RNG); declare.in(src, WARMUP_RNG);
if (srcSize == OCL_SIZE_4000)
declare.time(11);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst; ocl::oclMat oclSrc(src), oclDst;
@ -649,9 +640,6 @@ PERF_TEST_P(ColumnSumFixture, ColumnSum, OCL_TYPICAL_MAT_SIZES)
Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1); Mat src(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
if (srcSize == OCL_SIZE_4000)
declare.time(5);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {
ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1); ocl::oclMat oclSrc(src), oclDst(srcSize, CV_32FC1);

View File

@ -235,9 +235,6 @@ OCL_PERF_TEST_P(RemapFixture, Remap,
Mat src(srcSize, type), dst(srcSize, type); Mat src(srcSize, type), dst(srcSize, type);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
if (srcSize == OCL_SIZE_4000 && interpolation == INTER_LINEAR)
declare.time(9);
Mat xmap, ymap; Mat xmap, ymap;
xmap.create(srcSize, CV_32FC1); xmap.create(srcSize, CV_32FC1);
ymap.create(srcSize, CV_32FC1); ymap.create(srcSize, CV_32FC1);

View File

@ -46,7 +46,7 @@
#include "perf_precomp.hpp" #include "perf_precomp.hpp"
#ifdef HAVE_CLAMDBLAS //#ifdef HAVE_CLAMDBLAS
using namespace perf; using namespace perf;
using namespace std; using namespace std;
@ -100,4 +100,4 @@ PERF_TEST_P(KalmanFilterFixture, KalmanFilter,
SANITY_CHECK(statePre_); SANITY_CHECK(statePre_);
} }
#endif // HAVE_CLAMDBLAS //#endif // HAVE_CLAMDBLAS

View File

@ -99,8 +99,7 @@ OCL_PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate,
Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst; Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst;
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1); const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
dst.create(dstSize, CV_8UC1); dst.create(dstSize, CV_8UC1);
declare.in(src, templ, WARMUP_RNG).out(dst) declare.in(src, templ, WARMUP_RNG).out(dst);
.time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2);
if (RUN_OCL_IMPL) if (RUN_OCL_IMPL)
{ {

View File

@ -55,7 +55,7 @@ static void genData(Mat& trainData, Size size, Mat& trainLabel = Mat().setTo(Sca
trainData.create(size, CV_32FC1); trainData.create(size, CV_32FC1);
randu(trainData, 1.0, 100.0); randu(trainData, 1.0, 100.0);
if(nClasses != 0) if (nClasses != 0)
{ {
trainLabel.create(size.height, 1, CV_8UC1); trainLabel.create(size.height, 1, CV_8UC1);
randu(trainLabel, 0, nClasses - 1); randu(trainLabel, 0, nClasses - 1);
@ -82,7 +82,7 @@ PERF_TEST_P(KNNFixture, KNN,
genData(testData, size); genData(testData, size);
Mat best_label; Mat best_label;
if(RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
TEST_CYCLE() TEST_CYCLE()
{ {
@ -90,7 +90,8 @@ PERF_TEST_P(KNNFixture, KNN,
knn_cpu.train(trainData, trainLabels); knn_cpu.train(trainData, trainLabels);
knn_cpu.find_nearest(testData, k, &best_label); knn_cpu.find_nearest(testData, k, &best_label);
} }
}else if(RUN_OCL_IMPL) }
else if (RUN_OCL_IMPL)
{ {
cv::ocl::oclMat best_label_ocl; cv::ocl::oclMat best_label_ocl;
cv::ocl::oclMat testdata; cv::ocl::oclMat testdata;
@ -103,7 +104,8 @@ PERF_TEST_P(KNNFixture, KNN,
knn_ocl.find_nearest(testdata, k, best_label_ocl); knn_ocl.find_nearest(testdata, k, best_label_ocl);
} }
best_label_ocl.download(best_label); best_label_ocl.download(best_label);
}else }
else
OCL_PERF_ELSE OCL_PERF_ELSE
SANITY_CHECK(best_label); SANITY_CHECK(best_label);
} }
@ -188,7 +190,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM,
CvMat samples_ = samples; CvMat samples_ = samples;
CvMat results_ = results; CvMat results_ = results;
if(RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {
CvSVM svm; CvSVM svm;
svm.train(trainData, labels, Mat(), Mat(), params); svm.train(trainData, labels, Mat(), Mat(), params);
@ -197,7 +199,7 @@ PERF_TEST_P(SVMFixture, DISABLED_SVM,
svm.predict(&samples_, &results_); svm.predict(&samples_, &results_);
} }
} }
else if(RUN_OCL_IMPL) else if (RUN_OCL_IMPL)
{ {
CvSVM_OCL svm; CvSVM_OCL svm;
svm.train(trainData, labels, Mat(), Mat(), params); svm.train(trainData, labels, Mat(), Mat(), params);

View File

@ -1,89 +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.
//
//
// 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
// Jin Ma, jin@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 materials 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 "perf_precomp.hpp"
using namespace perf;
using std::tr1::tuple;
using std::tr1::get;
///////////// norm////////////////////////
CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
typedef std::tr1::tuple<Size, MatType, NormType> NormParams;
typedef TestBaseWithParam<NormParams> NormFixture;
OCL_PERF_TEST_P(NormFixture, Norm,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_TEST_TYPES, NormType::all()))
{
const NormParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const int normType = get<2>(params);
perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE;
double eps = 1e-5, value;
Mat src1(srcSize, type), src2(srcSize, type);
declare.in(src1, src2, WARMUP_RNG);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2);
OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType);
SANITY_CHECK(value, eps, errorType);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() value = cv::norm(src1, src2, normType);
SANITY_CHECK(value, eps, errorType);
}
else
OCL_PERF_ELSE
}

View File

@ -52,13 +52,12 @@ using std::tr1::get;
using std::tr1::tuple; using std::tr1::tuple;
using std::tr1::make_tuple; using std::tr1::make_tuple;
typedef tuple<int> PyrLKOpticalFlowParamType; typedef TestBaseWithParam<tuple<int> > PyrLKOpticalFlowFixture;
typedef TestBaseWithParam<int> PyrLKOpticalFlowFixture;
OCL_PERF_TEST_P(PyrLKOpticalFlowFixture, OCL_PERF_TEST_P(PyrLKOpticalFlowFixture,
PyrLKOpticalFlow, ::testing::Values(1000, 2000, 4000)) PyrLKOpticalFlow, ::testing::Values(1000, 2000, 4000))
{ {
const int pointsCount = GetParam(); const int pointsCount = get<0>(GetParam());
const string fileName0 = "gpu/opticalflow/rubberwhale1.png", const string fileName0 = "gpu/opticalflow/rubberwhale1.png",
fileName1 = "gpu/opticalflow/rubberwhale2.png"; fileName1 = "gpu/opticalflow/rubberwhale2.png";
@ -109,7 +108,7 @@ PERF_TEST(tvl1flowFixture, tvl1flow)
const Size srcSize = frame0.size(); const Size srcSize = frame0.size();
const double eps = 1.2; const double eps = 1.2;
Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1); Mat flow(srcSize, CV_32FC2), flow1(srcSize, CV_32FC1), flow2(srcSize, CV_32FC1);
declare.in(frame0, frame1).out(flow1, flow2).time(159); declare.in(frame0, frame1).out(flow1, flow2);
if (RUN_PLAIN_IMPL) if (RUN_PLAIN_IMPL)
{ {

View File

@ -0,0 +1,276 @@
/*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
// Jin Ma, jin@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 materials 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 "perf_precomp.hpp"
using namespace perf;
using std::tr1::tuple;
using std::tr1::get;
///////////// MinMax ////////////////////////
typedef Size_MatType MinMaxFixture;
PERF_TEST_P(MinMaxFixture, MinMax,
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
declare.in(src, WARMUP_RNG);
double min_val = std::numeric_limits<double>::max(),
max_val = std::numeric_limits<double>::min();
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMax(oclSrc, &min_val, &max_val);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
Point min_loc, max_loc;
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// MinMaxLoc ////////////////////////
typedef Size_MatType MinMaxLocFixture;
OCL_PERF_TEST_P(MinMaxLocFixture, MinMaxLoc,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
randu(src, 0, 1);
declare.in(src);
double min_val = 0.0, max_val = 0.0;
Point min_loc, max_loc;
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::minMaxLoc(oclSrc, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
ASSERT_GE(max_val, min_val);
SANITY_CHECK(min_val);
SANITY_CHECK(max_val);
}
else
OCL_PERF_ELSE
}
///////////// Sum ////////////////////////
typedef Size_MatType SumFixture;
OCL_PERF_TEST_P(SumFixture, Sum,
::testing::Combine(OCL_TEST_SIZES,
OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar result;
randu(src, 0, 60);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::sum(oclSrc);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::sum(src);
SANITY_CHECK(result, 1e-6, ERROR_RELATIVE);
}
else
OCL_PERF_ELSE
}
///////////// countNonZero ////////////////////////
typedef Size_MatType CountNonZeroFixture;
OCL_PERF_TEST_P(CountNonZeroFixture, CountNonZero,
::testing::Combine(OCL_TEST_SIZES,
OCL_PERF_ENUM(CV_8UC1, CV_32FC1)))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
int result = 0;
randu(src, 0, 256);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() result = cv::ocl::countNonZero(oclSrc);
SANITY_CHECK(result);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() result = cv::countNonZero(src);
SANITY_CHECK(result);
}
else
OCL_PERF_ELSE
}
///////////// meanStdDev ////////////////////////
typedef Size_MatType MeanStdDevFixture;
OCL_PERF_TEST_P(MeanStdDevFixture, MeanStdDev,
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
{
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
Mat src(srcSize, type);
Scalar mean, stddev;
randu(src, 0, 256);
declare.in(src);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc(src);
OCL_TEST_CYCLE() cv::ocl::meanStdDev(oclSrc, mean, stddev);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::meanStdDev(src, mean, stddev);
}
else
OCL_PERF_ELSE
SANITY_CHECK_NOTHING();
// SANITY_CHECK(mean, 1e-6, ERROR_RELATIVE);
// SANITY_CHECK(stddev, 1e-6, ERROR_RELATIVE);
}
///////////// norm////////////////////////
CV_ENUM(NormType, NORM_INF, NORM_L1, NORM_L2)
typedef std::tr1::tuple<Size, MatType, NormType> NormParams;
typedef TestBaseWithParam<NormParams> NormFixture;
OCL_PERF_TEST_P(NormFixture, Norm,
::testing::Combine(OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
OCL_TEST_TYPES, NormType::all()))
{
const NormParams params = GetParam();
const Size srcSize = get<0>(params);
const int type = get<1>(params);
const int normType = get<2>(params);
perf::ERROR_TYPE errorType = type != NORM_INF ? ERROR_RELATIVE : ERROR_ABSOLUTE;
double eps = 1e-5, value;
Mat src1(srcSize, type), src2(srcSize, type);
declare.in(src1, src2, WARMUP_RNG);
if (RUN_OCL_IMPL)
{
ocl::oclMat oclSrc1(src1), oclSrc2(src2);
OCL_TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, normType);
SANITY_CHECK(value, eps, errorType);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() value = cv::norm(src1, src2, normType);
SANITY_CHECK(value, eps, errorType);
}
else
OCL_PERF_ELSE
}