Commit 97156897 authored by niko's avatar niko

format files to ANSI C style with coolformat

change the download channels to oclchannles()
fix bugs of arithm functions
perf fix of bilateral
bug fix of split test case
add build_warps functions
parent 69fbc610
...@@ -55,22 +55,22 @@ namespace cv ...@@ -55,22 +55,22 @@ namespace cv
//////////////////////////////// oclMat //////////////////////////////// //////////////////////////////// oclMat ////////////////////////////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
inline oclMat::oclMat() : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) {} inline oclMat::oclMat() : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0) {}
inline oclMat::oclMat(int _rows, int _cols, int _type) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) inline oclMat::oclMat(int _rows, int _cols, int _type) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
if( _rows > 0 && _cols > 0 ) if( _rows > 0 && _cols > 0 )
create( _rows, _cols, _type ); create( _rows, _cols, _type );
} }
inline oclMat::oclMat(Size _size, int _type) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) inline oclMat::oclMat(Size _size, int _type) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
if( _size.height > 0 && _size.width > 0 ) if( _size.height > 0 && _size.width > 0 )
create( _size.height, _size.width, _type ); create( _size.height, _size.width, _type );
} }
inline oclMat::oclMat(int _rows, int _cols, int _type, const Scalar &_s) inline oclMat::oclMat(int _rows, int _cols, int _type, const Scalar &_s)
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
if(_rows > 0 && _cols > 0) if(_rows > 0 && _cols > 0)
{ {
...@@ -80,7 +80,7 @@ namespace cv ...@@ -80,7 +80,7 @@ namespace cv
} }
inline oclMat::oclMat(Size _size, int _type, const Scalar &_s) inline oclMat::oclMat(Size _size, int _type, const Scalar &_s)
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
if( _size.height > 0 && _size.width > 0 ) if( _size.height > 0 && _size.width > 0 )
{ {
...@@ -91,7 +91,7 @@ namespace cv ...@@ -91,7 +91,7 @@ namespace cv
inline oclMat::oclMat(const oclMat &m) inline oclMat::oclMat(const oclMat &m)
: flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data), : flags(m.flags), rows(m.rows), cols(m.cols), step(m.step), data(m.data),
refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), clCxt(m.clCxt), offset(m.offset), wholerows(m.wholerows), wholecols(m.wholecols), download_channels(m.download_channels) refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), clCxt(m.clCxt), offset(m.offset), wholerows(m.wholerows), wholecols(m.wholecols)
{ {
if( refcount ) if( refcount )
CV_XADD(refcount, 1); CV_XADD(refcount, 1);
...@@ -99,9 +99,9 @@ namespace cv ...@@ -99,9 +99,9 @@ namespace cv
inline oclMat::oclMat(int _rows, int _cols, int _type, void *_data, size_t _step) inline oclMat::oclMat(int _rows, int _cols, int _type, void *_data, size_t _step)
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), : flags(0), rows(0), cols(0), step(0), data(0), refcount(0),
datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
cv::Mat m(_rows,_cols,_type,_data,_step); cv::Mat m(_rows, _cols, _type, _data, _step);
upload(m); upload(m);
//size_t minstep = cols * elemSize(); //size_t minstep = cols * elemSize();
//if( step == Mat::AUTO_STEP ) //if( step == Mat::AUTO_STEP )
...@@ -121,9 +121,9 @@ namespace cv ...@@ -121,9 +121,9 @@ namespace cv
inline oclMat::oclMat(Size _size, int _type, void *_data, size_t _step) inline oclMat::oclMat(Size _size, int _type, void *_data, size_t _step)
: flags(0), rows(0), cols(0), : flags(0), rows(0), cols(0),
step(0), data(0), refcount(0), step(0), data(0), refcount(0),
datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0), download_channels(0) datastart(0), dataend(0), offset(0), wholerows(0), wholecols(0)
{ {
cv::Mat m(_size,_type,_data,_step); cv::Mat m(_size, _type, _data, _step);
upload(m); upload(m);
//size_t minstep = cols * elemSize(); //size_t minstep = cols * elemSize();
//if( step == Mat::AUTO_STEP ) //if( step == Mat::AUTO_STEP )
...@@ -152,7 +152,6 @@ namespace cv ...@@ -152,7 +152,6 @@ namespace cv
wholerows = m.wholerows; wholerows = m.wholerows;
wholecols = m.wholecols; wholecols = m.wholecols;
offset = m.offset; offset = m.offset;
download_channels = m.download_channels;
if( rowRange == Range::all() ) if( rowRange == Range::all() )
rows = m.rows; rows = m.rows;
else else
...@@ -184,7 +183,7 @@ namespace cv ...@@ -184,7 +183,7 @@ namespace cv
inline oclMat::oclMat(const oclMat &m, const Rect &roi) inline oclMat::oclMat(const oclMat &m, const Rect &roi)
: flags(m.flags), rows(roi.height), cols(roi.width), : flags(m.flags), rows(roi.height), cols(roi.width),
step(m.step), data(m.data), refcount(m.refcount), step(m.step), data(m.data), refcount(m.refcount),
datastart(m.datastart), dataend(m.dataend), clCxt(m.clCxt), offset(m.offset), wholerows(m.wholerows), wholecols(m.wholecols), download_channels(m.download_channels) datastart(m.datastart), dataend(m.dataend), clCxt(m.clCxt), offset(m.offset), wholerows(m.wholerows), wholecols(m.wholecols)
{ {
flags &= roi.width < m.cols ? ~Mat::CONTINUOUS_FLAG : -1; flags &= roi.width < m.cols ? ~Mat::CONTINUOUS_FLAG : -1;
offset += roi.y * step + roi.x * elemSize(); offset += roi.y * step + roi.x * elemSize();
...@@ -197,7 +196,7 @@ namespace cv ...@@ -197,7 +196,7 @@ namespace cv
} }
inline oclMat::oclMat(const Mat &m) inline oclMat::oclMat(const Mat &m)
: flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) , offset(0), wholerows(0), wholecols(0), download_channels(0) : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) , offset(0), wholerows(0), wholecols(0)
{ {
//clCxt = Context::getContext(); //clCxt = Context::getContext();
upload(m); upload(m);
...@@ -227,7 +226,6 @@ namespace cv ...@@ -227,7 +226,6 @@ namespace cv
wholerows = m.wholerows; wholerows = m.wholerows;
wholecols = m.wholecols; wholecols = m.wholecols;
refcount = m.refcount; refcount = m.refcount;
download_channels = m.download_channels;
} }
return *this; return *this;
} }
...@@ -330,7 +328,6 @@ namespace cv ...@@ -330,7 +328,6 @@ namespace cv
std::swap( clCxt, b.clCxt ); std::swap( clCxt, b.clCxt );
std::swap( wholerows, b.wholerows ); std::swap( wholerows, b.wholerows );
std::swap( wholecols, b.wholecols ); std::swap( wholecols, b.wholecols );
std::swap( download_channels, b.download_channels);
} }
inline void oclMat::locateROI( Size &wholeSize, Point &ofs ) const inline void oclMat::locateROI( Size &wholeSize, Point &ofs ) const
...@@ -366,7 +363,7 @@ namespace cv ...@@ -366,7 +363,7 @@ namespace cv
offset += (row1 - ofs.y) * step + (col1 - ofs.x) * esz; offset += (row1 - ofs.y) * step + (col1 - ofs.x) * esz;
rows = row2 - row1; rows = row2 - row1;
cols = col2 - col1; cols = col2 - col1;
if( esz *cols == step || rows == 1 ) if( esz * cols == step || rows == 1 )
flags |= Mat::CONTINUOUS_FLAG; flags |= Mat::CONTINUOUS_FLAG;
else else
flags &= ~Mat::CONTINUOUS_FLAG; flags &= ~Mat::CONTINUOUS_FLAG;
...@@ -388,7 +385,7 @@ namespace cv ...@@ -388,7 +385,7 @@ namespace cv
} }
inline size_t oclMat::elemSize() const inline size_t oclMat::elemSize() const
{ {
return CV_ELEM_SIZE(flags); return CV_ELEM_SIZE((CV_MAKE_TYPE(type(), oclchannels())));
} }
inline size_t oclMat::elemSize1() const inline size_t oclMat::elemSize1() const
{ {
...@@ -398,6 +395,10 @@ namespace cv ...@@ -398,6 +395,10 @@ namespace cv
{ {
return CV_MAT_TYPE(flags); return CV_MAT_TYPE(flags);
} }
inline int oclMat::ocltype() const
{
return CV_MAKE_TYPE(depth(), oclchannels());
}
inline int oclMat::depth() const inline int oclMat::depth() const
{ {
return CV_MAT_DEPTH(flags); return CV_MAT_DEPTH(flags);
...@@ -406,6 +407,10 @@ namespace cv ...@@ -406,6 +407,10 @@ namespace cv
{ {
return CV_MAT_CN(flags); return CV_MAT_CN(flags);
} }
inline int oclMat::oclchannels() const
{
return (CV_MAT_CN(flags)) == 3 ? 4 : (CV_MAT_CN(flags));
}
inline size_t oclMat::step1() const inline size_t oclMat::step1() const
{ {
return step / elemSize1(); return step / elemSize1();
...@@ -424,28 +429,28 @@ namespace cv ...@@ -424,28 +429,28 @@ namespace cv
inline uchar *oclMat::ptr(int y) inline uchar *oclMat::ptr(int y)
{ {
CV_DbgAssert( (unsigned)y < (unsigned)rows ); CV_DbgAssert( (unsigned)y < (unsigned)rows );
CV_Error(CV_GpuNotSupported,"This function hasn't been supported yet.\n"); CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n");
return data + step * y; return data + step * y;
} }
inline const uchar *oclMat::ptr(int y) const inline const uchar *oclMat::ptr(int y) const
{ {
CV_DbgAssert( (unsigned)y < (unsigned)rows ); CV_DbgAssert( (unsigned)y < (unsigned)rows );
CV_Error(CV_GpuNotSupported,"This function hasn't been supported yet.\n"); CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n");
return data + step * y; return data + step * y;
} }
template<typename _Tp> inline _Tp *oclMat::ptr(int y) template<typename _Tp> inline _Tp *oclMat::ptr(int y)
{ {
CV_DbgAssert( (unsigned)y < (unsigned)rows ); CV_DbgAssert( (unsigned)y < (unsigned)rows );
CV_Error(CV_GpuNotSupported,"This function hasn't been supported yet.\n"); CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n");
return (_Tp *)(data + step * y); return (_Tp *)(data + step * y);
} }
template<typename _Tp> inline const _Tp *oclMat::ptr(int y) const template<typename _Tp> inline const _Tp *oclMat::ptr(int y) const
{ {
CV_DbgAssert( (unsigned)y < (unsigned)rows ); CV_DbgAssert( (unsigned)y < (unsigned)rows );
CV_Error(CV_GpuNotSupported,"This function hasn't been supported yet.\n"); CV_Error(CV_GpuNotSupported, "This function hasn't been supported yet.\n");
return (const _Tp *)(data + step * y); return (const _Tp *)(data + step * y);
} }
...@@ -461,7 +466,7 @@ namespace cv ...@@ -461,7 +466,7 @@ namespace cv
a.swap(b); a.swap(b);
} }
inline void ensureSizeIsEnough(int rows, int cols, int type, oclMat& m) inline void ensureSizeIsEnough(int rows, int cols, int type, oclMat &m)
{ {
if (m.type() == type && m.rows >= rows && m.cols >= cols) if (m.type() == type && m.rows >= rows && m.cols >= cols)
m = m(Rect(0, 0, cols, rows)); m = m(Rect(0, 0, cols, rows));
...@@ -469,10 +474,12 @@ namespace cv ...@@ -469,10 +474,12 @@ namespace cv
m.create(rows, cols, type); m.create(rows, cols, type);
} }
inline void ensureSizeIsEnough(Size size, int type, oclMat& m) inline void ensureSizeIsEnough(Size size, int type, oclMat &m)
{ {
ensureSizeIsEnough(size.height, size.width, type, m); ensureSizeIsEnough(size.height, size.width, type, m);
} }
} /* end of namespace ocl */ } /* end of namespace ocl */
} /* end of namespace cv */ } /* end of namespace cv */
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#ifndef __OPENCV_TEST_INTERPOLATION_HPP__ #ifndef __OPENCV_TEST_INTERPOLATION_HPP__
#define __OPENCV_TEST_INTERPOLATION_HPP__ #define __OPENCV_TEST_INTERPOLATION_HPP__
template <typename T> T readVal(const cv::Mat& src, int y, int x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) template <typename T> T readVal(const cv::Mat &src, int y, int x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
{ {
if (border_type == cv::BORDER_CONSTANT) if (border_type == cv::BORDER_CONSTANT)
return (y >= 0 && y < src.rows && x >= 0 && x < src.cols) ? src.at<T>(y, x * src.channels() + c) : cv::saturate_cast<T>(borderVal.val[c]); return (y >= 0 && y < src.rows && x >= 0 && x < src.cols) ? src.at<T>(y, x * src.channels() + c) : cv::saturate_cast<T>(borderVal.val[c]);
...@@ -52,7 +52,7 @@ template <typename T> T readVal(const cv::Mat& src, int y, int x, int c, int bor ...@@ -52,7 +52,7 @@ template <typename T> T readVal(const cv::Mat& src, int y, int x, int c, int bor
template <typename T> struct NearestInterpolator template <typename T> struct NearestInterpolator
{ {
static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
{ {
return readVal<T>(src, cvFloor(y), cvFloor(x), c, border_type, borderVal); return readVal<T>(src, cvFloor(y), cvFloor(x), c, border_type, borderVal);
} }
...@@ -60,7 +60,7 @@ template <typename T> struct NearestInterpolator ...@@ -60,7 +60,7 @@ template <typename T> struct NearestInterpolator
template <typename T> struct LinearInterpolator template <typename T> struct LinearInterpolator
{ {
static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
{ {
x -= 0.5f; x -= 0.5f;
y -= 0.5f; y -= 0.5f;
...@@ -85,7 +85,7 @@ template <typename T> struct CubicInterpolator ...@@ -85,7 +85,7 @@ template <typename T> struct CubicInterpolator
{ {
static float getValue(float p[4], float x) static float getValue(float p[4], float x)
{ {
return p[1] + 0.5 * x * (p[2] - p[0] + x*(2.0*p[0] - 5.0*p[1] + 4.0*p[2] - p[3] + x*(3.0*(p[1] - p[2]) + p[3] - p[0]))); return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
} }
static float getValue(float p[4][4], float x, float y) static float getValue(float p[4][4], float x, float y)
...@@ -100,7 +100,7 @@ template <typename T> struct CubicInterpolator ...@@ -100,7 +100,7 @@ template <typename T> struct CubicInterpolator
return getValue(arr, y); return getValue(arr, y);
} }
static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar()) static T getValue(const cv::Mat &src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())
{ {
int ix = cvRound(x); int ix = cvRound(x);
int iy = cvRound(y); int iy = cvRound(y);
......
...@@ -74,7 +74,7 @@ void print_info() ...@@ -74,7 +74,7 @@ void print_info()
} }
int main(int argc, char** argv) int main(int argc, char **argv)
{ {
std::vector<cv::ocl::Info> oclinfo; std::vector<cv::ocl::Info> oclinfo;
TS::ptr()->init("ocl"); TS::ptr()->init("ocl");
...@@ -82,7 +82,7 @@ int main(int argc, char** argv) ...@@ -82,7 +82,7 @@ int main(int argc, char** argv)
print_info(); print_info();
int devnums = getDevice(oclinfo); int devnums = getDevice(oclinfo);
if(devnums<1) if(devnums < 1)
{ {
std::cout << "no device found\n"; std::cout << "no device found\n";
return -1; return -1;
......
This diff is collapsed.
...@@ -101,7 +101,7 @@ PARAM_TEST_CASE(Canny1, AppertureSize, L2gradient) ...@@ -101,7 +101,7 @@ PARAM_TEST_CASE(Canny1, AppertureSize, L2gradient)
TEST_P(Canny1, Performance) TEST_P(Canny1, Performance)
{ {
cv::Mat img = readImage(FILTER_IMAGE,cv::IMREAD_GRAYSCALE); cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()); ASSERT_FALSE(img.empty());
double low_thresh = 100.0; double low_thresh = 100.0;
...@@ -110,19 +110,19 @@ TEST_P(Canny1, Performance) ...@@ -110,19 +110,19 @@ TEST_P(Canny1, Performance)
cv::Mat edges_gold; cv::Mat edges_gold;
cv::ocl::oclMat edges; cv::ocl::oclMat edges;
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
cv::ocl::oclMat ocl_img = cv::ocl::oclMat(img);//upload cv::ocl::oclMat ocl_img = cv::ocl::oclMat(img);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::Canny(ocl_img, edges, low_thresh, high_thresh, apperture_size, useL2gradient); cv::ocl::Canny(ocl_img, edges, low_thresh, high_thresh, apperture_size, useL2gradient);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
...@@ -134,14 +134,14 @@ TEST_P(Canny1, Performance) ...@@ -134,14 +134,14 @@ TEST_P(Canny1, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
......
...@@ -75,24 +75,24 @@ PARAM_TEST_CASE(ColumnSum) ...@@ -75,24 +75,24 @@ PARAM_TEST_CASE(ColumnSum)
TEST_F(ColumnSum, Performance) TEST_F(ColumnSum, Performance)
{ {
cv::Size size(MWIDTH,MHEIGHT); cv::Size size(MWIDTH, MHEIGHT);
cv::Mat src = randomMat(size, CV_32FC1); cv::Mat src = randomMat(size, CV_32FC1);
cv::ocl::oclMat d_dst; cv::ocl::oclMat d_dst;
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
cv::ocl::oclMat d_src(src); cv::ocl::oclMat d_src(src);
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::columnSum(d_src,d_dst); cv::ocl::columnSum(d_src, d_dst);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
cv::Mat cpu_dst; cv::Mat cpu_dst;
...@@ -103,13 +103,13 @@ TEST_F(ColumnSum, Performance) ...@@ -103,13 +103,13 @@ TEST_F(ColumnSum, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
......
...@@ -69,19 +69,19 @@ TEST_P(Dft, C2C) ...@@ -69,19 +69,19 @@ TEST_P(Dft, C2C)
cv::ocl::oclMat d_b; cv::ocl::oclMat d_b;
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
cv::ocl::oclMat ga=cv::ocl::oclMat(a);//upload cv::ocl::oclMat ga = cv::ocl::oclMat(a); //upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::dft(ga, d_b, a.size(), flags); cv::ocl::dft(ga, d_b, a.size(), flags);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
...@@ -93,13 +93,13 @@ TEST_P(Dft, C2C) ...@@ -93,13 +93,13 @@ TEST_P(Dft, C2C)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
......
This diff is collapsed.
...@@ -71,12 +71,12 @@ TEST_P(Gemm, Performance) ...@@ -71,12 +71,12 @@ TEST_P(Gemm, Performance)
cv::Mat c = randomMat(mat_size, type, 0.0, 10.0); cv::Mat c = randomMat(mat_size, type, 0.0, 10.0);
cv::ocl::oclMat ocl_dst; cv::ocl::oclMat ocl_dst;
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
...@@ -85,8 +85,8 @@ TEST_P(Gemm, Performance) ...@@ -85,8 +85,8 @@ TEST_P(Gemm, Performance)
cv::ocl::oclMat gb = cv::ocl::oclMat(b);//upload cv::ocl::oclMat gb = cv::ocl::oclMat(b);//upload
cv::ocl::oclMat gc = cv::ocl::oclMat(c);//upload cv::ocl::oclMat gc = cv::ocl::oclMat(c);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::gemm(ga, gb, 1.0,gc, 1.0, ocl_dst, flags); cv::ocl::gemm(ga, gb, 1.0, gc, 1.0, ocl_dst, flags);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
cv::Mat cpu_dst; cv::Mat cpu_dst;
...@@ -97,12 +97,12 @@ TEST_P(Gemm, Performance) ...@@ -97,12 +97,12 @@ TEST_P(Gemm, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
......
...@@ -53,7 +53,13 @@ using namespace testing; ...@@ -53,7 +53,13 @@ using namespace testing;
using namespace std; using namespace std;
using namespace cv; using namespace cv;
struct getRect { Rect operator ()(const CvAvgComp& e) const { return e.rect; } }; struct getRect
{
Rect operator ()(const CvAvgComp &e) const
{
return e.rect;
}
};
PARAM_TEST_CASE(HaarTestBase, int, int) PARAM_TEST_CASE(HaarTestBase, int, int)
{ {
...@@ -68,8 +74,8 @@ PARAM_TEST_CASE(HaarTestBase, int, int) ...@@ -68,8 +74,8 @@ PARAM_TEST_CASE(HaarTestBase, int, int)
virtual void SetUp() virtual void SetUp()
{ {
scale = 1.0; scale = 1.0;
index=0; index = 0;
string cascadeName="../../../data/haarcascades/haarcascade_frontalface_alt.xml"; string cascadeName = "../../../data/haarcascades/haarcascade_frontalface_alt.xml";
if( (!cascade.load( cascadeName )) || (!cpucascade.load(cascadeName))) if( (!cascade.load( cascadeName )) || (!cpucascade.load(cascadeName)))
{ {
...@@ -98,7 +104,7 @@ TEST_F(Haar, FaceDetect) ...@@ -98,7 +104,7 @@ TEST_F(Haar, FaceDetect)
if(img.empty()) if(img.empty())
{ {
std::cout << "Couldn't read test" << index <<".jpg" << std::endl; std::cout << "Couldn't read test" << index << ".jpg" << std::endl;
return ; return ;
} }
...@@ -106,45 +112,46 @@ TEST_F(Haar, FaceDetect) ...@@ -106,45 +112,46 @@ TEST_F(Haar, FaceDetect)
double t = 0; double t = 0;
vector<Rect> faces, oclfaces; vector<Rect> faces, oclfaces;
const static Scalar colors[] = { CV_RGB(0,0,255), const static Scalar colors[] = { CV_RGB(0, 0, 255),
CV_RGB(0,128,255), CV_RGB(0, 128, 255),
CV_RGB(0,255,255), CV_RGB(0, 255, 255),
CV_RGB(0,255,0), CV_RGB(0, 255, 0),
CV_RGB(255,128,0), CV_RGB(255, 128, 0),
CV_RGB(255,255,0), CV_RGB(255, 255, 0),
CV_RGB(255,0,0), CV_RGB(255, 0, 0),
CV_RGB(255,0,255)} ; CV_RGB(255, 0, 255)
} ;
Mat gray, smallImg(cvRound (img.rows/scale), cvRound(img.cols/scale), CV_8UC1 );
Mat gray, smallImg(cvRound (img.rows / scale), cvRound(img.cols / scale), CV_8UC1 );
MemStorage storage(cvCreateMemStorage(0)); MemStorage storage(cvCreateMemStorage(0));
cvtColor( img, gray, CV_BGR2GRAY ); cvtColor( img, gray, CV_BGR2GRAY );
resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR ); resize( gray, smallImg, smallImg.size(), 0, 0, INTER_LINEAR );
equalizeHist( smallImg, smallImg ); equalizeHist( smallImg, smallImg );
t = (double)cvGetTickCount(); t = (double)cvGetTickCount();
for(int k= 0; k<LOOP_TIMES; k++) for(int k = 0; k < LOOP_TIMES; k++)
{ {
cpucascade.detectMultiScale( smallImg, faces, 1.1, cpucascade.detectMultiScale( smallImg, faces, 1.1,
3, 0 3, 0
|CV_HAAR_SCALE_IMAGE | CV_HAAR_SCALE_IMAGE
, Size(30,30), Size(0, 0) ); , Size(30, 30), Size(0, 0) );
} }
t = (double)cvGetTickCount() - t ; t = (double)cvGetTickCount() - t ;
printf( "cpudetection time = %g ms\n", t/(LOOP_TIMES*(double)cvGetTickFrequency()*1000.) ); printf( "cpudetection time = %g ms\n", t / (LOOP_TIMES * (double)cvGetTickFrequency() * 1000.) );
cv::ocl::oclMat image; cv::ocl::oclMat image;
CvSeq* _objects; CvSeq *_objects;
t = (double)cvGetTickCount(); t = (double)cvGetTickCount();
for(int k= 0; k<LOOP_TIMES; k++) for(int k = 0; k < LOOP_TIMES; k++)
{ {
image.upload(smallImg); image.upload(smallImg);
_objects = cascade.oclHaarDetectObjects( image, storage, 1.1, _objects = cascade.oclHaarDetectObjects( image, storage, 1.1,
3, 0 3, 0
|CV_HAAR_SCALE_IMAGE | CV_HAAR_SCALE_IMAGE
, Size(30,30), Size(0, 0) ); , Size(30, 30), Size(0, 0) );
} }
t = (double)cvGetTickCount() - t ; t = (double)cvGetTickCount() - t ;
printf( "ocldetection time = %g ms\n", t/(LOOP_TIMES*(double)cvGetTickFrequency()*1000.) ); printf( "ocldetection time = %g ms\n", t / (LOOP_TIMES * (double)cvGetTickFrequency() * 1000.) );
vector<CvAvgComp> vecAvgComp; vector<CvAvgComp> vecAvgComp;
Seq<CvAvgComp>(_objects).copyTo(vecAvgComp); Seq<CvAvgComp>(_objects).copyTo(vecAvgComp);
oclfaces.resize(vecAvgComp.size()); oclfaces.resize(vecAvgComp.size());
......
...@@ -100,7 +100,7 @@ PARAM_TEST_CASE(HOG, WinSizw48, bool) ...@@ -100,7 +100,7 @@ PARAM_TEST_CASE(HOG, WinSizw48, bool)
TEST_P(HOG, Performance) TEST_P(HOG, Performance)
{ {
cv::Mat img = readImage(FILTER_IMAGE,cv::IMREAD_GRAYSCALE); cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()); ASSERT_FALSE(img.empty());
// define HOG related arguments // define HOG related arguments
...@@ -110,7 +110,7 @@ TEST_P(HOG, Performance) ...@@ -110,7 +110,7 @@ TEST_P(HOG, Performance)
float hit_threshold = 1.4; float hit_threshold = 1.4;
bool hit_threshold_auto = true; bool hit_threshold_auto = true;
int win_width = is48? 48 : 64; int win_width = is48 ? 48 : 64;
int win_stride_width = 8; int win_stride_width = 8;
int win_stride_height = 8; int win_stride_height = 8;
...@@ -125,18 +125,18 @@ TEST_P(HOG, Performance) ...@@ -125,18 +125,18 @@ TEST_P(HOG, Performance)
gpu_hog.setSVMDetector(detector); gpu_hog.setSVMDetector(detector);
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
ocl::oclMat d_src(img);//upload ocl::oclMat d_src(img);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
vector<Rect> found; vector<Rect> found;
gpu_hog.detectMultiScale(d_src, found, hit_threshold, win_stride, gpu_hog.detectMultiScale(d_src, found, hit_threshold, win_stride,
...@@ -151,14 +151,14 @@ TEST_P(HOG, Performance) ...@@ -151,14 +151,14 @@ TEST_P(HOG, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
......
This diff is collapsed.
...@@ -87,7 +87,7 @@ IMPLEMENT_PARAM_CLASS(Channels, int) ...@@ -87,7 +87,7 @@ IMPLEMENT_PARAM_CLASS(Channels, int)
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size); 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"}; 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) PARAM_TEST_CASE(MatchTemplate, cv::Size, TemplateSize, Channels, TemplateMethod)
{ {
...@@ -112,8 +112,8 @@ struct MatchTemplate8U : MatchTemplate {}; ...@@ -112,8 +112,8 @@ struct MatchTemplate8U : MatchTemplate {};
TEST_P(MatchTemplate8U, Performance) TEST_P(MatchTemplate8U, Performance)
{ {
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl; std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
std::cout << "Image Size: (" << size.width << ", " << size.height << ")"<< 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 << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")" << std::endl;
std::cout << "Channels: " << cn << std::endl; std::cout << "Channels: " << cn << std::endl;
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn)); cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
...@@ -125,12 +125,12 @@ TEST_P(MatchTemplate8U, Performance) ...@@ -125,12 +125,12 @@ TEST_P(MatchTemplate8U, Performance)
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
...@@ -138,7 +138,7 @@ TEST_P(MatchTemplate8U, Performance) ...@@ -138,7 +138,7 @@ TEST_P(MatchTemplate8U, Performance)
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method); cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
...@@ -150,13 +150,13 @@ TEST_P(MatchTemplate8U, Performance) ...@@ -150,13 +150,13 @@ TEST_P(MatchTemplate8U, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
...@@ -166,8 +166,8 @@ struct MatchTemplate32F : MatchTemplate {}; ...@@ -166,8 +166,8 @@ struct MatchTemplate32F : MatchTemplate {};
TEST_P(MatchTemplate32F, Performance) TEST_P(MatchTemplate32F, Performance)
{ {
std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl; std::cout << "Method: " << TEMPLATE_METHOD_NAMES[method] << std::endl;
std::cout << "Image Size: (" << size.width << ", " << size.height << ")"<< 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 << "Template Size: (" << templ_size.width << ", " << templ_size.height << ")" << std::endl;
std::cout << "Channels: " << cn << std::endl; std::cout << "Channels: " << cn << std::endl;
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn)); cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn)); cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
...@@ -178,11 +178,11 @@ TEST_P(MatchTemplate32F, Performance) ...@@ -178,11 +178,11 @@ TEST_P(MatchTemplate32F, Performance)
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES; j ++) for(int j = 0; j < LOOP_TIMES; j ++)
{ {
...@@ -191,7 +191,7 @@ TEST_P(MatchTemplate32F, Performance) ...@@ -191,7 +191,7 @@ TEST_P(MatchTemplate32F, Performance)
cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload cv::ocl::oclMat ocl_image = cv::ocl::oclMat(image);//upload
cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload cv::ocl::oclMat ocl_templ = cv::ocl::oclMat(templ);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method); cv::ocl::matchTemplate(ocl_image, ocl_templ, dst, method);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
...@@ -200,14 +200,14 @@ TEST_P(MatchTemplate32F, Performance) ...@@ -200,14 +200,14 @@ TEST_P(MatchTemplate32F, Performance)
t1 = (double)cvGetTickCount() - t1;//gpu end1 t1 = (double)cvGetTickCount() - t1;//gpu end1
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
...@@ -216,15 +216,15 @@ TEST_P(MatchTemplate32F, Performance) ...@@ -216,15 +216,15 @@ TEST_P(MatchTemplate32F, Performance)
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U, INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U,
testing::Combine( testing::Combine(
testing::Values(cv::Size(1280, 1024), cv::Size(MWIDTH, MHEIGHT),cv::Size(1800, 1500)), 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(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(Channels(1), Channels(4)/*, Channels(3)*/),
ALL_TEMPLATE_METHODS ALL_TEMPLATE_METHODS
) )
); );
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate32F, testing::Combine( 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(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(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(Channels(1), Channels(4) /*, Channels(3)*/),
testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR)))); testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))));
......
This diff is collapsed.
This diff is collapsed.
...@@ -58,25 +58,25 @@ using namespace std; ...@@ -58,25 +58,25 @@ using namespace std;
TEST(SURF, Performance) TEST(SURF, Performance)
{ {
cv::Mat img = readImage(FILTER_IMAGE,cv::IMREAD_GRAYSCALE); cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty()); ASSERT_FALSE(img.empty());
ocl::SURF_OCL d_surf; ocl::SURF_OCL d_surf;
ocl::oclMat d_keypoints; ocl::oclMat d_keypoints;
ocl::oclMat d_descriptors; ocl::oclMat d_descriptors;
double totalgputick=0; double totalgputick = 0;
double totalgputick_kernel=0; double totalgputick_kernel = 0;
double t1=0; double t1 = 0;
double t2=0; double t2 = 0;
for(int j = 0; j < LOOP_TIMES+1; j ++) for(int j = 0; j < LOOP_TIMES + 1; j ++)
{ {
t1 = (double)cvGetTickCount();//gpu start1 t1 = (double)cvGetTickCount();//gpu start1
ocl::oclMat d_src(img);//upload ocl::oclMat d_src(img);//upload
t2=(double)cvGetTickCount();//kernel t2 = (double)cvGetTickCount(); //kernel
d_surf(d_src, ocl::oclMat(), d_keypoints, d_descriptors); d_surf(d_src, ocl::oclMat(), d_keypoints, d_descriptors);
t2 = (double)cvGetTickCount() - t2;//kernel t2 = (double)cvGetTickCount() - t2;//kernel
...@@ -89,14 +89,14 @@ TEST(SURF, Performance) ...@@ -89,14 +89,14 @@ TEST(SURF, Performance)
if(j == 0) if(j == 0)
continue; continue;
totalgputick=t1+totalgputick; totalgputick = t1 + totalgputick;
totalgputick_kernel=t2+totalgputick_kernel; totalgputick_kernel = t2 + totalgputick_kernel;
} }
cout << "average gpu runtime is " << totalgputick/((double)cvGetTickFrequency()* LOOP_TIMES *1000.) << "ms" << endl; 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; cout << "average gpu runtime without data transfer is " << totalgputick_kernel / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
} }
......
...@@ -42,4 +42,3 @@ ...@@ -42,4 +42,3 @@
#include "precomp.hpp" #include "precomp.hpp"
\ No newline at end of file
...@@ -75,13 +75,13 @@ using namespace cvtest; ...@@ -75,13 +75,13 @@ using namespace cvtest;
int randomInt(int minVal, int maxVal) int randomInt(int minVal, int maxVal)
{ {
RNG& rng = TS::ptr()->get_rng(); RNG &rng = TS::ptr()->get_rng();
return rng.uniform(minVal, maxVal); return rng.uniform(minVal, maxVal);
} }
double randomDouble(double minVal, double maxVal) double randomDouble(double minVal, double maxVal)
{ {
RNG& rng = TS::ptr()->get_rng(); RNG &rng = TS::ptr()->get_rng();
return rng.uniform(minVal, maxVal); return rng.uniform(minVal, maxVal);
} }
...@@ -207,19 +207,19 @@ vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end) ...@@ -207,19 +207,19 @@ vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
return v; return v;
} }
const vector<MatType>& all_types() const vector<MatType> &all_types()
{ {
static vector<MatType> v = types(CV_8U, CV_64F, 1, 4); static vector<MatType> v = types(CV_8U, CV_64F, 1, 4);
return v; return v;
} }
Mat readImage(const string& fileName, int flags) Mat readImage(const string &fileName, int flags)
{ {
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags); return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
} }
Mat readImageType(const string& fname, int type) Mat readImageType(const string &fname, int type)
{ {
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR); Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
if (CV_MAT_CN(type) == 4) if (CV_MAT_CN(type) == 4)
...@@ -232,17 +232,17 @@ Mat readImageType(const string& fname, int type) ...@@ -232,17 +232,17 @@ Mat readImageType(const string& fname, int type)
return src; return src;
} }
double checkNorm(const Mat& m) double checkNorm(const Mat &m)
{ {
return norm(m, NORM_INF); return norm(m, NORM_INF);
} }
double checkNorm(const Mat& m1, const Mat& m2) double checkNorm(const Mat &m1, const Mat &m2)
{ {
return norm(m1, m2, NORM_INF); return norm(m1, m2, NORM_INF);
} }
double checkSimilarity(const Mat& m1, const Mat& m2) double checkSimilarity(const Mat &m1, const Mat &m2)
{ {
Mat diff; Mat diff;
matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED); matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);
...@@ -256,7 +256,7 @@ void cv::ocl::PrintTo(const DeviceInfo& info, ostream* os) ...@@ -256,7 +256,7 @@ void cv::ocl::PrintTo(const DeviceInfo& info, ostream* os)
} }
*/ */
void PrintTo(const Inverse& inverse, std::ostream* os) void PrintTo(const Inverse &inverse, std::ostream *os)
{ {
if (inverse) if (inverse)
(*os) << "inverse"; (*os) << "inverse";
......
...@@ -56,7 +56,7 @@ int randomInt(int minVal, int maxVal); ...@@ -56,7 +56,7 @@ int randomInt(int minVal, int maxVal);
double randomDouble(double minVal, double maxVal); double randomDouble(double minVal, double maxVal);
//std::string generateVarList(int first,...); //std::string generateVarList(int first,...);
std::string generateVarList(int& p1,int& p2); std::string generateVarList(int &p1, int &p2);
cv::Size randomSize(int minVal, int maxVal); cv::Size randomSize(int minVal, int maxVal);
cv::Scalar randomScalar(double minVal, double maxVal); cv::Scalar randomScalar(double minVal, double maxVal);
cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0); cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0);
...@@ -72,12 +72,12 @@ void showDiff(cv::InputArray gold, cv::InputArray actual, double eps); ...@@ -72,12 +72,12 @@ void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);
//std::vector<cv::ocl::DeviceInfo> devices(cv::gpu::FeatureSet feature); //std::vector<cv::ocl::DeviceInfo> devices(cv::gpu::FeatureSet feature);
//! read image from testdata folder. //! read image from testdata folder.
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR); cv::Mat readImage(const std::string &fileName, int flags = cv::IMREAD_COLOR);
cv::Mat readImageType(const std::string& fname, int type); cv::Mat readImageType(const std::string &fname, int type);
double checkNorm(const cv::Mat& m); double checkNorm(const cv::Mat &m);
double checkNorm(const cv::Mat& m1, const cv::Mat& m2); double checkNorm(const cv::Mat &m1, const cv::Mat &m2);
double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2); double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
#define EXPECT_MAT_NORM(mat, eps) \ #define EXPECT_MAT_NORM(mat, eps) \
{ \ { \
...@@ -120,31 +120,34 @@ using perf::MatType; ...@@ -120,31 +120,34 @@ using perf::MatType;
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end); std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end);
//! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4). //! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
const std::vector<MatType>& all_types(); const std::vector<MatType> &all_types();
class Inverse class Inverse
{ {
public: public:
inline Inverse(bool val = false) : val_(val) {} inline Inverse(bool val = false) : val_(val) {}
inline operator bool() const { return val_; } inline operator bool() const
{
return val_;
}
private: private:
bool val_; bool val_;
}; };
void PrintTo(const Inverse& useRoi, std::ostream* os); void PrintTo(const Inverse &useRoi, std::ostream *os);
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE) CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX) CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)
enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1}; enum {FLIP_BOTH = 0, FLIP_X = 1, FLIP_Y = -1};
CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y) CV_ENUM(FlipCode, FLIP_BOTH, FLIP_X, FLIP_Y)
CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN) CV_ENUM(ReduceOp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
CV_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T); CV_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT) CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
......
This diff is collapsed.
...@@ -51,8 +51,11 @@ using namespace cv::ocl; ...@@ -51,8 +51,11 @@ using namespace cv::ocl;
using namespace std; using namespace std;
#if !defined (HAVE_OPENCL) #if !defined (HAVE_OPENCL)
void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat& weights1, const oclMat& weights2, void cv::ocl::blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2,
oclMat& result){throw_nogpu();} oclMat &result)
{
throw_nogpu();
}
#else #else
namespace cv namespace cv
{ {
...@@ -63,12 +66,12 @@ namespace cv ...@@ -63,12 +66,12 @@ namespace cv
} }
} }
void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat& weights1, const oclMat& weights2, void cv::ocl::blendLinear(const oclMat &img1, const oclMat &img2, const oclMat &weights1, const oclMat &weights2,
oclMat& result) oclMat &result)
{ {
cv::ocl::Context *ctx = img1.clCxt; cv::ocl::Context *ctx = img1.clCxt;
assert(ctx == img2.clCxt && ctx == weights1.clCxt && ctx == weights2.clCxt); assert(ctx == img2.clCxt && ctx == weights1.clCxt && ctx == weights2.clCxt);
int channels = img1.channels(); int channels = img1.oclchannels();
int depth = img1.depth(); int depth = img1.depth();
int rows = img1.rows; int rows = img1.rows;
int cols = img1.cols; int cols = img1.cols;
...@@ -79,7 +82,7 @@ void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat& ...@@ -79,7 +82,7 @@ void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat&
vector< pair<size_t, const void *> > args; vector< pair<size_t, const void *> > args;
if(globalSize[0]!=0) if(globalSize[0] != 0)
{ {
args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data )); args.push_back( make_pair( sizeof(cl_mem), (void *)&result.data ));
args.push_back( make_pair( sizeof(cl_mem), (void *)&img1.data )); args.push_back( make_pair( sizeof(cl_mem), (void *)&img1.data ));
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -81,9 +81,9 @@ namespace ...@@ -81,9 +81,9 @@ namespace
void RGB2Gray_caller(const oclMat &src, oclMat &dst, int bidx) void RGB2Gray_caller(const oclMat &src, oclMat &dst, int bidx)
{ {
vector<pair<size_t , const void *> > args; vector<pair<size_t , const void *> > args;
int channels = src.channels(); int channels = src.oclchannels();
char build_options[50]; char build_options[50];
//printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.channels(),bidx); //printf("depth:%d,channels:%d,bidx:%d\n",src.depth(),src.oclchannels(),bidx);
sprintf(build_options, "-D DEPTH_%d", src.depth()); sprintf(build_options, "-D DEPTH_%d", src.depth());
args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols)); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.cols));
args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows)); args.push_back( make_pair( sizeof(cl_int) , (void *)&src.rows));
...@@ -99,7 +99,7 @@ namespace ...@@ -99,7 +99,7 @@ namespace
void cvtColor_caller(const oclMat &src, oclMat &dst, int code, int dcn) void cvtColor_caller(const oclMat &src, oclMat &dst, int code, int dcn)
{ {
Size sz = src.size(); Size sz = src.size();
int scn = src.channels(), depth = src.depth(), bidx; int scn = src.oclchannels(), depth = src.depth(), bidx;
CV_Assert(depth == CV_8U || depth == CV_16U); CV_Assert(depth == CV_8U || depth == CV_16U);
......
...@@ -53,7 +53,10 @@ using namespace std; ...@@ -53,7 +53,10 @@ using namespace std;
#if !defined(HAVE_OPENCL) #if !defined(HAVE_OPENCL)
void cv::ocl::columnSum(const oclMat& src,oclMat& dst){ throw_nogpu(); } void cv::ocl::columnSum(const oclMat &src, oclMat &dst)
{
throw_nogpu();
}
#else /*!HAVE_OPENCL */ #else /*!HAVE_OPENCL */
...@@ -61,11 +64,11 @@ namespace cv ...@@ -61,11 +64,11 @@ namespace cv
{ {
namespace ocl namespace ocl
{ {
extern const char* imgproc_columnsum; extern const char *imgproc_columnsum;
} }
} }
void cv::ocl::columnSum(const oclMat& src,oclMat& dst) void cv::ocl::columnSum(const oclMat &src, oclMat &dst)
{ {
CV_Assert(src.type() == CV_32FC1); CV_Assert(src.type() == CV_32FC1);
......
This diff is collapsed.
This diff is collapsed.
...@@ -51,14 +51,17 @@ ...@@ -51,14 +51,17 @@
#include "clAmdBlas.h" #include "clAmdBlas.h"
#if !defined (HAVE_OPENCL) #if !defined (HAVE_OPENCL)
void cv::ocl::dft(const oclMat& src, oclMat& dst, int flags) { throw_nogpu(); } void cv::ocl::dft(const oclMat &src, oclMat &dst, int flags)
{
throw_nogpu();
}
#else #else
using namespace cv; using namespace cv;
void cv::ocl::gemm(const oclMat& src1, const oclMat& src2, double alpha, void cv::ocl::gemm(const oclMat &src1, const oclMat &src2, double alpha,
const oclMat& src3, double beta, oclMat& dst, int flags) const oclMat &src3, double beta, oclMat &dst, int flags)
{ {
CV_Assert(src1.cols == src2.rows && CV_Assert(src1.cols == src2.rows &&
(src3.empty() || src1.rows == src3.rows && src2.cols == src3.cols)); (src3.empty() || src1.rows == src3.rows && src2.cols == src3.cols));
CV_Assert(!(cv::GEMM_3_T & flags)); // cv::GEMM_3_T is not supported CV_Assert(!(cv::GEMM_3_T & flags)); // cv::GEMM_3_T is not supported
...@@ -73,8 +76,8 @@ using namespace cv; ...@@ -73,8 +76,8 @@ using namespace cv;
} }
openCLSafeCall( clAmdBlasSetup() ); openCLSafeCall( clAmdBlasSetup() );
const clAmdBlasTranspose transA = (cv::GEMM_1_T & flags)?clAmdBlasTrans:clAmdBlasNoTrans; const clAmdBlasTranspose transA = (cv::GEMM_1_T & flags) ? clAmdBlasTrans : clAmdBlasNoTrans;
const clAmdBlasTranspose transB = (cv::GEMM_2_T & flags)?clAmdBlasTrans:clAmdBlasNoTrans; const clAmdBlasTranspose transB = (cv::GEMM_2_T & flags) ? clAmdBlasTrans : clAmdBlasNoTrans;
const clAmdBlasOrder order = clAmdBlasRowMajor; const clAmdBlasOrder order = clAmdBlasRowMajor;
const int M = src1.rows; const int M = src1.rows;
...@@ -156,6 +159,6 @@ using namespace cv; ...@@ -156,6 +159,6 @@ using namespace cv;
break; break;
} }
clAmdBlasTeardown(); clAmdBlasTeardown();
} }
#endif #endif
#endif #endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -207,7 +207,7 @@ vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end) ...@@ -207,7 +207,7 @@ vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
return v; return v;
} }
const vector<MatType>& all_types() const vector<MatType> &all_types()
{ {
static vector<MatType> v = types(CV_8U, CV_64F, 1, 4); static vector<MatType> v = types(CV_8U, CV_64F, 1, 4);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment