most of the performance tests was rewritten in google-test manner
This commit is contained in:
parent
6c4ad9b597
commit
4c28a6f0f6
@ -42,7 +42,7 @@
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
static int old_main(int argc, const char *argv[])
|
||||
{
|
||||
const char *keys =
|
||||
"{ h | help | false | print help message }"
|
||||
@ -99,7 +99,7 @@ int main(int argc, const char *argv[])
|
||||
|
||||
// set this to overwrite binary cache every time the test starts
|
||||
ocl::setBinaryDiskCache(ocl::CACHE_UPDATE);
|
||||
|
||||
|
||||
if (cmd.get<bool>("verify"))
|
||||
{
|
||||
TestSystem::instance().setNumIters(1);
|
||||
@ -162,3 +162,33 @@ END_DEV:
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * impls[] =
|
||||
{
|
||||
"ocl",
|
||||
"plain",
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
"gpu"
|
||||
#endif
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// temp solution: if no '--gtest_' and '--perf_' args switch to old behavior
|
||||
bool useGTest = false;
|
||||
|
||||
for(int i=1; i<argc; i++)
|
||||
{
|
||||
std::string arg( argv[i] );
|
||||
if( arg.find("--gtest_")==0 || arg.find("--perf_")==0 )
|
||||
useGTest = true;
|
||||
|
||||
// if (arg == "--perf_verify_sanity")
|
||||
// argv[i] = (char*)"--perf_no_verify_sanity";
|
||||
}
|
||||
|
||||
if( !useGTest )
|
||||
return old_main(argc, (const char**)argv);
|
||||
|
||||
CV_PERF_TEST_MAIN_INTERNALS(ocl, impls)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,9 +45,15 @@
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// 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)
|
||||
static void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2,
|
||||
const cv::Mat &weights1, const cv::Mat &weights2,
|
||||
cv::Mat &result_gold)
|
||||
{
|
||||
result_gold.create(img1.size(), img1.type());
|
||||
|
||||
@ -63,60 +69,54 @@ void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &we
|
||||
|
||||
for (int x = 0; x < img1.cols * cn; ++x)
|
||||
{
|
||||
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));
|
||||
int x1 = x * cn;
|
||||
float w1 = weights1_row[x];
|
||||
float w2 = weights2_row[x];
|
||||
result_gold_row[x] = static_cast<T>((img1_row[x1] * w1
|
||||
+ img2_row[x1] * w2) / (w1 + w2 + 1e-5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
PERFTEST(blend)
|
||||
|
||||
typedef TestBaseWithParam<Size> blendLinearFixture;
|
||||
|
||||
PERF_TEST_P(blendLinearFixture, blendLinear, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat src1, src2, weights1, weights2, dst, ocl_dst;
|
||||
ocl::oclMat d_src1, d_src2, d_weights1, d_weights2, d_dst;
|
||||
// getting params
|
||||
const Size srcSize = GetParam();
|
||||
const int type = CV_8UC1;
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
// creating src data
|
||||
Mat src1(srcSize, type), src2(srcSize, CV_8UC1), dst;
|
||||
Mat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
declare.in(src1, src2, WARMUP_RNG);
|
||||
randu(weights1, 0.0f, 1.0f);
|
||||
randu(weights2, 0.0f, 1.0f);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " and CV_32FC1";
|
||||
ocl::oclMat oclSrc1(src1), oclSrc2(src2), oclDst;
|
||||
ocl::oclMat oclWeights1(weights1), oclWeights2(weights2);
|
||||
|
||||
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);
|
||||
TEST_CYCLE() cv::ocl::blendLinear(oclSrc1, oclSrc2, oclWeights1, oclWeights2, oclDst);
|
||||
|
||||
blendLinearGold<uchar>(src1, src2, weights1, weights2, dst);
|
||||
oclDst.download(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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.f);
|
||||
}
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() blendLinearGold<uchar>(src1, src2, weights1, weights2, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,123 +45,242 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
#define OCL_BFMATCHER_TYPICAL_MAT_SIZES ::testing::Values(cv::Size(128, 500), cv::Size(128, 1000), cv::Size(128, 2000))
|
||||
|
||||
//////////////////// BruteForceMatch /////////////////
|
||||
PERFTEST(BruteForceMatcher)
|
||||
|
||||
typedef TestBaseWithParam<Size> BruteForceMatcherFixture;
|
||||
|
||||
PERF_TEST_P(BruteForceMatcherFixture, match,
|
||||
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat trainIdx_cpu;
|
||||
Mat distance_cpu;
|
||||
Mat allDist_cpu;
|
||||
Mat nMatches_cpu;
|
||||
const Size srcSize = GetParam();
|
||||
const string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
vector<DMatch> matches;
|
||||
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
declare.in(query, train).time(srcSize.height == 2000 ? 8 : 4 );
|
||||
randu(query, 0.0f, 1.0f);
|
||||
randu(train, 0.0f, 1.0f);
|
||||
|
||||
if (impl == "plain")
|
||||
{
|
||||
// Init CPU matcher
|
||||
int desc_len = 64;
|
||||
|
||||
BFMatcher matcher(NORM_L2);
|
||||
TEST_CYCLE() matcher.match(query, train, matches);
|
||||
|
||||
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);
|
||||
vector< vector<DMatch> > d_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, d_matches[0]);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
int diff = abs((int)d_matches[0].size() - (int)matches[0].size());
|
||||
if(diff == 0)
|
||||
TestSystem::instance().setAccurate(1, 0);
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, diff);
|
||||
|
||||
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, d_matches, 2);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
diff = abs((int)d_matches[0].size() - (int)matches[0].size());
|
||||
if(diff == 0)
|
||||
TestSystem::instance().setAccurate(1, 0);
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, diff);
|
||||
|
||||
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, d_matches, max_distance);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
diff = abs((int)d_matches[0].size() - (int)matches[0].size());
|
||||
if(diff == 0)
|
||||
TestSystem::instance().setAccurate(1, 0);
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, diff);
|
||||
SANITY_CHECK_MATCHES(matches);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
// Init GPU matcher
|
||||
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
|
||||
ocl::oclMat oclQuery(query), oclTrain(train);
|
||||
|
||||
TEST_CYCLE() oclMatcher.match(oclQuery, oclTrain, matches);
|
||||
|
||||
SANITY_CHECK_MATCHES(matches);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
//PERF_TEST_P(BruteForceMatcherFixture, matchSingle,
|
||||
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
//{
|
||||
// const Size srcSize = GetParam();
|
||||
// const string impl = getSelectedImpl();
|
||||
|
||||
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
// Mat trainIdx, distance;
|
||||
|
||||
// randu(query, 0.0f, 1.0f);
|
||||
// randu(train, 0.0f, 1.0f);
|
||||
|
||||
// if (impl == "plain")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
// else if (impl == "ocl")
|
||||
// {
|
||||
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance;
|
||||
|
||||
// TEST_CYCLE() oclMatcher->matchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance);
|
||||
|
||||
// oclTrainIdx.download(trainIdx);
|
||||
// oclDistance.download(distance);
|
||||
|
||||
// SANITY_CHECK(trainIdx);
|
||||
// SANITY_CHECK(distance);
|
||||
// }
|
||||
//#ifdef HAVE_OPENCV_GPU
|
||||
// else if (impl == "gpu")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//#endif
|
||||
// else
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//}
|
||||
|
||||
PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
|
||||
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
const Size srcSize = GetParam();
|
||||
const string impl = getSelectedImpl();
|
||||
|
||||
vector<vector<DMatch> > matches(2);
|
||||
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
randu(query, 0.0f, 1.0f);
|
||||
randu(train, 0.0f, 1.0f);
|
||||
|
||||
declare.in(query, train);
|
||||
if (srcSize.height == 2000)
|
||||
declare.time(8);
|
||||
|
||||
if (impl == "plain")
|
||||
{
|
||||
BFMatcher matcher (NORM_L2);
|
||||
TEST_CYCLE() matcher.knnMatch(query, train, matches, 2);
|
||||
|
||||
std::vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0);
|
||||
SANITY_CHECK_MATCHES(matches1);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
|
||||
ocl::oclMat oclQuery(query), oclTrain(train);
|
||||
|
||||
TEST_CYCLE() oclMatcher.knnMatch(oclQuery, oclTrain, matches, 2);
|
||||
|
||||
std::vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0);
|
||||
SANITY_CHECK_MATCHES(matches1);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
//PERF_TEST_P(BruteForceMatcherFixture, knnMatchSingle,
|
||||
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
//{
|
||||
// const Size srcSize = GetParam();
|
||||
// const string impl = getSelectedImpl();
|
||||
|
||||
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
// Mat trainIdx, distance, allDist;
|
||||
|
||||
// randu(query, 0.0f, 1.0f);
|
||||
// randu(train, 0.0f, 1.0f);
|
||||
|
||||
// if (impl == "plain")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
// else if (impl == "ocl")
|
||||
// {
|
||||
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance, oclAllDist;
|
||||
|
||||
// TEST_CYCLE() oclMatcher->knnMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclAllDist, 2);
|
||||
|
||||
// oclTrainIdx.download(trainIdx);
|
||||
// oclDistance.download(distance);
|
||||
// oclAllDist.download(allDist);
|
||||
|
||||
// SANITY_CHECK(trainIdx);
|
||||
// SANITY_CHECK(distance);
|
||||
// SANITY_CHECK(allDist);
|
||||
// }
|
||||
//#ifdef HAVE_OPENCV_GPU
|
||||
// else if (impl == "gpu")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//#endif
|
||||
// else
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//}
|
||||
|
||||
PERF_TEST_P(BruteForceMatcherFixture, DISABLED_radiusMatch,
|
||||
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
const Size srcSize = GetParam();
|
||||
const string impl = getSelectedImpl();
|
||||
|
||||
const float max_distance = 2.0f;
|
||||
vector<vector<DMatch> > matches(2);
|
||||
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
declare.in(query, train);
|
||||
Mat trainIdx, distance, allDist;
|
||||
|
||||
randu(query, 0.0f, 1.0f);
|
||||
randu(train, 0.0f, 1.0f);
|
||||
|
||||
if (impl == "plain")
|
||||
{
|
||||
BFMatcher matcher (NORM_L2);
|
||||
TEST_CYCLE() matcher.radiusMatch(query, matches, max_distance);
|
||||
|
||||
std::vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0);
|
||||
SANITY_CHECK_MATCHES(matches1);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
ocl::oclMat oclQuery(query), oclTrain(train);
|
||||
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
|
||||
|
||||
TEST_CYCLE() oclMatcher.radiusMatch(oclQuery, oclTrain, matches, max_distance);
|
||||
|
||||
std::vector<DMatch> & matches0 = matches[0], & matches1 = matches[1];
|
||||
SANITY_CHECK_MATCHES(matches0);
|
||||
SANITY_CHECK_MATCHES(matches1);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
//PERF_TEST_P(BruteForceMatcherFixture, radiusMatchSingle,
|
||||
// OCL_BFMATCHER_TYPICAL_MAT_SIZES)
|
||||
//{
|
||||
// const Size srcSize = GetParam();
|
||||
// const string impl = getSelectedImpl();
|
||||
|
||||
// const float max_distance = 2.0f;
|
||||
// Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
|
||||
// Mat trainIdx, distance, nMatches;
|
||||
|
||||
// randu(query, 0.0f, 1.0f);
|
||||
// randu(train, 0.0f, 1.0f);
|
||||
|
||||
// if (impl == "plain")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
// else if (impl == "ocl")
|
||||
// {
|
||||
// ocl::oclMat oclQuery(query), oclTrain(train), oclTrainIdx, oclDistance, oclNMatches;
|
||||
|
||||
// TEST_CYCLE() oclMatcher->radiusMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclNMatches, max_distance);
|
||||
|
||||
// oclTrainIdx.download(trainIdx);
|
||||
// oclDistance.download(distance);
|
||||
// oclNMatches.download(nMatches);
|
||||
|
||||
// SANITY_CHECK(trainIdx);
|
||||
// SANITY_CHECK(distance);
|
||||
// SANITY_CHECK(nMatches);
|
||||
// }
|
||||
//#ifdef HAVE_OPENCV_GPU
|
||||
// else if (impl == "gpu")
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//#endif
|
||||
// else
|
||||
// CV_TEST_FAIL_NO_IMPL();
|
||||
//}
|
||||
|
||||
#undef OCL_BFMATCHER_TYPICAL_MAT_SIZES
|
||||
|
@ -45,48 +45,49 @@
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
///////////// StereoMatchBM ////////////////////////
|
||||
PERFTEST(StereoMatchBM)
|
||||
|
||||
PERF_TEST(StereoMatchBMFixture, DISABLED_StereoMatchBM)
|
||||
{
|
||||
Mat left_image = imread(abspath("aloeL.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat right_image = imread(abspath("aloeR.jpg"), cv::IMREAD_GRAYSCALE);
|
||||
Mat disp,dst;
|
||||
ocl::oclMat d_left, d_right,d_disp;
|
||||
int n_disp= 128;
|
||||
int winSize =19;
|
||||
Mat left_image = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE);
|
||||
Mat right_image = imread(getDataPath("gpu/stereobm/aloe-R.png"), cv::IMREAD_GRAYSCALE);
|
||||
|
||||
SUBTEST << left_image.cols << 'x' << left_image.rows << "; aloeL.jpg ;"<< right_image.cols << 'x' << right_image.rows << "; aloeR.jpg ";
|
||||
ASSERT_TRUE(!left_image.empty()) << "no input image";
|
||||
ASSERT_TRUE(!right_image.empty()) << "no input image";
|
||||
ASSERT_TRUE(right_image.size() == left_image.size());
|
||||
ASSERT_TRUE(right_image.size() == left_image.size());
|
||||
|
||||
StereoBM bm(0, n_disp, winSize);
|
||||
bm(left_image, right_image, dst);
|
||||
const std::string impl = getSelectedImpl();
|
||||
const int n_disp = 128, winSize = 19;
|
||||
Mat disp(left_image.size(), CV_16SC1);
|
||||
|
||||
CPU_ON;
|
||||
bm(left_image, right_image, dst);
|
||||
CPU_OFF;
|
||||
declare.in(left_image, right_image).out(disp);
|
||||
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
if (impl == "ocl")
|
||||
{
|
||||
ocl::oclMat oclLeft(left_image), oclRight(right_image),
|
||||
oclDisp(left_image.size(), CV_16SC1);
|
||||
ocl::StereoBM_OCL oclBM(0, n_disp, winSize);
|
||||
|
||||
ocl::StereoBM_OCL d_bm(0, n_disp, winSize);
|
||||
TEST_CYCLE() oclBM(oclLeft, oclRight, oclDisp);
|
||||
|
||||
WARMUP_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
WARMUP_OFF;
|
||||
oclDisp.download(disp);
|
||||
|
||||
cv::Mat ocl_mat;
|
||||
d_disp.download(ocl_mat);
|
||||
ocl_mat.convertTo(ocl_mat, dst.type());
|
||||
SANITY_CHECK(disp);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
StereoBM bm(0, n_disp, winSize);
|
||||
|
||||
GPU_ON;
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
GPU_OFF;
|
||||
TEST_CYCLE() bm(left_image, right_image, disp);
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_left.upload(left_image);
|
||||
d_right.upload(right_image);
|
||||
d_bm(d_left, d_right, d_disp);
|
||||
d_disp.download(disp);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().setAccurate(-1, 0.);
|
||||
SANITY_CHECK(disp);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,41 +45,38 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// Canny ////////////////////////
|
||||
PERFTEST(Canny)
|
||||
|
||||
PERF_TEST(CannyFixture, Canny)
|
||||
{
|
||||
Mat img = imread(abspath("aloeL.jpg"), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE),
|
||||
edges(img.size(), CV_8UC1);
|
||||
ASSERT_TRUE(!img.empty()) << "can't open aloeL.jpg";
|
||||
|
||||
if (img.empty())
|
||||
const std::string impl = getSelectedImpl();
|
||||
declare.in(img).out(edges);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
throw runtime_error("can't open aloeL.jpg");
|
||||
ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1);
|
||||
|
||||
TEST_CYCLE() Canny(oclImg, oclEdges, 50.0, 100.0);
|
||||
oclEdges.download(edges);
|
||||
|
||||
SANITY_CHECK(edges);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() Canny(img, edges, 50.0, 100.0);
|
||||
|
||||
SUBTEST << img.cols << 'x' << img.rows << "; aloeL.jpg" << "; edges" << "; CV_8UC1";
|
||||
|
||||
Mat edges(img.size(), CV_8UC1), ocl_edges;
|
||||
|
||||
CPU_ON;
|
||||
Canny(img, edges, 50.0, 100.0);
|
||||
CPU_OFF;
|
||||
|
||||
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;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_img.upload(img);
|
||||
ocl::Canny(d_img, d_buf, d_edges, 50.0, 100.0);
|
||||
d_edges.download(ocl_edges);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExceptedMatSimilar(edges, ocl_edges, 2e-2);
|
||||
SANITY_CHECK(edges);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,49 +45,39 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// cvtColor////////////////////////
|
||||
PERFTEST(cvtColor)
|
||||
|
||||
typedef TestBaseWithParam<Size> cvtColorFixture;
|
||||
|
||||
PERF_TEST_P(cvtColorFixture, cvtColor, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
const Size srcSize = GetParam();
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
int all_type[] = {CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC4"};
|
||||
Mat src(srcSize, CV_8UC4), dst(srcSize, CV_8UC4);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
if (impl == "ocl")
|
||||
{
|
||||
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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExceptedMatSimilar(dst, ocl_dst, 1e-5);
|
||||
}
|
||||
ocl::oclMat oclSrc(src), oclDst(src.size(), CV_8UC4);
|
||||
|
||||
TEST_CYCLE() ocl::cvtColor(oclSrc, oclDst, CV_RGBA2GRAY, 4);
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::cvtColor(src, dst, CV_RGBA2GRAY, 4);
|
||||
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,47 +45,43 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// dft ////////////////////////
|
||||
PERFTEST(dft)
|
||||
|
||||
typedef TestBaseWithParam<Size> dftFixture;
|
||||
|
||||
PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
const std::string impl = getSelectedImpl();
|
||||
Size srcSize = GetParam();
|
||||
|
||||
int all_type[] = {CV_32FC2};
|
||||
std::string type_name[] = {"CV_32FC2"};
|
||||
Mat src(srcSize, CV_32FC2), dst;
|
||||
randu(src, 0.0f, 1.0f);
|
||||
declare.in(src);
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " ; complex-to-complex";
|
||||
ocl::oclMat oclSrc(src), oclDst;
|
||||
|
||||
gen(src, size, size, all_type[j], Scalar::all(0), Scalar::all(1));
|
||||
EXPECT_NO_THROW({
|
||||
TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst);
|
||||
});
|
||||
|
||||
dft(src, dst);
|
||||
|
||||
CPU_ON;
|
||||
dft(src, dst);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::dft(d_src, d_dst, Size(size, size));
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, src.size().area() * 1e-4);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::dft(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,333 +45,344 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::get;
|
||||
using std::tr1::tuple;
|
||||
|
||||
///////////// Blur////////////////////////
|
||||
PERFTEST(Blur)
|
||||
|
||||
CV_ENUM(BlurMatType, CV_8UC1, CV_8UC4)
|
||||
|
||||
typedef tuple<Size, BlurMatType> BlurParams;
|
||||
typedef TestBaseWithParam<BlurParams> BlurFixture;
|
||||
|
||||
PERF_TEST_P(BlurFixture, Blur,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
BlurMatType::all()))
|
||||
{
|
||||
Mat src1, dst, ocl_dst;
|
||||
ocl::oclMat d_src1, d_dst;
|
||||
// getting params
|
||||
BlurParams params = GetParam();
|
||||
const Size srcSize = get<0>(params), ksize(3, 3);
|
||||
const int type = get<1>(params), bordertype = BORDER_CONSTANT;
|
||||
|
||||
Size ksize = Size(3, 3);
|
||||
int bordertype = BORDER_CONSTANT;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(5);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src1, size, size, all_type[j], 0, 256);
|
||||
gen(dst, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::blur(oclSrc, oclDst, ksize, Point(-1, -1), bordertype);
|
||||
|
||||
blur(src1, dst, ksize, Point(-1, -1), bordertype);
|
||||
|
||||
CPU_ON;
|
||||
blur(src1, dst, ksize, Point(-1, -1), bordertype);
|
||||
CPU_OFF;
|
||||
|
||||
d_src1.upload(src1);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src1.upload(src1);
|
||||
ocl::blur(d_src1, d_dst, ksize, Point(-1, -1), bordertype);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1.0);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, 1 + DBL_EPSILON);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::blur(src, dst, ksize, Point(-1, -1), bordertype);
|
||||
|
||||
SANITY_CHECK(dst, 1 + DBL_EPSILON);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// Laplacian////////////////////////
|
||||
PERFTEST(Laplacian)
|
||||
|
||||
typedef BlurMatType LaplacianMatType;
|
||||
typedef tuple<Size, LaplacianMatType> LaplacianParams;
|
||||
typedef TestBaseWithParam<LaplacianParams> LaplacianFixture;
|
||||
|
||||
PERF_TEST_P(LaplacianFixture, Laplacian,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
LaplacianMatType::all()))
|
||||
{
|
||||
Mat src1, dst, ocl_dst;
|
||||
ocl::oclMat d_src1, d_dst;
|
||||
// getting params
|
||||
LaplacianParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), ksize = 3;
|
||||
|
||||
int ksize = 3;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(6);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src1, size, size, all_type[j], 0, 256);
|
||||
gen(dst, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::Laplacian(oclSrc, oclDst, -1, ksize, 1);
|
||||
|
||||
Laplacian(src1, dst, -1, ksize, 1);
|
||||
|
||||
CPU_ON;
|
||||
Laplacian(src1, dst, -1, ksize, 1);
|
||||
CPU_OFF;
|
||||
|
||||
d_src1.upload(src1);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::Laplacian(d_src1, d_dst, -1, ksize, 1);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::Laplacian(d_src1, d_dst, -1, ksize, 1);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src1.upload(src1);
|
||||
ocl::Laplacian(d_src1, d_dst, -1, ksize, 1);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1e-5);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::Laplacian(src, dst, -1, ksize, 1);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// Erode ////////////////////
|
||||
PERFTEST(Erode)
|
||||
|
||||
CV_ENUM(ErodeMatType, CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4)
|
||||
|
||||
typedef tuple<Size, ErodeMatType> ErodeParams;
|
||||
typedef TestBaseWithParam<ErodeParams> ErodeFixture;
|
||||
|
||||
PERF_TEST_P(ErodeFixture, Erode,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
ErodeMatType::all()))
|
||||
{
|
||||
Mat src, dst, ker, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
// getting params
|
||||
ErodeParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), ksize = 3;
|
||||
const Mat ker = getStructuringElement(MORPH_RECT, Size(ksize, ksize));
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4", "CV_32FC1", "CV_32FC4"};
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst).in(ker);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(5);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKer(ker);
|
||||
|
||||
gen(src, size, size, all_type[j], Scalar::all(0), Scalar::all(256));
|
||||
ker = getStructuringElement(MORPH_RECT, Size(3, 3));
|
||||
TEST_CYCLE() cv::ocl::erode(oclSrc, oclDst, oclKer);
|
||||
|
||||
erode(src, dst, ker);
|
||||
|
||||
CPU_ON;
|
||||
erode(src, dst, ker);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::erode(d_src, d_dst, ker);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::erode(d_src, d_dst, ker);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::erode(d_src, d_dst, ker);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1e-5);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::erode(src, dst, ker);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// Sobel ////////////////////////
|
||||
PERFTEST(Sobel)
|
||||
|
||||
typedef BlurMatType SobelMatType;
|
||||
typedef tuple<Size, SobelMatType> SobelMatParams;
|
||||
typedef TestBaseWithParam<SobelMatParams> SobelFixture;
|
||||
|
||||
PERF_TEST_P(SobelFixture, Sobel,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
SobelMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
// getting params
|
||||
SobelMatParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), dx = 1, dy = 1;
|
||||
|
||||
int dx = 1;
|
||||
int dy = 1;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if ((srcSize == OCL_SIZE_2000 && type == CV_8UC4) ||
|
||||
(srcSize == OCL_SIZE_4000 && type == CV_8UC1))
|
||||
declare.time(5.5);
|
||||
else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(20);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::Sobel(oclSrc, oclDst, -1, dx, dy);
|
||||
|
||||
Sobel(src, dst, -1, dx, dy);
|
||||
|
||||
CPU_ON;
|
||||
Sobel(src, dst, -1, dx, dy);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::Sobel(d_src, d_dst, -1, dx, dy);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::Sobel(d_src, d_dst, -1, dx, dy);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::Sobel(d_src, d_dst, -1, dx, dy);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::Sobel(src, dst, -1, dx, dy);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// Scharr ////////////////////////
|
||||
PERFTEST(Scharr)
|
||||
|
||||
typedef BlurMatType ScharrMatType;
|
||||
typedef tuple<Size, ScharrMatType> ScharrParams;
|
||||
typedef TestBaseWithParam<ScharrParams> ScharrFixture;
|
||||
|
||||
PERF_TEST_P(ScharrFixture, Scharr,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
ScharrMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
// getting params
|
||||
ScharrParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), dx = 1, dy = 0;
|
||||
|
||||
int dx = 1;
|
||||
int dy = 0;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if ((srcSize == OCL_SIZE_2000 && type == CV_8UC4) ||
|
||||
(srcSize == OCL_SIZE_4000 && type == CV_8UC1))
|
||||
declare.time(5.5);
|
||||
else if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(21);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::Scharr(oclSrc, oclDst, -1, dx, dy);
|
||||
|
||||
Scharr(src, dst, -1, dx, dy);
|
||||
|
||||
CPU_ON;
|
||||
Scharr(src, dst, -1, dx, dy);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::Scharr(d_src, d_dst, -1, dx, dy);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::Scharr(d_src, d_dst, -1, dx, dy);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::Scharr(d_src, d_dst, -1, dx, dy);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::Scharr(src, dst, -1, dx, dy);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// GaussianBlur ////////////////////////
|
||||
PERFTEST(GaussianBlur)
|
||||
|
||||
typedef ErodeMatType GaussianBlurMatType;
|
||||
typedef tuple<Size, GaussianBlurMatType> GaussianBlurParams;
|
||||
typedef TestBaseWithParam<GaussianBlurParams> GaussianBlurFixture;
|
||||
|
||||
PERF_TEST_P(GaussianBlurFixture, GaussianBlur,
|
||||
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
|
||||
GaussianBlurMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4", "CV_32FC1", "CV_32FC4"};
|
||||
const int ksize = 7;
|
||||
// getting params
|
||||
GaussianBlurParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), ksize = 7;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
const double eps = src.depth() == CV_8U ? 1 + DBL_EPSILON : 3e-4;
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::GaussianBlur(oclSrc, oclDst, Size(ksize, ksize), 0);
|
||||
|
||||
GaussianBlur(src, dst, Size(ksize, ksize), 0);
|
||||
|
||||
CPU_ON;
|
||||
GaussianBlur(src, dst, Size(ksize, ksize), 0);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src);
|
||||
ocl::oclMat d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::GaussianBlur(d_src, d_dst, Size(ksize, ksize), 0);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::GaussianBlur(d_src, d_dst, Size(ksize, ksize), 0);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::GaussianBlur(d_src, d_dst, Size(ksize, ksize), 0);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1.0);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::GaussianBlur(src, dst, Size(ksize, ksize), 0);
|
||||
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// filter2D////////////////////////
|
||||
PERFTEST(filter2D)
|
||||
|
||||
typedef BlurMatType filter2DMatType;
|
||||
typedef tuple<Size, filter2DMatType> filter2DParams;
|
||||
typedef TestBaseWithParam<filter2DParams> filter2DFixture;
|
||||
|
||||
PERF_TEST_P(filter2DFixture, filter2D,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
filter2DMatType::all()))
|
||||
{
|
||||
Mat src;
|
||||
// getting params
|
||||
filter2DParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), ksize = 3;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type), kernel(ksize, ksize, CV_32SC1);
|
||||
declare.in(src, WARMUP_RNG).in(kernel).out(dst);
|
||||
randu(kernel, -3.0, 3.0);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC4)
|
||||
declare.time(8);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type), oclKernel(kernel);
|
||||
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
const int ksize = 3;
|
||||
|
||||
SUBTEST << "ksize = " << ksize << "; " << size << 'x' << size << "; " << type_name[j] ;
|
||||
|
||||
Mat kernel;
|
||||
gen(kernel, ksize, ksize, CV_32SC1, -3.0, 3.0);
|
||||
|
||||
Mat dst, ocl_dst;
|
||||
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
|
||||
CPU_ON;
|
||||
cv::filter2D(src, dst, -1, kernel);
|
||||
CPU_OFF;
|
||||
|
||||
ocl::oclMat d_src(src), d_dst;
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::filter2D(d_src, d_dst, -1, kernel);
|
||||
WARMUP_OFF;
|
||||
|
||||
GPU_ON;
|
||||
ocl::filter2D(d_src, d_dst, -1, kernel);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
ocl::filter2D(d_src, d_dst, -1, kernel);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, 1e-5);
|
||||
|
||||
}
|
||||
TEST_CYCLE() cv::ocl::filter2D(oclSrc, oclDst, -1, oclKernel);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::filter2D(src, dst, -1, kernel);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,46 +45,46 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// gemm ////////////////////////
|
||||
PERFTEST(gemm)
|
||||
|
||||
typedef TestBaseWithParam<Size> gemmFixture;
|
||||
|
||||
PERF_TEST_P(gemmFixture, DISABLED_gemm, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat src1, src2, src3, dst, ocl_dst;
|
||||
ocl::oclMat d_src1, d_src2, d_src3, d_dst;
|
||||
// getting params
|
||||
const Size srcSize = GetParam();
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
Mat src1(srcSize, CV_32FC1), src2(srcSize, CV_32FC1),
|
||||
src3(srcSize, CV_32FC1), dst(srcSize, CV_32FC1);
|
||||
declare.in(src1, src2, src3).out(dst);
|
||||
randu(src1, -10.0f, 10.0f);
|
||||
randu(src2, -10.0f, 10.0f);
|
||||
randu(src3, -10.0f, 10.0f);
|
||||
|
||||
if (impl == "ocl")
|
||||
{
|
||||
SUBTEST << size << 'x' << size;
|
||||
ocl::oclMat oclSrc1(src1), oclSrc2(src2),
|
||||
oclSrc3(src3), oclDst(srcSize, CV_32FC1);
|
||||
|
||||
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));
|
||||
TEST_CYCLE() cv::ocl::gemm(oclSrc1, oclSrc2, 1.0, oclSrc3, 1.0, oclDst);
|
||||
|
||||
gemm(src1, src2, 1.0, src3, 1.0, dst);
|
||||
oclDst.download(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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(ocl_dst, dst, src1.cols * src1.rows * 1e-4);
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -46,56 +46,54 @@
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
///////////// GoodFeaturesToTrack ////////////////////////
|
||||
PERFTEST(GoodFeaturesToTrack)
|
||||
|
||||
typedef tuple<string, double> GoodFeaturesToTrackParams;
|
||||
typedef TestBaseWithParam<GoodFeaturesToTrackParams> GoodFeaturesToTrackFixture;
|
||||
|
||||
PERF_TEST_P(GoodFeaturesToTrackFixture, GoodFeaturesToTrack,
|
||||
::testing::Combine(::testing::Values(string("gpu/opticalflow/rubberwhale1.png"),
|
||||
string("gpu/stereobm/aloe-L.png")),
|
||||
::testing::Range(0.0, 4.0, 3.0)))
|
||||
{
|
||||
using namespace cv;
|
||||
std::vector<cv::Point2f> pts_gold;
|
||||
|
||||
int maxCorners = 2000;
|
||||
double qualityLevel = 0.01;
|
||||
// getting params
|
||||
GoodFeaturesToTrackParams param = GetParam();
|
||||
const string fileName = getDataPath(get<0>(param)), impl = getSelectedImpl();
|
||||
const int maxCorners = 2000;
|
||||
const double qualityLevel = 0.01, minDistance = get<1>(param);
|
||||
|
||||
std::string images[] = { "rubberwhale1.png", "aloeL.jpg" };
|
||||
Mat frame = imread(fileName, IMREAD_GRAYSCALE);
|
||||
declare.in(frame);
|
||||
ASSERT_TRUE(!frame.empty()) << "no input image";
|
||||
|
||||
std::vector<cv::Point2f> pts_gold, pts_ocl;
|
||||
|
||||
for(size_t imgIdx = 0; imgIdx < (sizeof(images)/sizeof(std::string)); ++imgIdx)
|
||||
if (impl == "ocl")
|
||||
{
|
||||
Mat frame = imread(abspath(images[imgIdx]), IMREAD_GRAYSCALE);
|
||||
CV_Assert(!frame.empty());
|
||||
ocl::oclMat oclFrame(frame), pts_oclmat;
|
||||
cv::ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance);
|
||||
|
||||
for(float minDistance = 0; minDistance < 4; minDistance += 3.0)
|
||||
{
|
||||
SUBTEST << "image = " << images[imgIdx] << "; ";
|
||||
SUBTEST << "minDistance = " << minDistance << "; ";
|
||||
TEST_CYCLE() detector(oclFrame, pts_oclmat);
|
||||
|
||||
cv::goodFeaturesToTrack(frame, pts_gold, maxCorners, qualityLevel, minDistance);
|
||||
detector.downloadPoints(pts_oclmat, pts_gold);
|
||||
|
||||
CPU_ON;
|
||||
cv::goodFeaturesToTrack(frame, pts_gold, maxCorners, qualityLevel, minDistance);
|
||||
CPU_OFF;
|
||||
|
||||
cv::ocl::GoodFeaturesToTrackDetector_OCL detector(maxCorners, qualityLevel, minDistance);
|
||||
|
||||
ocl::oclMat frame_ocl(frame), pts_oclmat;
|
||||
|
||||
WARMUP_ON;
|
||||
detector(frame_ocl, pts_oclmat);
|
||||
WARMUP_OFF;
|
||||
|
||||
detector.downloadPoints(pts_oclmat, pts_ocl);
|
||||
|
||||
double diff = abs(static_cast<float>(pts_gold.size() - pts_ocl.size()));
|
||||
TestSystem::instance().setAccurate(diff == 0.0, diff);
|
||||
|
||||
GPU_ON;
|
||||
detector(frame_ocl, pts_oclmat);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
frame_ocl.upload(frame);
|
||||
detector(frame_ocl, pts_oclmat);
|
||||
detector.downloadPoints(pts_oclmat, pts_ocl);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
SANITY_CHECK(pts_gold);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::goodFeaturesToTrack(frame, pts_gold,
|
||||
maxCorners, qualityLevel, minDistance);
|
||||
|
||||
SANITY_CHECK(pts_gold);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,6 +45,8 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// Haar ////////////////////////
|
||||
namespace cv
|
||||
{
|
||||
@ -83,61 +85,45 @@ public:
|
||||
|
||||
}
|
||||
}
|
||||
PERFTEST(Haar)
|
||||
|
||||
PERF_TEST(HaarFixture, 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");
|
||||
}
|
||||
|
||||
const std::string impl = getSelectedImpl();
|
||||
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;
|
||||
Mat img = imread(getDataPath("gpu/haarcascade/basketball1.png"), CV_LOAD_IMAGE_GRAYSCALE);
|
||||
ASSERT_TRUE(!img.empty()) << "can't open basketball1.png";
|
||||
declare.in(img);
|
||||
|
||||
|
||||
vector<Rect> oclfaces;
|
||||
ocl::CascadeClassifier_GPU faceCascade;
|
||||
|
||||
if (!faceCascade.load(abspath("haarcascade_frontalface_alt.xml")))
|
||||
if (impl == "plain")
|
||||
{
|
||||
throw runtime_error("can't load haarcascade_frontalface_alt.xml");
|
||||
CascadeClassifier faceCascade;
|
||||
ASSERT_TRUE(faceCascade.load(getDataPath("gpu/haarcascade/haarcascade_frontalface_alt.xml")))
|
||||
<< "can't load haarcascade_frontalface_alt.xml";
|
||||
|
||||
TEST_CYCLE() faceCascade.detectMultiScale(img, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
|
||||
SANITY_CHECK(faces, 4 + 1e-4);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
ocl::CascadeClassifier_GPU faceCascade;
|
||||
ocl::oclMat oclImg(img);
|
||||
|
||||
ASSERT_TRUE(faceCascade.load(getDataPath("gpu/haarcascade/haarcascade_frontalface_alt.xml")))
|
||||
<< "can't load haarcascade_frontalface_alt.xml";
|
||||
|
||||
TEST_CYCLE() faceCascade.detectMultiScale(oclImg, faces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
|
||||
SANITY_CHECK(faces, 4 + 1e-4);
|
||||
}
|
||||
|
||||
ocl::oclMat d_img(img);
|
||||
|
||||
WARMUP_ON;
|
||||
faceCascade.detectMultiScale(d_img, oclfaces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
WARMUP_OFF;
|
||||
|
||||
if(faces.size() == oclfaces.size())
|
||||
TestSystem::instance().setAccurate(1, 0);
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, abs((int)faces.size() - (int)oclfaces.size()));
|
||||
|
||||
faces.clear();
|
||||
|
||||
GPU_ON;
|
||||
faceCascade.detectMultiScale(d_img, oclfaces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_img.upload(img);
|
||||
faceCascade.detectMultiScale(d_img, oclfaces,
|
||||
1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
|
||||
GPU_FULL_OFF;
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,50 +45,42 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
|
||||
///////////// HOG////////////////////////
|
||||
|
||||
PERFTEST(HOG)
|
||||
PERF_TEST(HOGFixture, HOG)
|
||||
{
|
||||
Mat src = imread(abspath("road.png"), cv::IMREAD_GRAYSCALE);
|
||||
Mat src = imread(getDataPath("gpu/hog/road.png"), cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_TRUE(!src.empty()) << "can't open input image road.png";
|
||||
|
||||
if (src.empty())
|
||||
{
|
||||
throw runtime_error("can't open road.png");
|
||||
}
|
||||
|
||||
cv::HOGDescriptor hog;
|
||||
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||
const std::string impl = getSelectedImpl();
|
||||
std::vector<cv::Rect> found_locations;
|
||||
std::vector<cv::Rect> d_found_locations;
|
||||
declare.in(src).time(5);
|
||||
|
||||
SUBTEST << src.cols << 'x' << src.rows << "; road.png";
|
||||
if (impl == "plain")
|
||||
{
|
||||
cv::HOGDescriptor hog;
|
||||
hog.setSVMDetector(hog.getDefaultPeopleDetector());
|
||||
|
||||
hog.detectMultiScale(src, found_locations);
|
||||
TEST_CYCLE() hog.detectMultiScale(src, found_locations);
|
||||
|
||||
CPU_ON;
|
||||
hog.detectMultiScale(src, found_locations);
|
||||
CPU_OFF;
|
||||
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
cv::ocl::HOGDescriptor ocl_hog;
|
||||
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector());
|
||||
ocl::oclMat oclSrc(src);
|
||||
|
||||
cv::ocl::HOGDescriptor ocl_hog;
|
||||
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector());
|
||||
ocl::oclMat d_src;
|
||||
d_src.upload(src);
|
||||
TEST_CYCLE() ocl_hog.detectMultiScale(oclSrc, found_locations);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl_hog.detectMultiScale(d_src, d_found_locations);
|
||||
WARMUP_OFF;
|
||||
|
||||
if(d_found_locations.size() == found_locations.size())
|
||||
TestSystem::instance().setAccurate(1, 0);
|
||||
SANITY_CHECK(found_locations, 1 + DBL_EPSILON);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, abs((int)found_locations.size() - (int)d_found_locations.size()));
|
||||
|
||||
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;
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,101 +45,97 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
/////////// 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);
|
||||
//}
|
||||
PERFTEST(matchTemplate)
|
||||
|
||||
CV_ENUM(CV_TM_CCORRMatType, CV_32FC1, CV_32FC4)
|
||||
|
||||
typedef tuple<Size, CV_TM_CCORRMatType> CV_TM_CCORRParams;
|
||||
typedef TestBaseWithParam<CV_TM_CCORRParams> CV_TM_CCORRFixture;
|
||||
|
||||
PERF_TEST_P(CV_TM_CCORRFixture, matchTemplate,
|
||||
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
|
||||
CV_TM_CCORRMatType::all()))
|
||||
{
|
||||
//InitMatchTemplate();
|
||||
Mat src, templ, dst, ocl_dst;
|
||||
int templ_size = 5;
|
||||
// getting params
|
||||
CV_TM_CCORRParams params = GetParam();
|
||||
const Size srcSize = get<0>(params), templSize(5, 5);
|
||||
const int type = get<1>(params);
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
// creating src data
|
||||
Mat src(srcSize, type), templ(templSize, type);
|
||||
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
|
||||
Mat dst(dstSize, CV_32F);
|
||||
randu(src, 0.0f, 1.0f);
|
||||
randu(templ, 0.0f, 1.0f);
|
||||
declare.time(srcSize == OCL_SIZE_2000 ? 20 : 6).in(src, templ).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
int all_type[] = {CV_32FC1, CV_32FC4};
|
||||
std::string type_name[] = {"CV_32FC1", "CV_32FC4"};
|
||||
ocl::oclMat oclSrc(src), oclTempl(templ), oclDst(dstSize, CV_32F);
|
||||
|
||||
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);
|
||||
TEST_CYCLE() cv::ocl::matchTemplate(oclSrc, oclTempl, oclDst, CV_TM_CCORR);
|
||||
|
||||
SUBTEST << src.cols << 'x' << src.rows << "; " << type_name[j] << "; templ " << templ_size << 'x' << templ_size << "; CCORR";
|
||||
oclDst.download(dst);
|
||||
|
||||
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(templ), d_dst;
|
||||
|
||||
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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, templ.rows * templ.cols * 1e-1);
|
||||
}
|
||||
}
|
||||
|
||||
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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, templ.rows * templ.cols * 1e-1);
|
||||
}
|
||||
}
|
||||
SANITY_CHECK(dst, 1e-4);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR);
|
||||
|
||||
SANITY_CHECK(dst, 1e-4);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
typedef TestBaseWithParam<Size> CV_TM_CCORR_NORMEDFixture;
|
||||
|
||||
PERF_TEST_P(CV_TM_CCORR_NORMEDFixture, matchTemplate, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
// getting params
|
||||
const Size srcSize = GetParam(), templSize(5, 5);
|
||||
const std::string impl = getSelectedImpl();
|
||||
|
||||
// creating src data
|
||||
Mat src(srcSize, CV_8UC1), templ(templSize, CV_8UC1), dst;
|
||||
const Size dstSize(src.cols - templ.cols + 1, src.rows - templ.rows + 1);
|
||||
dst.create(dstSize, CV_8UC1);
|
||||
declare.in(src, templ, WARMUP_RNG).out(dst)
|
||||
.time(srcSize == OCL_SIZE_2000 ? 10 : srcSize == OCL_SIZE_4000 ? 23 : 2);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
ocl::oclMat oclSrc(src), oclTempl(templ), oclDst(dstSize, CV_8UC1);
|
||||
|
||||
TEST_CYCLE() cv::ocl::matchTemplate(oclSrc, oclTempl, oclDst, CV_TM_CCORR_NORMED);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, 2e-2);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::matchTemplate(src, templ, dst, CV_TM_CCORR_NORMED);
|
||||
|
||||
SANITY_CHECK(dst, 2e-2);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,142 +45,147 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
///////////// ConvertTo////////////////////////
|
||||
PERFTEST(ConvertTo)
|
||||
|
||||
CV_ENUM(ConvertToMatType, CV_8UC1, CV_8UC4)
|
||||
|
||||
typedef tuple<Size, ConvertToMatType> ConvertToParams;
|
||||
typedef TestBaseWithParam<ConvertToParams> ConvertToFixture;
|
||||
|
||||
PERF_TEST_P(ConvertToFixture, ConvertTo,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
ConvertToMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
// getting params
|
||||
ConvertToParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
Mat src(srcSize, type), dst;
|
||||
const int dstType = CV_MAKE_TYPE(CV_32F, src.channels());
|
||||
dst.create(srcSize, dstType);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] << " to 32FC1";
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, dstType);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
//gen(dst, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() oclSrc.convertTo(oclDst, dstType);
|
||||
|
||||
//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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 0.0);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() src.convertTo(dst, dstType);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// copyTo////////////////////////
|
||||
PERFTEST(copyTo)
|
||||
|
||||
typedef ConvertToMatType copyToMatType;
|
||||
typedef tuple<Size, copyToMatType> copyToParams;
|
||||
typedef TestBaseWithParam<copyToParams> copyToFixture;
|
||||
|
||||
PERF_TEST_P(copyToFixture, copyTo,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
copyToMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
ocl::oclMat d_src, d_dst;
|
||||
// getting params
|
||||
copyToParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
//gen(dst, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() oclSrc.copyTo(oclDst);
|
||||
|
||||
//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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 0.0);
|
||||
}
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() src.copyTo(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// setTo////////////////////////
|
||||
PERFTEST(setTo)
|
||||
|
||||
typedef ConvertToMatType setToMatType;
|
||||
typedef tuple<Size, setToMatType> setToParams;
|
||||
typedef TestBaseWithParam<setToParams> setToFixture;
|
||||
|
||||
PERF_TEST_P(setToFixture, setTo,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
setToMatType::all()))
|
||||
{
|
||||
Mat src, ocl_src;
|
||||
Scalar val(1, 2, 3, 4);
|
||||
ocl::oclMat d_src;
|
||||
// getting params
|
||||
setToParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
const Scalar val(1, 2, 3, 4);
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
Mat src(srcSize, type);
|
||||
declare.in(src);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(srcSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
src.setTo(val);
|
||||
|
||||
CPU_ON;
|
||||
src.setTo(val);
|
||||
CPU_OFF;
|
||||
|
||||
d_src.upload(src);
|
||||
|
||||
WARMUP_ON;
|
||||
d_src.setTo(val);
|
||||
WARMUP_OFF;
|
||||
|
||||
d_src.download(ocl_src);
|
||||
TestSystem::instance().ExpectedMatNear(src, ocl_src, 1.0);
|
||||
|
||||
GPU_ON;;
|
||||
d_src.setTo(val);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src.upload(src);
|
||||
d_src.setTo(val);
|
||||
GPU_FULL_OFF;
|
||||
}
|
||||
TEST_CYCLE() oclSrc.setTo(val);
|
||||
oclSrc.download(src);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() src.setTo(val);
|
||||
|
||||
SANITY_CHECK(src);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -43,50 +43,59 @@
|
||||
// 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;
|
||||
|
||||
///////////// Moments ////////////////////////
|
||||
PERFTEST(Moments)
|
||||
|
||||
CV_ENUM(MomentsMatType, CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1)
|
||||
|
||||
typedef tuple<Size, MomentsMatType> MomentsParams;
|
||||
typedef TestBaseWithParam<MomentsParams> MomentsFixture;
|
||||
|
||||
PERF_TEST_P(MomentsFixture, DISABLED_Moments,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
MomentsMatType::all()))
|
||||
{
|
||||
Mat src;
|
||||
bool binaryImage = 0;
|
||||
// getting params
|
||||
MomentsParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
int all_type[] = {CV_8UC1, CV_16SC1, CV_32FC1, CV_64FC1};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_16SC1", "CV_32FC1", "CV_64FC1"};
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
Mat src(srcSize, type), dst(7, 1, CV_64F);
|
||||
const bool binaryImage = false;
|
||||
cv::Moments mom;
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j];
|
||||
ocl::oclMat oclSrc(src);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
|
||||
cv::Moments CvMom = moments(src, binaryImage);
|
||||
|
||||
CPU_ON;
|
||||
moments(src, binaryImage);
|
||||
CPU_OFF;
|
||||
|
||||
cv::Moments oclMom;
|
||||
WARMUP_ON;
|
||||
oclMom = ocl::ocl_moments(src, binaryImage);
|
||||
WARMUP_OFF;
|
||||
|
||||
Mat gpu_dst, cpu_dst;
|
||||
HuMoments(CvMom, cpu_dst);
|
||||
HuMoments(oclMom, gpu_dst);
|
||||
|
||||
GPU_ON;
|
||||
ocl::ocl_moments(src, binaryImage);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
ocl::ocl_moments(src, binaryImage);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(gpu_dst, cpu_dst, .5);
|
||||
|
||||
}
|
||||
TEST_CYCLE() mom = cv::ocl::ocl_moments(oclSrc, binaryImage);
|
||||
cv::HuMoments(mom, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() mom = cv::moments(src, binaryImage);
|
||||
cv::HuMoments(mom, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,43 +45,46 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
///////////// norm////////////////////////
|
||||
PERFTEST(norm)
|
||||
|
||||
typedef TestBaseWithParam<Size> normFixture;
|
||||
|
||||
PERF_TEST_P(normFixture, DISABLED_norm, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
Mat src1, src2, ocl_src1;
|
||||
ocl::oclMat d_src1, d_src2;
|
||||
// getting params
|
||||
const Size srcSize = GetParam();
|
||||
const std::string impl = getSelectedImpl();
|
||||
double value = 0.0;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
Mat src1(srcSize, CV_8UC1), src2(srcSize, CV_8UC1);
|
||||
declare.in(src1, src2);
|
||||
randu(src1, 0, 1);
|
||||
randu(src2, 0, 1);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; CV_8UC1; NORM_INF";
|
||||
ocl::oclMat oclSrc1(src1), oclSrc2(src2);
|
||||
|
||||
gen(src1, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1));
|
||||
gen(src2, size, size, CV_8UC1, Scalar::all(0), Scalar::all(1));
|
||||
TEST_CYCLE() value = cv::ocl::norm(oclSrc1, oclSrc2, NORM_INF);
|
||||
|
||||
norm(src1, src2, NORM_INF);
|
||||
|
||||
CPU_ON;
|
||||
norm(src1, src2, NORM_INF);
|
||||
CPU_OFF;
|
||||
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
|
||||
WARMUP_ON;
|
||||
ocl::norm(d_src1, d_src2, NORM_INF);
|
||||
WARMUP_OFF;
|
||||
|
||||
d_src1.download(ocl_src1);
|
||||
TestSystem::instance().ExpectedMatNear(src1, ocl_src1, .5);
|
||||
|
||||
GPU_ON;
|
||||
ocl::norm(d_src1, d_src2, NORM_INF);
|
||||
GPU_OFF;
|
||||
|
||||
GPU_FULL_ON;
|
||||
d_src1.upload(src1);
|
||||
d_src2.upload(src2);
|
||||
ocl::norm(d_src1, d_src2, NORM_INF);
|
||||
GPU_FULL_OFF;
|
||||
SANITY_CHECK(value);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() value = cv::norm(src1, src2, NORM_INF);
|
||||
|
||||
SANITY_CHECK(value);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -46,117 +46,130 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
///////////// PyrLKOpticalFlow ////////////////////////
|
||||
PERFTEST(PyrLKOpticalFlow)
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::get;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::make_tuple;
|
||||
|
||||
template <typename T>
|
||||
static vector<T> & MatToVector(const ocl::oclMat & oclSrc, vector<T> & instance)
|
||||
{
|
||||
std::string images1[] = {"rubberwhale1.png", "aloeL.jpg"};
|
||||
std::string images2[] = {"rubberwhale2.png", "aloeR.jpg"};
|
||||
Mat src;
|
||||
oclSrc.download(src);
|
||||
|
||||
for (size_t i = 0; i < sizeof(images1) / sizeof(std::string); i++)
|
||||
for (int i = 0; i < src.cols; ++i)
|
||||
instance.push_back(src.at<T>(0, i));
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
CV_ENUM(LoadMode, IMREAD_GRAYSCALE, IMREAD_COLOR)
|
||||
|
||||
typedef tuple<int, tuple<string, string, LoadMode> > PyrLKOpticalFlowParamType;
|
||||
typedef TestBaseWithParam<PyrLKOpticalFlowParamType> PyrLKOpticalFlowFixture;
|
||||
|
||||
PERF_TEST_P(PyrLKOpticalFlowFixture,
|
||||
PyrLKOpticalFlow,
|
||||
::testing::Combine(
|
||||
::testing::Values(1000, 2000, 4000),
|
||||
::testing::Values(
|
||||
make_tuple<string, string, LoadMode>
|
||||
(
|
||||
string("gpu/opticalflow/rubberwhale1.png"),
|
||||
string("gpu/opticalflow/rubberwhale1.png"),
|
||||
LoadMode(IMREAD_COLOR)
|
||||
)
|
||||
// , make_tuple<string, string, LoadMode>
|
||||
// (
|
||||
// string("gpu/stereobm/aloe-L.png"),
|
||||
// string("gpu/stereobm/aloe-R.png"),
|
||||
// LoadMode(IMREAD_GRAYSCALE)
|
||||
// )
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
PyrLKOpticalFlowParamType params = GetParam();
|
||||
tuple<string, string, LoadMode> fileParam = get<1>(params);
|
||||
const int pointsCount = get<0>(params);
|
||||
const int openMode = static_cast<int>(get<2>(fileParam));
|
||||
const string fileName0 = get<0>(fileParam), fileName1 = get<1>(fileParam);
|
||||
Mat frame0 = imread(getDataPath(fileName0), openMode);
|
||||
Mat frame1 = imread(getDataPath(fileName1), openMode);
|
||||
const string impl = getSelectedImpl();
|
||||
|
||||
ASSERT_FALSE(frame0.empty()) << "can't load " << fileName0;
|
||||
ASSERT_FALSE(frame1.empty()) << "can't load " << fileName1;
|
||||
|
||||
Mat grayFrame;
|
||||
if (openMode == IMREAD_COLOR)
|
||||
cvtColor(frame0, grayFrame, COLOR_BGR2GRAY);
|
||||
else
|
||||
grayFrame = frame0;
|
||||
|
||||
// initialization
|
||||
vector<Point2f> pts, nextPts;
|
||||
vector<unsigned char> status;
|
||||
vector<float> err;
|
||||
goodFeaturesToTrack(grayFrame, pts, pointsCount, 0.01, 0.0);
|
||||
|
||||
// selecting implementation
|
||||
if (impl == "plain")
|
||||
{
|
||||
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 ocl_nextPts;
|
||||
Mat ocl_status;
|
||||
|
||||
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(ocl_nextPts);
|
||||
|
||||
if (!d_status.empty())
|
||||
d_status.download(ocl_status);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
size_t mismatch = 0;
|
||||
for (int i = 0; i < (int)nextPts.size(); ++i)
|
||||
{
|
||||
if(status[i] != ocl_status.at<unsigned char>(0, i))
|
||||
{
|
||||
mismatch++;
|
||||
continue;
|
||||
}
|
||||
if(status[i])
|
||||
{
|
||||
Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i);
|
||||
Point2f cpu_rst = nextPts[i];
|
||||
if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.)
|
||||
mismatch++;
|
||||
}
|
||||
}
|
||||
double ratio = (double)mismatch / (double)nextPts.size();
|
||||
if(ratio < .02)
|
||||
TestSystem::instance().setAccurate(1, ratio);
|
||||
else
|
||||
TestSystem::instance().setAccurate(0, ratio);
|
||||
}
|
||||
TEST_CYCLE()
|
||||
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, err);
|
||||
|
||||
SANITY_CHECK(nextPts);
|
||||
SANITY_CHECK(status);
|
||||
SANITY_CHECK(err);
|
||||
}
|
||||
else if (impl == "ocl")
|
||||
{
|
||||
ocl::PyrLKOpticalFlow oclPyrLK;
|
||||
ocl::oclMat oclFrame0(frame0), oclFrame1(frame1);
|
||||
ocl::oclMat oclPts(1, static_cast<int>(pts.size()), CV_32FC2, (void *)&pts[0]);
|
||||
ocl::oclMat oclNextPts, oclStatus, oclErr;
|
||||
|
||||
TEST_CYCLE()
|
||||
oclPyrLK.sparse(oclFrame0, oclFrame1, oclPts, oclNextPts, oclStatus, &oclErr);
|
||||
|
||||
MatToVector(oclNextPts, nextPts);
|
||||
MatToVector(oclStatus, status);
|
||||
MatToVector(oclErr, err);
|
||||
|
||||
SANITY_CHECK(nextPts);
|
||||
SANITY_CHECK(status);
|
||||
SANITY_CHECK(err);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
|
||||
// size_t mismatch = 0;
|
||||
// for (int i = 0; i < (int)nextPts.size(); ++i)
|
||||
// {
|
||||
// if(status[i] != ocl_status.at<unsigned char>(0, i))
|
||||
// {
|
||||
// mismatch++;
|
||||
// continue;
|
||||
// }
|
||||
// if(status[i])
|
||||
// {
|
||||
// Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i);
|
||||
// Point2f cpu_rst = nextPts[i];
|
||||
// if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.)
|
||||
// mismatch++;
|
||||
// }
|
||||
// }
|
||||
// double ratio = (double)mismatch / (double)nextPts.size();
|
||||
// if(ratio < .02)
|
||||
// TestSystem::instance().setAccurate(1, ratio);
|
||||
// else
|
||||
// TestSystem::instance().setAccurate(0, ratio);
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,6 +40,15 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# pragma GCC diagnostic ignored "-Wunused-function"
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_PERF_PRECOMP_HPP__
|
||||
#define __OPENCV_PERF_PRECOMP_HPP__
|
||||
|
||||
@ -50,6 +59,7 @@
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
@ -59,9 +69,12 @@
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/ocl/ocl.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
#include "opencv2/ts/ts_gtest.h"
|
||||
|
||||
#define OCL_SIZE_1000 cv::Size(1000, 1000)
|
||||
#define OCL_SIZE_2000 cv::Size(2000, 2000)
|
||||
#define OCL_SIZE_4000 cv::Size(4000, 4000)
|
||||
|
||||
#define OCL_TYPICAL_MAT_SIZES ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000, OCL_SIZE_4000)
|
||||
|
||||
#define Min_Size 1000
|
||||
#define Max_Size 4000
|
||||
@ -76,15 +89,15 @@ void gen(Mat &mat, int rows, int cols, int type, int low, int high, int n);
|
||||
|
||||
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);
|
||||
//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);
|
||||
|
||||
|
||||
template<class T1, class T2>
|
||||
|
@ -45,88 +45,103 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
///////////// pyrDown //////////////////////
|
||||
PERFTEST(pyrDown)
|
||||
|
||||
CV_ENUM(pyrDownMatType, CV_8UC1, CV_8UC4)
|
||||
|
||||
typedef tuple<Size, pyrDownMatType> pyrDownParams;
|
||||
typedef TestBaseWithParam<pyrDownParams> pyrDownFixture;
|
||||
|
||||
PERF_TEST_P(pyrDownFixture, pyrDown,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
pyrDownMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
// getting params
|
||||
pyrDownParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
// creating src data
|
||||
Mat src(srcSize, type), dst;
|
||||
Size dstSize((srcSize.height + 1) >> 1, (srcSize.width + 1) >> 1);
|
||||
dst.create(dstSize, type);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(dstSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::pyrDown(oclSrc, oclDst);
|
||||
|
||||
pyrDown(src, dst);
|
||||
oclDst.download(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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, dst.depth() == CV_32F ? 1e-4f : 1.0f);
|
||||
}
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::pyrDown(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// pyrUp ////////////////////////
|
||||
PERFTEST(pyrUp)
|
||||
|
||||
typedef pyrDownMatType pyrUpMatType;
|
||||
typedef tuple<Size, pyrUpMatType> pyrUpParams;
|
||||
typedef TestBaseWithParam<pyrUpParams> pyrUpFixture;
|
||||
|
||||
PERF_TEST_P(pyrUpFixture, pyrUp,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
pyrUpMatType::all()))
|
||||
{
|
||||
Mat src, dst, ocl_dst;
|
||||
int all_type[] = {CV_8UC1, CV_8UC4};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
|
||||
// getting params
|
||||
pyrUpParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
|
||||
for (int size = 500; size <= 2000; size *= 2)
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
// creating src data
|
||||
Mat src(srcSize, type), dst;
|
||||
Size dstSize(srcSize.height << 1, srcSize.width << 1);
|
||||
dst.create(dstSize, type);
|
||||
declare.in(src).out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j] ;
|
||||
ocl::oclMat oclSrc(src), oclDst(dstSize, type);
|
||||
|
||||
gen(src, size, size, all_type[j], 0, 256);
|
||||
TEST_CYCLE() cv::ocl::pyrDown(oclSrc, oclDst);
|
||||
|
||||
pyrUp(src, dst);
|
||||
oclDst.download(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(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, (src.depth() == CV_32F ? 1e-4f : 1.0));
|
||||
}
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::pyrDown(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
@ -45,110 +45,120 @@
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
///////////// Merge////////////////////////
|
||||
PERFTEST(Merge)
|
||||
|
||||
CV_ENUM(MergeMatType, CV_8U, CV_32F)
|
||||
|
||||
typedef tuple<Size, MergeMatType> MergeParams;
|
||||
typedef TestBaseWithParam<MergeParams> MergeFixture;
|
||||
|
||||
PERF_TEST_P(MergeFixture, Merge,
|
||||
::testing::Combine(::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000),
|
||||
MergeMatType::all()))
|
||||
{
|
||||
Mat dst, ocl_dst;
|
||||
ocl::oclMat d_dst;
|
||||
// getting params
|
||||
MergeParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), channels = 3;
|
||||
|
||||
int channels = 4;
|
||||
int all_type[] = {CV_8UC1, CV_32FC1};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
// creating src data
|
||||
const int dstType = CV_MAKE_TYPE(depth, channels);
|
||||
Mat dst(srcSize, dstType);
|
||||
vector<Mat> src(channels);
|
||||
for (vector<Mat>::iterator i = src.begin(), end = src.end(); i != end; ++i)
|
||||
{
|
||||
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);
|
||||
|
||||
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, all_type[j], cv::Scalar::all(i));
|
||||
}
|
||||
ocl::merge(d_src, d_dst);
|
||||
d_dst.download(ocl_dst);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 0.0);
|
||||
}
|
||||
|
||||
i->create(srcSize, CV_MAKE_TYPE(depth, 1));
|
||||
declare.in(*i, WARMUP_RNG);
|
||||
}
|
||||
declare.out(dst);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
ocl::oclMat oclDst(srcSize, dstType);
|
||||
vector<ocl::oclMat> oclSrc(src.size());
|
||||
for (vector<ocl::oclMat>::size_type i = 0, end = src.size(); i < end; ++i)
|
||||
oclSrc[i] = src[i];
|
||||
|
||||
TEST_CYCLE() cv::ocl::merge(oclSrc, oclDst);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
TEST_CYCLE() cv::merge(src, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
||||
///////////// Split////////////////////////
|
||||
PERFTEST(Split)
|
||||
|
||||
typedef MergeMatType SplitMatType;
|
||||
typedef tuple<Size, SplitMatType> SplitParams;
|
||||
typedef TestBaseWithParam<SplitParams> SplitFixture;
|
||||
|
||||
PERF_TEST_P(SplitFixture, Split,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
SplitMatType::all()))
|
||||
{
|
||||
//int channels = 4;
|
||||
int all_type[] = {CV_8UC1, CV_32FC1};
|
||||
std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
|
||||
// getting params
|
||||
MergeParams params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int depth = get<1>(params), channels = 3;
|
||||
|
||||
for (int size = Min_Size; size <= Max_Size; size *= Multiple)
|
||||
std::string impl = getSelectedImpl();
|
||||
|
||||
// creating src data
|
||||
Mat src(srcSize, CV_MAKE_TYPE(depth, channels));
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
// select implementation
|
||||
if (impl == "ocl")
|
||||
{
|
||||
for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
|
||||
{
|
||||
SUBTEST << size << 'x' << size << "; " << type_name[j];
|
||||
Size size1 = Size(size, size);
|
||||
ocl::oclMat oclSrc(src);
|
||||
vector<ocl::oclMat> oclDst(channels, ocl::oclMat(srcSize, CV_MAKE_TYPE(depth, 1)));
|
||||
|
||||
Mat src(size1, CV_MAKE_TYPE(all_type[j], 4), cv::Scalar(1, 2, 3, 4));
|
||||
|
||||
std::vector<cv::Mat> dst, ocl_dst(4);
|
||||
|
||||
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);
|
||||
for(size_t i = 0; i < dst.size(); i++)
|
||||
d_dst[i].download(ocl_dst[i]);
|
||||
GPU_FULL_OFF;
|
||||
|
||||
vector<double> eps(4, 0.);
|
||||
TestSystem::instance().ExpectMatsNear(dst, ocl_dst, eps);
|
||||
}
|
||||
TEST_CYCLE() cv::ocl::split(oclSrc, oclDst);
|
||||
|
||||
AssertEQ(channels, 3);
|
||||
Mat dst0, dst1, dst2;
|
||||
oclDst[0].download(dst0);
|
||||
oclDst[1].download(dst1);
|
||||
oclDst[2].download(dst2);
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
SANITY_CHECK(dst2);
|
||||
}
|
||||
else if (impl == "plain")
|
||||
{
|
||||
vector<Mat> dst(channels, Mat(srcSize, CV_MAKE_TYPE(depth, 1)));
|
||||
TEST_CYCLE() cv::split(src, dst);
|
||||
|
||||
AssertEQ(channels, 3);
|
||||
Mat & dst0 = dst[0], & dst1 = dst[1], & dst2 = dst[2];
|
||||
SANITY_CHECK(dst0);
|
||||
SANITY_CHECK(dst1);
|
||||
SANITY_CHECK(dst2);
|
||||
}
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
else if (impl == "gpu")
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
#endif
|
||||
else
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user