parent
3fb3851c7a
commit
0fdb55a54d
24 changed files with 3025 additions and 1822 deletions
@ -0,0 +1,122 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors as is and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
|
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
PARAM_TEST_CASE(Blend, MatType, int) |
||||||
|
{ |
||||||
|
int type; |
||||||
|
int channels; |
||||||
|
std::vector<cv::ocl::Info> oclinfo; |
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
|
||||||
|
type = GET_PARAM(0); |
||||||
|
channels = GET_PARAM(1); |
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
//cv::ocl::setBinpath(CLBINPATH);
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(Blend, Performance) |
||||||
|
{ |
||||||
|
cv::Size size(MWIDTH, MHEIGHT); |
||||||
|
cv::Mat img1_host = randomMat(size, CV_MAKETYPE(type, channels), 0, type == CV_8U ? 255.0 : 1.0); |
||||||
|
cv::Mat img2_host = randomMat(size, CV_MAKETYPE(type, channels), 0, type == CV_8U ? 255.0 : 1.0); |
||||||
|
cv::Mat weights1 = randomMat(size, CV_32F, 0, 1); |
||||||
|
cv::Mat weights2 = randomMat(size, CV_32F, 0, 1); |
||||||
|
cv::ocl::oclMat gimg1(size, CV_MAKETYPE(type, channels)), gimg2(size, CV_MAKETYPE(type, channels)), gweights1(size, CV_32F), gweights2(size, CV_32F); |
||||||
|
cv::ocl::oclMat gdst(size, CV_MAKETYPE(type, channels)); |
||||||
|
|
||||||
|
|
||||||
|
double totalgputick_all = 0; |
||||||
|
double totalgputick_kernel = 0; |
||||||
|
double t1 = 0; |
||||||
|
double t2 = 0; |
||||||
|
|
||||||
|
for (int j = 0; j < LOOP_TIMES + 1; j ++) //LOOP_TIMES=100
|
||||||
|
{ |
||||||
|
t1 = (double)cvGetTickCount(); |
||||||
|
cv::ocl::oclMat gimg1 = cv::ocl::oclMat(img1_host); |
||||||
|
cv::ocl::oclMat gimg2 = cv::ocl::oclMat(img2_host); |
||||||
|
cv::ocl::oclMat gweights1 = cv::ocl::oclMat(weights1); |
||||||
|
cv::ocl::oclMat gweights2 = cv::ocl::oclMat(weights1); |
||||||
|
|
||||||
|
t2 = (double)cvGetTickCount(); |
||||||
|
cv::ocl::blendLinear(gimg1, gimg2, gweights1, gweights2, gdst); |
||||||
|
t2 = (double)cvGetTickCount() - t2; |
||||||
|
|
||||||
|
cv::Mat m; |
||||||
|
gdst.download(m); |
||||||
|
t1 = (double)cvGetTickCount() - t1; |
||||||
|
|
||||||
|
if (j == 0) |
||||||
|
{ |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
totalgputick_all = t1 + totalgputick_all; |
||||||
|
totalgputick_kernel = t2 + totalgputick_kernel; |
||||||
|
}; |
||||||
|
|
||||||
|
cout << "average gpu total runtime is " << totalgputick_all / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
|
||||||
|
cout << "average gpu runtime without data transfering is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, Combine( |
||||||
|
Values(CV_8U, CV_32F), Values(1, 4))); |
||||||
|
#endif |
@ -0,0 +1,155 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors as is and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
#define FILTER_IMAGE "../../../samples/gpu/road.png" |
||||||
|
|
||||||
|
#ifndef MWC_TEST_UTILITY |
||||||
|
#define MWC_TEST_UTILITY |
||||||
|
|
||||||
|
// Param class
|
||||||
|
#ifndef IMPLEMENT_PARAM_CLASS |
||||||
|
#define IMPLEMENT_PARAM_CLASS(name, type) \ |
||||||
|
class name \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
name ( type arg = type ()) : val_(arg) {} \
|
||||||
|
operator type () const {return val_;} \
|
||||||
|
private: \
|
||||||
|
type val_; \
|
||||||
|
}; \
|
||||||
|
inline void PrintTo( name param, std::ostream* os) \
|
||||||
|
{ \
|
||||||
|
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
|
||||||
|
} |
||||||
|
|
||||||
|
IMPLEMENT_PARAM_CLASS(Channels, int) |
||||||
|
#endif // IMPLEMENT_PARAM_CLASS
|
||||||
|
#endif // MWC_TEST_UTILITY
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
// Canny1
|
||||||
|
|
||||||
|
IMPLEMENT_PARAM_CLASS(AppertureSize, int); |
||||||
|
IMPLEMENT_PARAM_CLASS(L2gradient, bool); |
||||||
|
|
||||||
|
PARAM_TEST_CASE(Canny1, AppertureSize, L2gradient) |
||||||
|
{ |
||||||
|
int apperture_size; |
||||||
|
bool useL2gradient; |
||||||
|
//std::vector<cv::ocl::Info> oclinfo;
|
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
apperture_size = GET_PARAM(0); |
||||||
|
useL2gradient = GET_PARAM(1); |
||||||
|
|
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(Canny1, Performance) |
||||||
|
{ |
||||||
|
cv::Mat img = readImage(FILTER_IMAGE,cv::IMREAD_GRAYSCALE); |
||||||
|
ASSERT_FALSE(img.empty()); |
||||||
|
|
||||||
|
double low_thresh = 100.0; |
||||||
|
double high_thresh = 150.0; |
||||||
|
|
||||||
|
cv::Mat edges_gold; |
||||||
|
cv::ocl::oclMat edges; |
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
|
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat ocl_img = cv::ocl::oclMat(img);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::Canny(ocl_img, edges, low_thresh, high_thresh, apperture_size, useL2gradient); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
edges.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick; |
||||||
|
|
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Canny1, testing::Combine( |
||||||
|
testing::Values(AppertureSize(3), AppertureSize(5)), |
||||||
|
testing::Values(L2gradient(false), L2gradient(true)))); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //Have opencl
|
@ -0,0 +1,120 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang Bai fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// ColumnSum
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// ColumnSum
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(ColumnSum) |
||||||
|
{ |
||||||
|
cv::Mat src; |
||||||
|
//std::vector<cv::ocl::Info> oclinfo;
|
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_F(ColumnSum, Performance) |
||||||
|
{ |
||||||
|
cv::Size size(MWIDTH,MHEIGHT); |
||||||
|
cv::Mat src = randomMat(size, CV_32FC1); |
||||||
|
cv::ocl::oclMat d_dst; |
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
|
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat d_src(src);
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::columnSum(d_src,d_dst); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
d_dst.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick; |
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif |
@ -0,0 +1,126 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfangbai, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors as is and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
using namespace std; |
||||||
|
#ifdef HAVE_CLAMDFFT |
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Dft
|
||||||
|
PARAM_TEST_CASE(Dft, cv::Size, bool)
|
||||||
|
{ |
||||||
|
cv::Size dft_size; |
||||||
|
bool dft_rows; |
||||||
|
vector<cv::ocl::Info> info; |
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
dft_size = GET_PARAM(0); |
||||||
|
dft_rows = GET_PARAM(1); |
||||||
|
cv::ocl::getDevice(info); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(Dft, C2C) |
||||||
|
{ |
||||||
|
cv::Mat a = randomMat(dft_size, CV_32FC2, 0.0, 10.0); |
||||||
|
int flags = 0; |
||||||
|
flags |= dft_rows ? cv::DFT_ROWS : 0; |
||||||
|
|
||||||
|
cv::ocl::oclMat d_b; |
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
|
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat ga=cv::ocl::oclMat(a);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::dft(ga, d_b, a.size(), flags); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
d_b.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick;
|
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TEST_P(Dft, R2CthenC2R) |
||||||
|
{ |
||||||
|
cv::Mat a = randomMat(dft_size, CV_32FC1, 0.0, 10.0); |
||||||
|
|
||||||
|
int flags = 0; |
||||||
|
//flags |= dft_rows ? cv::DFT_ROWS : 0; // not supported yet
|
||||||
|
|
||||||
|
cv::ocl::oclMat d_b, d_c; |
||||||
|
|
||||||
|
cv::ocl::dft(cv::ocl::oclMat(a), d_b, a.size(), flags); |
||||||
|
cv::ocl::dft(d_b, d_c, a.size(), flags + cv::DFT_INVERSE + cv::DFT_REAL_OUTPUT); |
||||||
|
|
||||||
|
EXPECT_MAT_NEAR(a, d_c, a.size().area() * 1e-4, ""); |
||||||
|
} |
||||||
|
|
||||||
|
//INSTANTIATE_TEST_CASE_P(ocl_DFT, Dft, testing::Combine(
|
||||||
|
// testing::Values(cv::Size(1280, 1024), cv::Size(1920, 1080),cv::Size(1800, 1500)),
|
||||||
|
// testing::Values(false, true)));
|
||||||
|
|
||||||
|
#endif // HAVE_CLAMDFFT
|
@ -0,0 +1,113 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors as is and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
using namespace std; |
||||||
|
#ifdef HAVE_CLAMDBLAS |
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// GEMM
|
||||||
|
PARAM_TEST_CASE(Gemm, int, cv::Size, int)
|
||||||
|
{ |
||||||
|
int type; |
||||||
|
cv::Size mat_size; |
||||||
|
int flags; |
||||||
|
vector<cv::ocl::Info> info; |
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
type = GET_PARAM(0); |
||||||
|
mat_size = GET_PARAM(1); |
||||||
|
flags = GET_PARAM(2); |
||||||
|
|
||||||
|
cv::ocl::getDevice(info); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(Gemm, Performance) |
||||||
|
{ |
||||||
|
cv::Mat a = randomMat(mat_size, type, 0.0, 10.0); |
||||||
|
cv::Mat b = randomMat(mat_size, type, 0.0, 10.0); |
||||||
|
cv::Mat c = randomMat(mat_size, type, 0.0, 10.0); |
||||||
|
cv::ocl::oclMat ocl_dst;
|
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
|
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat ga = cv::ocl::oclMat(a);//upload
|
||||||
|
cv::ocl::oclMat gb = cv::ocl::oclMat(b);//upload
|
||||||
|
cv::ocl::oclMat gc = cv::ocl::oclMat(c);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::gemm(ga, gb, 1.0,gc, 1.0, ocl_dst, flags); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
ocl_dst.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick;
|
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(ocl_gemm, Gemm, testing::Combine( |
||||||
|
testing::Values(CV_32FC1, CV_32FC2/* , CV_64FC1, CV_64FC2*/), |
||||||
|
testing::Values(cv::Size(512, 512), cv::Size(1024, 1024)), |
||||||
|
testing::Values(0, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_1_T + cv::GEMM_2_T))); |
||||||
|
#endif |
@ -0,0 +1,218 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Intel License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang BAI, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include "opencv2/core/core.hpp" |
||||||
|
#include <iomanip> |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(HOG,cv::Size,int) |
||||||
|
{ |
||||||
|
cv::Size winSize; |
||||||
|
int type; |
||||||
|
std::vector<cv::ocl::Info> oclinfo; |
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
winSize = GET_PARAM(0); |
||||||
|
type = GET_PARAM(1); |
||||||
|
int devnums = getDevice(oclinfo); |
||||||
|
CV_Assert(devnums > 0); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(HOG, GetDescriptors) |
||||||
|
{ |
||||||
|
// Load image
|
||||||
|
cv::Mat img_rgb = readImage("D:road.png"); |
||||||
|
ASSERT_FALSE(img_rgb.empty()); |
||||||
|
|
||||||
|
// Convert image
|
||||||
|
cv::Mat img; |
||||||
|
switch (type) |
||||||
|
{ |
||||||
|
case CV_8UC1: |
||||||
|
cv::cvtColor(img_rgb, img, CV_BGR2GRAY); |
||||||
|
break; |
||||||
|
case CV_8UC4: |
||||||
|
default: |
||||||
|
cv::cvtColor(img_rgb, img, CV_BGR2BGRA); |
||||||
|
break; |
||||||
|
} |
||||||
|
// HOGs
|
||||||
|
cv::ocl::HOGDescriptor ocl_hog; |
||||||
|
ocl_hog.gamma_correction = true; |
||||||
|
|
||||||
|
|
||||||
|
// Compute descriptor
|
||||||
|
cv::ocl::oclMat d_descriptors; |
||||||
|
//down_descriptors = down_descriptors.reshape(0, down_descriptors.cols * down_descriptors.rows);
|
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
|
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat d_img=cv::ocl::oclMat(img);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
ocl_hog.getDescriptors(d_img, ocl_hog.win_size, d_descriptors, ocl_hog.DESCR_FORMAT_COL_BY_COL); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat down_descriptors; |
||||||
|
d_descriptors.download(down_descriptors); |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick; |
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
TEST_P(HOG, Detect) |
||||||
|
{ |
||||||
|
// Load image
|
||||||
|
cv::Mat img_rgb = readImage("D:road.png"); |
||||||
|
ASSERT_FALSE(img_rgb.empty()); |
||||||
|
|
||||||
|
// Convert image
|
||||||
|
cv::Mat img; |
||||||
|
switch (type) |
||||||
|
{ |
||||||
|
case CV_8UC1: |
||||||
|
cv::cvtColor(img_rgb, img, CV_BGR2GRAY); |
||||||
|
break; |
||||||
|
case CV_8UC4: |
||||||
|
default: |
||||||
|
cv::cvtColor(img_rgb, img, CV_BGR2BGRA); |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
// HOGs
|
||||||
|
if ((winSize != cv::Size(48, 96)) && (winSize != cv::Size(64, 128))) |
||||||
|
winSize = cv::Size(64, 128); |
||||||
|
cv::ocl::HOGDescriptor ocl_hog(winSize); |
||||||
|
ocl_hog.gamma_correction = true; |
||||||
|
|
||||||
|
cv::HOGDescriptor hog; |
||||||
|
hog.winSize = winSize; |
||||||
|
hog.gammaCorrection = true; |
||||||
|
|
||||||
|
if (winSize.width == 48 && winSize.height == 96) |
||||||
|
{ |
||||||
|
// daimler's base
|
||||||
|
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector48x96()); |
||||||
|
hog.setSVMDetector(hog.getDaimlerPeopleDetector()); |
||||||
|
} |
||||||
|
else if (winSize.width == 64 && winSize.height == 128) |
||||||
|
{ |
||||||
|
ocl_hog.setSVMDetector(ocl_hog.getPeopleDetector64x128()); |
||||||
|
hog.setSVMDetector(hog.getDefaultPeopleDetector()); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
ocl_hog.setSVMDetector(ocl_hog.getDefaultPeopleDetector()); |
||||||
|
hog.setSVMDetector(hog.getDefaultPeopleDetector()); |
||||||
|
} |
||||||
|
|
||||||
|
// OpenCL detection
|
||||||
|
std::vector<cv::Point> d_v_locations; |
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
|
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat d_img=cv::ocl::oclMat(img);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
ocl_hog.detect(d_img, d_v_locations, 0); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
totalgputick=t1+totalgputick; |
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(OCL_ObjDetect, HOG, testing::Combine( |
||||||
|
testing::Values(cv::Size(64, 128), cv::Size(48, 96)), |
||||||
|
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)))); |
||||||
|
|
||||||
|
|
||||||
|
#endif //HAVE_OPENCL
|
@ -0,0 +1,232 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors as is and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
#ifndef MWC_TEST_UTILITY |
||||||
|
#define MWC_TEST_UTILITY |
||||||
|
//////// Utility
|
||||||
|
#ifndef DIFFERENT_SIZES |
||||||
|
#else |
||||||
|
#undef DIFFERENT_SIZES |
||||||
|
#endif |
||||||
|
#define DIFFERENT_SIZES testing::Values(cv::Size(256, 256), cv::Size(3000, 3000)) |
||||||
|
|
||||||
|
// Param class
|
||||||
|
#ifndef IMPLEMENT_PARAM_CLASS |
||||||
|
#define IMPLEMENT_PARAM_CLASS(name, type) \ |
||||||
|
class name \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
name ( type arg = type ()) : val_(arg) {} \
|
||||||
|
operator type () const {return val_;} \
|
||||||
|
private: \
|
||||||
|
type val_; \
|
||||||
|
}; \
|
||||||
|
inline void PrintTo( name param, std::ostream* os) \
|
||||||
|
{ \
|
||||||
|
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
|
||||||
|
} |
||||||
|
|
||||||
|
IMPLEMENT_PARAM_CLASS(Channels, int) |
||||||
|
#endif // IMPLEMENT_PARAM_CLASS
|
||||||
|
#endif // MWC_TEST_UTILITY
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// MatchTemplate
|
||||||
|
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF_NORMED)) |
||||||
|
|
||||||
|
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size); |
||||||
|
|
||||||
|
const char* TEMPLATE_METHOD_NAMES[6] = {"TM_SQDIFF", "TM_SQDIFF_NORMED", "TM_CCORR", "TM_CCORR_NORMED", "TM_CCOEFF", "TM_CCOEFF_NORMED"}; |
||||||
|
|
||||||
|
PARAM_TEST_CASE(MatchTemplate, cv::Size, TemplateSize, Channels, TemplateMethod) |
||||||
|
{ |
||||||
|
cv::Size size; |
||||||
|
cv::Size templ_size; |
||||||
|
int cn; |
||||||
|
int method; |
||||||
|
//vector<cv::ocl::Info> oclinfo;
|
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
size = GET_PARAM(0); |
||||||
|
templ_size = GET_PARAM(1); |
||||||
|
cn = GET_PARAM(2); |
||||||
|
method = GET_PARAM(3); |
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
} |
||||||
|
}; |
||||||
|
struct MatchTemplate8U : MatchTemplate {}; |
||||||
|
|
||||||
|
TEST_P(MatchTemplate8U, Performance) |
||||||
|
{ |
||||||
|
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl; |
||||||
|
std::cout << "Image Size: (" << size.width << ", " << size.height << ")"<< std::endl; |
||||||
|
std::cout << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")"<< std::endl; |
||||||
|
std::cout << "Channels: " << cn << std::endl; |
||||||
|
|
||||||
|
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn)); |
||||||
|
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn)); |
||||||
|
cv::Mat dst_gold; |
||||||
|
cv::ocl::oclMat dst; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
|
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
for(int j = 0; j < LOOP_TIMES+1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
|
||||||
|
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
dst.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if(j == 0) |
||||||
|
continue; |
||||||
|
|
||||||
|
totalgputick=t1+totalgputick;
|
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
struct MatchTemplate32F : MatchTemplate {}; |
||||||
|
TEST_P(MatchTemplate32F, Performance) |
||||||
|
{ |
||||||
|
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl; |
||||||
|
std::cout << "Image Size: (" << size.width << ", " << size.height << ")"<< std::endl; |
||||||
|
std::cout << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")"<< std::endl; |
||||||
|
std::cout << "Channels: " << cn << std::endl; |
||||||
|
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn)); |
||||||
|
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn)); |
||||||
|
|
||||||
|
cv::Mat dst_gold; |
||||||
|
cv::ocl::oclMat dst; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double totalgputick=0; |
||||||
|
double totalgputick_kernel=0; |
||||||
|
|
||||||
|
double t1=0; |
||||||
|
double t2=0; |
||||||
|
for(int j = 0; j < LOOP_TIMES; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
|
||||||
|
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
|
||||||
|
|
||||||
|
t2=(double)cvGetTickCount();//kernel
|
||||||
|
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
dst.download (cpu_dst);//download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
totalgputick=t1+totalgputick; |
||||||
|
|
||||||
|
totalgputick_kernel=t2+totalgputick_kernel;
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U,
|
||||||
|
testing::Combine( |
||||||
|
testing::Values(cv::Size(1280, 1024), cv::Size(MWIDTH, MHEIGHT),cv::Size(1800, 1500)), |
||||||
|
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16))/*, TemplateSize(cv::Size(30, 30))*/), |
||||||
|
testing::Values(Channels(1), Channels(4)/*, Channels(3)*/), |
||||||
|
ALL_TEMPLATE_METHODS |
||||||
|
) |
||||||
|
); |
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate32F, testing::Combine( |
||||||
|
testing::Values(cv::Size(1280, 1024), cv::Size(MWIDTH, MHEIGHT),cv::Size(1800, 1500)), |
||||||
|
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16))/*, TemplateSize(cv::Size(30, 30))*/), |
||||||
|
testing::Values(Channels(1), Channels(4) /*, Channels(3)*/), |
||||||
|
testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))); |
||||||
|
|
||||||
|
#endif //HAVE_OPENCL
|
@ -0,0 +1,137 @@ |
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// fangfang bai, fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
|
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
|
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
PARAM_TEST_CASE(PyrDown, MatType, int) |
||||||
|
{ |
||||||
|
int type; |
||||||
|
int channels; |
||||||
|
//src mat
|
||||||
|
cv::Mat mat1; |
||||||
|
cv::Mat dst; |
||||||
|
|
||||||
|
//std::vector<cv::ocl::Info> oclinfo;
|
||||||
|
//ocl dst mat for testing
|
||||||
|
|
||||||
|
cv::ocl::oclMat gmat1; |
||||||
|
cv::ocl::oclMat gdst; |
||||||
|
|
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
type = GET_PARAM(0); |
||||||
|
channels = GET_PARAM(1); |
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
}; |
||||||
|
|
||||||
|
#define VARNAME(A) string(#A); |
||||||
|
|
||||||
|
////////////////////////////////PyrDown/////////////////////////////////////////////////
|
||||||
|
TEST_P(PyrDown, Mat) |
||||||
|
{ |
||||||
|
cv::Size size(MWIDTH, MHEIGHT); |
||||||
|
cv::RNG &rng = TS::ptr()->get_rng(); |
||||||
|
mat1 = randomMat(rng, size, CV_MAKETYPE(type, channels), 5, 16, false); |
||||||
|
|
||||||
|
|
||||||
|
cv::ocl::oclMat gdst; |
||||||
|
double totalgputick = 0; |
||||||
|
double totalgputick_kernel = 0; |
||||||
|
|
||||||
|
double t1 = 0; |
||||||
|
double t2 = 0; |
||||||
|
|
||||||
|
for (int j = 0; j < LOOP_TIMES + 1; j ++) |
||||||
|
{ |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat gmat1(mat1); |
||||||
|
|
||||||
|
t2 = (double)cvGetTickCount(); //kernel
|
||||||
|
cv::ocl::pyrDown(gmat1, gdst); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
gdst.download(cpu_dst); |
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if (j == 0) |
||||||
|
{ |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
totalgputick = t1 + totalgputick; |
||||||
|
|
||||||
|
totalgputick_kernel = t2 + totalgputick_kernel; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
//********test****************
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrDown, Combine( |
||||||
|
Values(CV_8U, CV_32F), Values(1, 4))); |
||||||
|
|
||||||
|
|
||||||
|
#endif // HAVE_OPENCL
|
@ -0,0 +1,122 @@ |
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||||
|
//
|
||||||
|
// By downloading, copying, installing or using the software you agree to this license.
|
||||||
|
// If you do not agree to this license, do not download, install,
|
||||||
|
// copy or use the software.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// License Agreement
|
||||||
|
// For Open Source Computer Vision Library
|
||||||
|
//
|
||||||
|
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||||
|
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
// @Authors
|
||||||
|
// fangfang bai fangfang@multicorewareinc.com
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
// are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// * Redistribution's of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
|
// and/or other oclMaterials provided with the distribution.
|
||||||
|
//
|
||||||
|
// * The name of the copyright holders may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// This software is provided by the copyright holders and contributors "as is" and
|
||||||
|
// any express or implied warranties, including, but not limited to, the implied
|
||||||
|
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||||
|
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||||
|
// indirect, incidental, special, exemplary, or consequential damages
|
||||||
|
// (including, but not limited to, procurement of substitute goods or services;
|
||||||
|
// loss of use, data, or profits; or business interruption) however caused
|
||||||
|
// and on any theory of liability, whether in contract, strict liability,
|
||||||
|
// or tort (including negligence or otherwise) arising in any way out of
|
||||||
|
// the use of this software, even if advised of the possibility of such damage.
|
||||||
|
//
|
||||||
|
//M*/
|
||||||
|
|
||||||
|
#include "opencv2/core/core.hpp" |
||||||
|
#include "precomp.hpp" |
||||||
|
#include <iomanip> |
||||||
|
#ifdef HAVE_OPENCL |
||||||
|
using namespace cv; |
||||||
|
using namespace cv::ocl; |
||||||
|
using namespace cvtest; |
||||||
|
using namespace testing; |
||||||
|
using namespace std; |
||||||
|
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(PyrUp, MatType, int) |
||||||
|
{ |
||||||
|
int type; |
||||||
|
int channels; |
||||||
|
//std::vector<cv::ocl::Info> oclinfo;
|
||||||
|
|
||||||
|
virtual void SetUp() |
||||||
|
{ |
||||||
|
type = GET_PARAM(0); |
||||||
|
channels = GET_PARAM(1); |
||||||
|
//int devnums = getDevice(oclinfo);
|
||||||
|
//CV_Assert(devnums > 0);
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
TEST_P(PyrUp, Performance) |
||||||
|
{ |
||||||
|
cv::Size size(MWIDTH, MHEIGHT); |
||||||
|
cv::Mat src = randomMat(size, CV_MAKETYPE(type, channels)); |
||||||
|
cv::Mat dst_gold; |
||||||
|
cv::ocl::oclMat dst; |
||||||
|
|
||||||
|
|
||||||
|
double totalgputick = 0; |
||||||
|
double totalgputick_kernel = 0; |
||||||
|
|
||||||
|
double t1 = 0; |
||||||
|
double t2 = 0; |
||||||
|
|
||||||
|
for (int j = 0; j < LOOP_TIMES + 1; j ++) |
||||||
|
{ |
||||||
|
t1 = (double)cvGetTickCount();//gpu start1
|
||||||
|
|
||||||
|
cv::ocl::oclMat srcMat = cv::ocl::oclMat(src);//upload
|
||||||
|
|
||||||
|
t2 = (double)cvGetTickCount(); //kernel
|
||||||
|
cv::ocl::pyrUp(srcMat, dst); |
||||||
|
t2 = (double)cvGetTickCount() - t2;//kernel
|
||||||
|
|
||||||
|
cv::Mat cpu_dst; |
||||||
|
dst.download(cpu_dst); //download
|
||||||
|
|
||||||
|
t1 = (double)cvGetTickCount() - t1;//gpu end1
|
||||||
|
|
||||||
|
if (j == 0) |
||||||
|
{ |
||||||
|
continue; |
||||||
|
} |
||||||
|
|
||||||
|
totalgputick = t1 + totalgputick; |
||||||
|
|
||||||
|
totalgputick_kernel = t2 + totalgputick_kernel; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
cout << "average gpu runtime is " << totalgputick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrUp, Combine( |
||||||
|
Values(CV_8U, CV_32F), Values(1, 4))); |
||||||
|
|
||||||
|
#endif // HAVE_OPENCL
|
Loading…
Reference in new issue