Commit af59a75f authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

fixed bug with submatrix in some gpu functions

update gpu tests
parent 2ce6dd68
...@@ -59,56 +59,27 @@ namespace cv { namespace gpu { namespace device ...@@ -59,56 +59,27 @@ namespace cv { namespace gpu { namespace device
////////////////////////////////// CopyTo ///////////////////////////////// ////////////////////////////////// CopyTo /////////////////////////////////
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template<typename T> template <typename T> void copyToWithMask(DevMem2Db src, DevMem2Db dst, DevMem2Db mask, int channels, cudaStream_t stream)
__global__ void copy_to_with_mask(const T* mat_src, T* mat_dst, const uchar* mask, int cols, int rows, size_t step_mat, size_t step_mask, int channels)
{
size_t x = blockIdx.x * blockDim.x + threadIdx.x;
size_t y = blockIdx.y * blockDim.y + threadIdx.y;
if ((x < cols * channels ) && (y < rows))
if (mask[y * step_mask + x / channels] != 0)
{ {
size_t idx = y * ( step_mat >> shift_and_sizeof<T>::shift ) + x; cv::gpu::device::transform((DevMem2D_<T>)src, (DevMem2D_<T>)dst, identity<T>(), SingleMaskChannels(mask, channels), stream);
mat_dst[idx] = mat_src[idx];
}
} }
template<typename T> void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, int depth, int channels, DevMem2Db mask, cudaStream_t stream)
void copy_to_with_mask_run(DevMem2Db mat_src, DevMem2Db mat_dst, DevMem2Db mask, int channels, cudaStream_t stream)
{ {
dim3 threadsPerBlock(16,16, 1); typedef void (*func_t)(DevMem2Db src, DevMem2Db dst, DevMem2Db mask, int channels, cudaStream_t stream);
dim3 numBlocks ( divUp(mat_src.cols * channels , threadsPerBlock.x) , divUp(mat_src.rows , threadsPerBlock.y), 1);
copy_to_with_mask<T><<<numBlocks,threadsPerBlock, 0, stream>>> static func_t tab[] =
((T*)mat_src.data, (T*)mat_dst.data, (unsigned char*)mask.data, mat_src.cols, mat_src.rows, mat_src.step, mask.step, channels);
cudaSafeCall( cudaGetLastError() );
if (stream == 0)
cudaSafeCall ( cudaDeviceSynchronize() );
}
void copy_to_with_mask(DevMem2Db mat_src, DevMem2Db mat_dst, int depth, DevMem2Db mask, int channels, cudaStream_t stream)
{ {
typedef void (*CopyToFunc)(DevMem2Db mat_src, DevMem2Db mat_dst, DevMem2Db mask, int channels, cudaStream_t stream); copyToWithMask<unsigned char>,
copyToWithMask<signed char>,
static CopyToFunc tab[8] = copyToWithMask<unsigned short>,
{ copyToWithMask<short>,
copy_to_with_mask_run<unsigned char>, copyToWithMask<int>,
copy_to_with_mask_run<signed char>, copyToWithMask<float>,
copy_to_with_mask_run<unsigned short>, copyToWithMask<double>
copy_to_with_mask_run<short>,
copy_to_with_mask_run<int>,
copy_to_with_mask_run<float>,
copy_to_with_mask_run<double>,
0
}; };
CopyToFunc func = tab[depth]; tab[depth](src, dst, mask, channels, stream);
if (func == 0)
cv::gpu::error("Unsupported copyTo operation", __FILE__, __LINE__, "copy_to_with_mask");
func(mat_src, mat_dst, mask, channels, stream);
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -303,7 +274,7 @@ namespace cv { namespace gpu { namespace device ...@@ -303,7 +274,7 @@ namespace cv { namespace gpu { namespace device
cudaSafeCall( cudaSetDoubleForDevice(&alpha) ); cudaSafeCall( cudaSetDoubleForDevice(&alpha) );
cudaSafeCall( cudaSetDoubleForDevice(&beta) ); cudaSafeCall( cudaSetDoubleForDevice(&beta) );
Convertor<T, D> op(alpha, beta); Convertor<T, D> op(alpha, beta);
::cv::gpu::device::transform((DevMem2D_<T>)src, (DevMem2D_<D>)dst, op, stream); cv::gpu::device::transform((DevMem2D_<T>)src, (DevMem2D_<D>)dst, op, WithOutMask(), stream);
} }
void convert_gpu(DevMem2Db src, int sdepth, DevMem2Db dst, int ddepth, double alpha, double beta, cudaStream_t stream) void convert_gpu(DevMem2Db src, int sdepth, DevMem2Db dst, int ddepth, double alpha, double beta, cudaStream_t stream)
......
...@@ -348,7 +348,7 @@ namespace ...@@ -348,7 +348,7 @@ namespace
namespace cv { namespace gpu { namespace device namespace cv { namespace gpu { namespace device
{ {
void copy_to_with_mask(DevMem2Db src, DevMem2Db dst, int depth, DevMem2Db mask, int channels, cudaStream_t stream); void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, int depth, int channels, DevMem2Db mask, cudaStream_t stream);
template <typename T> template <typename T>
void set_to_gpu(DevMem2Db mat, const T* scalar, int channels, cudaStream_t stream); void set_to_gpu(DevMem2Db mat, const T* scalar, int channels, cudaStream_t stream);
...@@ -391,13 +391,13 @@ namespace ...@@ -391,13 +391,13 @@ namespace
template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, cudaStream_t stream) template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, cudaStream_t stream)
{ {
Scalar_<T> sf = s; Scalar_<T> sf = s;
::cv::gpu::device::set_to_gpu(src, sf.val, src.channels(), stream); cv::gpu::device::set_to_gpu(src, sf.val, src.channels(), stream);
} }
template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, const GpuMat& mask, cudaStream_t stream) template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, const GpuMat& mask, cudaStream_t stream)
{ {
Scalar_<T> sf = s; Scalar_<T> sf = s;
::cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream); cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream);
} }
} }
...@@ -405,17 +405,17 @@ namespace cv { namespace gpu ...@@ -405,17 +405,17 @@ namespace cv { namespace gpu
{ {
CV_EXPORTS void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream = 0) CV_EXPORTS void copyWithMask(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream = 0)
{ {
::cv::gpu::device::copy_to_with_mask(src, dst, src.depth(), mask, src.channels(), stream); cv::gpu::device::copyToWithMask_gpu(src.reshape(1), dst.reshape(1), src.depth(), src.channels(), mask, stream);
} }
CV_EXPORTS void convertTo(const GpuMat& src, GpuMat& dst) CV_EXPORTS void convertTo(const GpuMat& src, GpuMat& dst)
{ {
::cv::gpu::device::convert_gpu(src.reshape(1), src.depth(), dst.reshape(1), dst.depth(), 1.0, 0.0, 0); cv::gpu::device::convert_gpu(src.reshape(1), src.depth(), dst.reshape(1), dst.depth(), 1.0, 0.0, 0);
} }
CV_EXPORTS void convertTo(const GpuMat& src, GpuMat& dst, double alpha, double beta, cudaStream_t stream = 0) CV_EXPORTS void convertTo(const GpuMat& src, GpuMat& dst, double alpha, double beta, cudaStream_t stream = 0)
{ {
::cv::gpu::device::convert_gpu(src.reshape(1), src.depth(), dst.reshape(1), dst.depth(), alpha, beta, stream); cv::gpu::device::convert_gpu(src.reshape(1), src.depth(), dst.reshape(1), dst.depth(), alpha, beta, stream);
} }
CV_EXPORTS void setTo(GpuMat& src, Scalar s, cudaStream_t stream) CV_EXPORTS void setTo(GpuMat& src, Scalar s, cudaStream_t stream)
......
...@@ -74,7 +74,7 @@ namespace cv { namespace gpu { namespace device ...@@ -74,7 +74,7 @@ namespace cv { namespace gpu { namespace device
cudaSafeCall(cudaMemcpyToSymbol(crot1, rot + 3, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(crot1, rot + 3, sizeof(float) * 3));
cudaSafeCall(cudaMemcpyToSymbol(crot2, rot + 6, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(crot2, rot + 6, sizeof(float) * 3));
cudaSafeCall(cudaMemcpyToSymbol(ctransl, transl, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(ctransl, transl, sizeof(float) * 3));
::cv::gpu::device::transform(src, dst, TransformOp(), stream); cv::gpu::device::transform(src, dst, TransformOp(), WithOutMask(), stream);
} }
} // namespace transform_points } // namespace transform_points
...@@ -113,7 +113,7 @@ namespace cv { namespace gpu { namespace device ...@@ -113,7 +113,7 @@ namespace cv { namespace gpu { namespace device
cudaSafeCall(cudaMemcpyToSymbol(ctransl, transl, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(ctransl, transl, sizeof(float) * 3));
cudaSafeCall(cudaMemcpyToSymbol(cproj0, proj, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(cproj0, proj, sizeof(float) * 3));
cudaSafeCall(cudaMemcpyToSymbol(cproj1, proj + 3, sizeof(float) * 3)); cudaSafeCall(cudaMemcpyToSymbol(cproj1, proj + 3, sizeof(float) * 3));
::cv::gpu::device::transform(src, dst, ProjectOp(), stream); cv::gpu::device::transform(src, dst, ProjectOp(), WithOutMask(), stream);
} }
} // namespace project_points } // namespace project_points
......
...@@ -226,7 +226,7 @@ namespace cv { namespace gpu { namespace device ...@@ -226,7 +226,7 @@ namespace cv { namespace gpu { namespace device
traits::functor_type functor = traits::create_functor(); \ traits::functor_type functor = traits::create_functor(); \
typedef typename traits::functor_type::argument_type src_t; \ typedef typename traits::functor_type::argument_type src_t; \
typedef typename traits::functor_type::result_type dst_t; \ typedef typename traits::functor_type::result_type dst_t; \
::cv::gpu::device::transform((DevMem2D_<src_t>)src, (DevMem2D_<dst_t>)dst, functor, stream); \ cv::gpu::device::transform((DevMem2D_<src_t>)src, (DevMem2D_<dst_t>)dst, functor, WithOutMask(), stream); \
} }
#define OPENCV_GPU_IMPLEMENT_CVTCOLOR_ONE(name) \ #define OPENCV_GPU_IMPLEMENT_CVTCOLOR_ONE(name) \
......
This diff is collapsed.
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include "opencv2/gpu/device/limits.hpp" #include "opencv2/gpu/device/limits.hpp"
#include "opencv2/gpu/device/saturate_cast.hpp" #include "opencv2/gpu/device/saturate_cast.hpp"
#include "opencv2/gpu/device/vec_math.hpp" #include "opencv2/gpu/device/vec_math.hpp"
#include "opencv2/gpu/device/transform.hpp"
namespace cv { namespace gpu { namespace device namespace cv { namespace gpu { namespace device
{ {
......
This diff is collapsed.
This diff is collapsed.
...@@ -114,7 +114,7 @@ namespace cv { namespace gpu { namespace device ...@@ -114,7 +114,7 @@ namespace cv { namespace gpu { namespace device
namespace imgproc namespace imgproc
{ {
template <typename T> template <typename T>
void remap_gpu(const DevMem2Db& src, const DevMem2Df& xmap, const DevMem2Df& ymap, const DevMem2Db& dst, void remap_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst,
int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc); int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);
} }
}}} }}}
...@@ -123,8 +123,9 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp ...@@ -123,8 +123,9 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp
{ {
using namespace ::cv::gpu::device::imgproc; using namespace ::cv::gpu::device::imgproc;
typedef void (*caller_t)(const DevMem2Db& src, const DevMem2Df& xmap, const DevMem2Df& ymap, const DevMem2Db& dst, int interpolation, typedef void (*caller_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst, int interpolation,
int borderMode, const float* borderValue, cudaStream_t stream, int cc); int borderMode, const float* borderValue, cudaStream_t stream, int cc);
static const caller_t callers[6][4] = static const caller_t callers[6][4] =
{ {
{remap_gpu<uchar>, 0/*remap_gpu<uchar2>*/, remap_gpu<uchar3>, remap_gpu<uchar4>}, {remap_gpu<uchar>, 0/*remap_gpu<uchar2>*/, remap_gpu<uchar3>, remap_gpu<uchar4>},
...@@ -155,7 +156,12 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp ...@@ -155,7 +156,12 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp
DeviceInfo info; DeviceInfo info;
int cc = info.majorVersion() * 10 + info.minorVersion(); int cc = info.majorVersion() * 10 + info.minorVersion();
func(src, xmap, ymap, dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(stream), cc); Size wholeSize;
Point ofs;
src.locateROI(wholeSize, ofs);
func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, xmap, ymap,
dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(stream), cc);
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -310,7 +316,8 @@ namespace cv { namespace gpu { namespace device ...@@ -310,7 +316,8 @@ namespace cv { namespace gpu { namespace device
{ {
namespace imgproc namespace imgproc
{ {
template <typename T> void resize_gpu(const DevMem2Db& src, float fx, float fy, const DevMem2Db& dst, int interpolation, cudaStream_t stream); template <typename T> void resize_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy,
DevMem2Db dst, int interpolation, cudaStream_t stream);
} }
}}} }}}
...@@ -343,17 +350,24 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub ...@@ -343,17 +350,24 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
cudaStream_t stream = StreamAccessor::getStream(s); cudaStream_t stream = StreamAccessor::getStream(s);
Size wholeSize;
Point ofs;
src.locateROI(wholeSize, ofs);
if ((src.type() == CV_8UC1 || src.type() == CV_8UC4) && (interpolation == INTER_NEAREST || interpolation == INTER_LINEAR)) if ((src.type() == CV_8UC1 || src.type() == CV_8UC4) && (interpolation == INTER_NEAREST || interpolation == INTER_LINEAR))
{ {
static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC, 0, NPPI_INTER_LANCZOS}; static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC, 0, NPPI_INTER_LANCZOS};
NppiSize srcsz; NppiSize srcsz;
srcsz.width = src.cols; srcsz.width = wholeSize.width;
srcsz.height = src.rows; srcsz.height = wholeSize.height;
NppiRect srcrect; NppiRect srcrect;
srcrect.x = srcrect.y = 0; srcrect.x = ofs.x;
srcrect.y = ofs.y;
srcrect.width = src.cols; srcrect.width = src.cols;
srcrect.height = src.rows; srcrect.height = src.rows;
NppiSize dstsz; NppiSize dstsz;
dstsz.width = dst.cols; dstsz.width = dst.cols;
dstsz.height = dst.rows; dstsz.height = dst.rows;
...@@ -362,12 +376,12 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub ...@@ -362,12 +376,12 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
if (src.type() == CV_8UC1) if (src.type() == CV_8UC1)
{ {
nppSafeCall( nppiResize_8u_C1R(src.ptr<Npp8u>(), srcsz, static_cast<int>(src.step), srcrect, nppSafeCall( nppiResize_8u_C1R(src.datastart, srcsz, static_cast<int>(src.step), srcrect,
dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) ); dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) );
} }
else else
{ {
nppSafeCall( nppiResize_8u_C4R(src.ptr<Npp8u>(), srcsz, static_cast<int>(src.step), srcrect, nppSafeCall( nppiResize_8u_C4R(src.datastart, srcsz, static_cast<int>(src.step), srcrect,
dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) ); dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) );
} }
...@@ -378,7 +392,8 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub ...@@ -378,7 +392,8 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
{ {
using namespace ::cv::gpu::device::imgproc; using namespace ::cv::gpu::device::imgproc;
typedef void (*caller_t)(const DevMem2Db& src, float fx, float fy, const DevMem2Db& dst, int interpolation, cudaStream_t stream); typedef void (*caller_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy, DevMem2Db dst, int interpolation, cudaStream_t stream);
static const caller_t callers[6][4] = static const caller_t callers[6][4] =
{ {
{resize_gpu<uchar>, 0/*resize_gpu<uchar2>*/, resize_gpu<uchar3>, resize_gpu<uchar4>}, {resize_gpu<uchar>, 0/*resize_gpu<uchar2>*/, resize_gpu<uchar3>, resize_gpu<uchar4>},
...@@ -389,7 +404,8 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub ...@@ -389,7 +404,8 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
{resize_gpu<float>, 0/*resize_gpu<float2>*/, resize_gpu<float3>, resize_gpu<float4>} {resize_gpu<float>, 0/*resize_gpu<float2>*/, resize_gpu<float3>, resize_gpu<float4>}
}; };
callers[src.depth()][src.channels() - 1](src, static_cast<float>(fx), static_cast<float>(fy), dst, interpolation, stream); callers[src.depth()][src.channels() - 1](src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y,
static_cast<float>(fx), static_cast<float>(fy), dst, interpolation, stream);
} }
} }
...@@ -527,13 +543,20 @@ namespace ...@@ -527,13 +543,20 @@ namespace
dst.create(dsize, src.type()); dst.create(dsize, src.type());
Size wholeSize;
Point ofs;
src.locateROI(wholeSize, ofs);
NppiSize srcsz; NppiSize srcsz;
srcsz.height = src.rows; srcsz.height = wholeSize.height;
srcsz.width = src.cols; srcsz.width = wholeSize.width;
NppiRect srcroi; NppiRect srcroi;
srcroi.x = srcroi.y = 0; srcroi.x = ofs.x;
srcroi.y = ofs.y;
srcroi.height = src.rows; srcroi.height = src.rows;
srcroi.width = src.cols; srcroi.width = src.cols;
NppiRect dstroi; NppiRect dstroi;
dstroi.x = dstroi.y = 0; dstroi.x = dstroi.y = 0;
dstroi.height = dst.rows; dstroi.height = dst.rows;
...@@ -546,19 +569,19 @@ namespace ...@@ -546,19 +569,19 @@ namespace
switch (src.depth()) switch (src.depth())
{ {
case CV_8U: case CV_8U:
nppSafeCall( npp_warp_8u[src.channels()][warpInd](src.ptr<Npp8u>(), srcsz, static_cast<int>(src.step), srcroi, nppSafeCall( npp_warp_8u[src.channels()][warpInd]((Npp8u*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,
dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) ); dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );
break; break;
case CV_16U: case CV_16U:
nppSafeCall( npp_warp_16u[src.channels()][warpInd](src.ptr<Npp16u>(), srcsz, static_cast<int>(src.step), srcroi, nppSafeCall( npp_warp_16u[src.channels()][warpInd]((Npp16u*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,
dst.ptr<Npp16u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) ); dst.ptr<Npp16u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );
break; break;
case CV_32S: case CV_32S:
nppSafeCall( npp_warp_32s[src.channels()][warpInd](src.ptr<Npp32s>(), srcsz, static_cast<int>(src.step), srcroi, nppSafeCall( npp_warp_32s[src.channels()][warpInd]((Npp32s*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,
dst.ptr<Npp32s>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) ); dst.ptr<Npp32s>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );
break; break;
case CV_32F: case CV_32F:
nppSafeCall( npp_warp_32f[src.channels()][warpInd](src.ptr<Npp32f>(), srcsz, static_cast<int>(src.step), srcroi, nppSafeCall( npp_warp_32f[src.channels()][warpInd]((Npp32f*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,
dst.ptr<Npp32f>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) ); dst.ptr<Npp32f>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );
break; break;
default: default:
......
...@@ -386,20 +386,6 @@ namespace cv { namespace gpu { namespace device ...@@ -386,20 +386,6 @@ namespace cv { namespace gpu { namespace device
cudaSafeCall( cudaDeviceSynchronize() ); cudaSafeCall( cudaDeviceSynchronize() );
} }
}; };
template <typename T, typename D, typename UnOp, typename Mask>
static inline void transform_caller(DevMem2D_<T> src, DevMem2D_<D> dst, UnOp op, Mask mask, cudaStream_t stream)
{
typedef TransformFunctorTraits<UnOp> ft;
TransformDispatcher<VecTraits<T>::cn == 1 && VecTraits<D>::cn == 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream);
}
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
static inline void transform_caller(DevMem2D_<T1> src1, DevMem2D_<T2> src2, DevMem2D_<D> dst, BinOp op, Mask mask, cudaStream_t stream)
{
typedef TransformFunctorTraits<BinOp> ft;
TransformDispatcher<VecTraits<T1>::cn == 1 && VecTraits<T2>::cn == 1 && VecTraits<D>::cn == 1 && ft::smart_shift != 1>::call(src1, src2, dst, op, mask, stream);
}
} // namespace transform_detail } // namespace transform_detail
}}} // namespace cv { namespace gpu { namespace device }}} // namespace cv { namespace gpu { namespace device
......
...@@ -49,28 +49,18 @@ ...@@ -49,28 +49,18 @@
namespace cv { namespace gpu { namespace device namespace cv { namespace gpu { namespace device
{ {
template <typename T, typename D, typename UnOp> template <typename T, typename D, typename UnOp, typename Mask>
static inline void transform(DevMem2D_<T> src, DevMem2D_<D> dst, UnOp op, cudaStream_t stream = 0) static inline void transform(DevMem2D_<T> src, DevMem2D_<D> dst, UnOp op, Mask mask, cudaStream_t stream)
{ {
transform_detail::transform_caller(src, dst, op, WithOutMask(), stream); typedef TransformFunctorTraits<UnOp> ft;
transform_detail::TransformDispatcher<VecTraits<T>::cn == 1 && VecTraits<D>::cn == 1 && ft::smart_shift != 1>::call(src, dst, op, mask, stream);
} }
template <typename T, typename D, typename UnOp> template <typename T1, typename T2, typename D, typename BinOp, typename Mask>
static inline void transform(DevMem2D_<T> src, DevMem2D_<D> dst, PtrStepb mask, UnOp op, cudaStream_t stream = 0) static inline void transform(DevMem2D_<T1> src1, DevMem2D_<T2> src2, DevMem2D_<D> dst, BinOp op, Mask mask, cudaStream_t stream)
{ {
transform_detail::transform_caller(src, dst, op, SingleMask(mask), stream); typedef TransformFunctorTraits<BinOp> ft;
} transform_detail::TransformDispatcher<VecTraits<T1>::cn == 1 && VecTraits<T2>::cn == 1 && VecTraits<D>::cn == 1 && ft::smart_shift != 1>::call(src1, src2, dst, op, mask, stream);
template <typename T1, typename T2, typename D, typename BinOp>
static inline void transform(DevMem2D_<T1> src1, DevMem2D_<T2> src2, DevMem2D_<D> dst, BinOp op, cudaStream_t stream = 0)
{
transform_detail::transform_caller(src1, src2, dst, op, WithOutMask(), stream);
}
template <typename T1, typename T2, typename D, typename BinOp>
static inline void transform(DevMem2D_<T1> src1, DevMem2D_<T2> src2, DevMem2D_<D> dst, PtrStepb mask, BinOp op, cudaStream_t stream = 0)
{
transform_detail::transform_caller(src1, src2, dst, op, SingleMask(mask), stream);
} }
}}} }}}
......
...@@ -69,7 +69,7 @@ namespace cv { namespace gpu { namespace device ...@@ -69,7 +69,7 @@ namespace cv { namespace gpu { namespace device
struct SingleMask struct SingleMask
{ {
explicit __host__ __device__ __forceinline__ SingleMask(const PtrStepb& mask_) : mask(mask_) {} explicit __host__ __device__ __forceinline__ SingleMask(PtrStepb mask_) : mask(mask_) {}
__device__ __forceinline__ bool operator()(int y, int x) const __device__ __forceinline__ bool operator()(int y, int x) const
{ {
...@@ -79,6 +79,19 @@ namespace cv { namespace gpu { namespace device ...@@ -79,6 +79,19 @@ namespace cv { namespace gpu { namespace device
PtrStepb mask; PtrStepb mask;
}; };
struct SingleMaskChannels
{
__host__ __device__ __forceinline__ SingleMaskChannels(PtrStepb mask_, int channels_) : mask(mask_), channels(channels_) {}
__device__ __forceinline__ bool operator()(int y, int x) const
{
return mask.ptr(y)[x / channels] != 0;
}
PtrStepb mask;
int channels;
};
struct MaskCollection struct MaskCollection
{ {
explicit __host__ __device__ __forceinline__ MaskCollection(PtrStepb* maskCollection_) : maskCollection(maskCollection_) {} explicit __host__ __device__ __forceinline__ MaskCollection(PtrStepb* maskCollection_) : maskCollection(maskCollection_) {}
......
This diff is collapsed.
...@@ -43,10 +43,13 @@ ...@@ -43,10 +43,13 @@
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
using namespace cvtest;
using namespace testing;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// BlockMatching // BlockMatching
struct StereoBlockMatching : testing::TestWithParam<cv::gpu::DeviceInfo> struct StereoBlockMatching : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::Mat img_l; cv::Mat img_l;
cv::Mat img_r; cv::Mat img_r;
...@@ -72,8 +75,6 @@ struct StereoBlockMatching : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -72,8 +75,6 @@ struct StereoBlockMatching : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoBlockMatching, Regression) TEST_P(StereoBlockMatching, Regression)
{ {
PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
ASSERT_NO_THROW( ASSERT_NO_THROW(
...@@ -90,12 +91,12 @@ TEST_P(StereoBlockMatching, Regression) ...@@ -90,12 +91,12 @@ TEST_P(StereoBlockMatching, Regression)
EXPECT_MAT_NEAR(img_template, disp, 0.0); EXPECT_MAT_NEAR(img_template, disp, 0.0);
} }
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, StereoBlockMatching, ALL_DEVICES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// BeliefPropagation // BeliefPropagation
struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo> struct StereoBeliefPropagation : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::Mat img_l; cv::Mat img_l;
cv::Mat img_r; cv::Mat img_r;
...@@ -121,8 +122,6 @@ struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -121,8 +122,6 @@ struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoBeliefPropagation, Regression) TEST_P(StereoBeliefPropagation, Regression)
{ {
PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
ASSERT_NO_THROW( ASSERT_NO_THROW(
...@@ -139,12 +138,12 @@ TEST_P(StereoBeliefPropagation, Regression) ...@@ -139,12 +138,12 @@ TEST_P(StereoBeliefPropagation, Regression)
EXPECT_MAT_NEAR(img_template, disp, 0.0); EXPECT_MAT_NEAR(img_template, disp, 0.0);
} }
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// ConstantSpaceBP // ConstantSpaceBP
struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo> struct StereoConstantSpaceBP : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::Mat img_l; cv::Mat img_l;
cv::Mat img_r; cv::Mat img_r;
...@@ -174,8 +173,6 @@ struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -174,8 +173,6 @@ struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoConstantSpaceBP, Regression) TEST_P(StereoConstantSpaceBP, Regression)
{ {
PRINT_PARAM(devInfo);
cv::Mat disp; cv::Mat disp;
ASSERT_NO_THROW( ASSERT_NO_THROW(
...@@ -192,12 +189,12 @@ TEST_P(StereoConstantSpaceBP, Regression) ...@@ -192,12 +189,12 @@ TEST_P(StereoConstantSpaceBP, Regression)
EXPECT_MAT_NEAR(img_template, disp, 1.0); EXPECT_MAT_NEAR(img_template, disp, 1.0);
} }
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// projectPoints // projectPoints
struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo> struct ProjectPoints : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
...@@ -231,8 +228,6 @@ struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -231,8 +228,6 @@ struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(ProjectPoints, Accuracy) TEST_P(ProjectPoints, Accuracy)
{ {
PRINT_PARAM(devInfo);
cv::Mat dst; cv::Mat dst;
ASSERT_NO_THROW( ASSERT_NO_THROW(
...@@ -257,12 +252,12 @@ TEST_P(ProjectPoints, Accuracy) ...@@ -257,12 +252,12 @@ TEST_P(ProjectPoints, Accuracy)
} }
} }
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, ALL_DEVICES);
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// transformPoints // transformPoints
struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo> struct TransformPoints : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
...@@ -289,8 +284,6 @@ struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -289,8 +284,6 @@ struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(TransformPoints, Accuracy) TEST_P(TransformPoints, Accuracy)
{ {
PRINT_PARAM(devInfo);
cv::Mat dst; cv::Mat dst;
ASSERT_NO_THROW( ASSERT_NO_THROW(
...@@ -318,12 +311,12 @@ TEST_P(TransformPoints, Accuracy) ...@@ -318,12 +311,12 @@ TEST_P(TransformPoints, Accuracy)
} }
} }
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, ALL_DEVICES);
/////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////
// solvePnPRansac // solvePnPRansac
struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo> struct SolvePnPRansac : TestWithParam<cv::gpu::DeviceInfo>
{ {
static const int num_points = 5000; static const int num_points = 5000;
...@@ -360,8 +353,6 @@ struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -360,8 +353,6 @@ struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(SolvePnPRansac, Accuracy) TEST_P(SolvePnPRansac, Accuracy)
{ {
PRINT_PARAM(devInfo);
cv::Mat rvec, tvec; cv::Mat rvec, tvec;
std::vector<int> inliers; std::vector<int> inliers;
...@@ -374,6 +365,6 @@ TEST_P(SolvePnPRansac, Accuracy) ...@@ -374,6 +365,6 @@ TEST_P(SolvePnPRansac, Accuracy)
ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3f); ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3f);
} }
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, ALL_DEVICES);
#endif // HAVE_CUDA #endif // HAVE_CUDA
This diff is collapsed.
This diff is collapsed.
...@@ -41,25 +41,53 @@ ...@@ -41,25 +41,53 @@
#include "test_precomp.hpp" #include "test_precomp.hpp"
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature) using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
GpuMat loadMat(const Mat& m, bool useRoi)
{
Size size = m.size();
Size size0 = size;
if (useRoi)
{
RNG& rng = TS::ptr()->get_rng();
size0.width += rng.uniform(5, 15);
size0.height += rng.uniform(5, 15);
}
GpuMat d_m(size0, m.type());
if (size0 != size)
d_m = d_m(Rect((size0.width - size.width) / 2, (size0.height - size.height) / 2, size.width, size.height));
d_m.upload(m);
return d_m;
}
bool supportFeature(const DeviceInfo& info, FeatureSet feature)
{ {
return cv::gpu::TargetArchs::builtWith(feature) && info.supports(feature); return TargetArchs::builtWith(feature) && info.supports(feature);
} }
const std::vector<cv::gpu::DeviceInfo>& devices() const vector<DeviceInfo>& devices()
{ {
static std::vector<cv::gpu::DeviceInfo> devs; static vector<DeviceInfo> devs;
static bool first = true; static bool first = true;
if (first) if (first)
{ {
int deviceCount = cv::gpu::getCudaEnabledDeviceCount(); int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount); devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i) for (int i = 0; i < deviceCount; ++i)
{ {
cv::gpu::DeviceInfo info(i); DeviceInfo info(i);
if (info.isCompatible()) if (info.isCompatible())
devs.push_back(info); devs.push_back(info);
} }
...@@ -70,19 +98,19 @@ const std::vector<cv::gpu::DeviceInfo>& devices() ...@@ -70,19 +98,19 @@ const std::vector<cv::gpu::DeviceInfo>& devices()
return devs; return devs;
} }
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature) vector<DeviceInfo> devices(FeatureSet feature)
{ {
const std::vector<cv::gpu::DeviceInfo>& d = devices(); const vector<DeviceInfo>& d = devices();
std::vector<cv::gpu::DeviceInfo> devs_filtered; vector<DeviceInfo> devs_filtered;
if (cv::gpu::TargetArchs::builtWith(feature)) if (TargetArchs::builtWith(feature))
{ {
devs_filtered.reserve(d.size()); devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i) for (size_t i = 0, size = d.size(); i < size; ++i)
{ {
const cv::gpu::DeviceInfo& info = d[i]; const DeviceInfo& info = d[i];
if (info.supports(feature)) if (info.supports(feature))
devs_filtered.push_back(info); devs_filtered.push_back(info);
...@@ -92,9 +120,9 @@ std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature) ...@@ -92,9 +120,9 @@ std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature)
return devs_filtered; return devs_filtered;
} }
std::vector<int> types(int depth_start, int depth_end, int cn_start, int cn_end) vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end)
{ {
std::vector<int> v; vector<MatType> v;
v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1)); v.reserve((depth_end - depth_start + 1) * (cn_end - cn_start + 1));
...@@ -109,46 +137,39 @@ std::vector<int> types(int depth_start, int depth_end, int cn_start, int cn_end) ...@@ -109,46 +137,39 @@ std::vector<int> types(int depth_start, int depth_end, int cn_start, int cn_end)
return v; return v;
} }
const std::vector<int>& all_types() const vector<MatType>& all_types()
{ {
static std::vector<int> v = types(CV_8U, CV_64F, 1, 4); static vector<MatType> v = types(CV_8U, CV_64F, 1, 4);
return v; return v;
} }
cv::Mat readImage(const std::string& fileName, int flags) Mat readImage(const string& fileName, int flags)
{ {
return cv::imread(std::string(cvtest::TS::ptr()->get_data_path()) + fileName, flags); return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
} }
double checkNorm(const cv::Mat& m1, const cv::Mat& m2) double checkNorm(const Mat& m1, const Mat& m2)
{ {
return cv::norm(m1, m2, cv::NORM_INF); return norm(m1, m2, NORM_INF);
} }
double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2) double checkSimilarity(const Mat& m1, const Mat& m2)
{ {
cv::Mat diff; Mat diff;
cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED); matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);
return std::abs(diff.at<float>(0, 0) - 1.f); return std::abs(diff.at<float>(0, 0) - 1.f);
} }
namespace cv void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
{ {
std::ostream& operator << (std::ostream& os, const Size& sz) (*os) << info.name();
{ }
return os << sz.width << "x" << sz.height;
}
std::ostream& operator << (std::ostream& os, const Scalar& s)
{
return os << "[" << s[0] << ", " << s[1] << ", " << s[2] << ", " << s[3] << "]";
}
namespace gpu void PrintTo(const UseRoi& useRoi, std::ostream* os)
{ {
std::ostream& operator << (std::ostream& os, const DeviceInfo& info) if (useRoi)
{ (*os) << "sub matrix";
return os << info.name(); else
} (*os) << "whole matrix";
}
} }
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#ifndef __OPENCV_TEST_GPU_BASE_HPP__ #ifndef __OPENCV_TEST_GPU_BASE_HPP__
#define __OPENCV_TEST_GPU_BASE_HPP__ #define __OPENCV_TEST_GPU_BASE_HPP__
cv::gpu::GpuMat loadMat(const cv::Mat& m, bool useRoi = false);
//! return true if device supports specified feature and gpu module was built with support the feature. //! return true if device supports specified feature and gpu module was built with support the feature.
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature); bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
...@@ -50,30 +52,12 @@ const std::vector<cv::gpu::DeviceInfo>& devices(); ...@@ -50,30 +52,12 @@ const std::vector<cv::gpu::DeviceInfo>& devices();
//! return all devices compatible with current gpu module build which support specified feature. //! return all devices compatible with current gpu module build which support specified feature.
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature); std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);
//! return vector with types from specified range.
std::vector<int> 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).
const std::vector<int>& all_types();
//! read image from testdata folder. //! read image from testdata folder.
cv::Mat readImage(const std::string& fileName, int flags = CV_LOAD_IMAGE_COLOR); cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
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 OSTR_NAME(suf) ostr_ ## suf
#define PRINT_PARAM(name) \
std::ostringstream OSTR_NAME(name); \
OSTR_NAME(name) << # name << ": " << name; \
SCOPED_TRACE(OSTR_NAME(name).str());
#define PRINT_TYPE(type) \
std::ostringstream OSTR_NAME(type); \
OSTR_NAME(type) << # type << ": " << cvtest::getTypeName(type) << "c" << CV_MAT_CN(type); \
SCOPED_TRACE(OSTR_NAME(type).str());
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \ #define EXPECT_MAT_NEAR(mat1, mat2, eps) \
{ \ { \
ASSERT_EQ(mat1.type(), mat2.type()); \ ASSERT_EQ(mat1.type(), mat2.type()); \
...@@ -88,16 +72,66 @@ double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2); ...@@ -88,16 +72,66 @@ double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2);
EXPECT_LE(checkSimilarity(mat1, mat2), eps); \ EXPECT_LE(checkSimilarity(mat1, mat2), eps); \
} }
namespace cv { namespace gpu
{
void PrintTo(const DeviceInfo& info, std::ostream* os);
}}
using perf::MatDepth;
using perf::MatType;
//! return vector with types from specified range.
std::vector<MatType> types(int depth_start, int depth_end, int cn_start, int cn_end);
//! for gtest ASSERT //! return vector with all types (depth: CV_8U-CV_64F, channels: 1-4).
namespace cv const std::vector<MatType>& all_types();
class UseRoi
{ {
std::ostream& operator << (std::ostream& os, const Size& sz); public:
std::ostream& operator << (std::ostream& os, const Scalar& s); inline UseRoi(bool val = false) : val_(val) {}
namespace gpu
{ inline operator bool() const { return val_; }
std::ostream& operator << (std::ostream& os, const DeviceInfo& info);
} private:
} bool val_;
};
void PrintTo(const UseRoi& 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(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};
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_FLAGS(GemmFlags, cv::GEMM_1_T, cv::GEMM_2_T, cv::GEMM_3_T);
CV_ENUM(DistType, cv::gpu::BruteForceMatcher_GPU_base::L1Dist, cv::gpu::BruteForceMatcher_GPU_base::L2Dist)
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC)
CV_ENUM(Border, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_FLAGS(WarpFlags, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::WARP_INVERSE_MAP)
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
#define ALL_DEVICES testing::ValuesIn(devices())
#define DEVICES(feature) testing::ValuesIn(devices(feature))
#define ALL_TYPES testing::ValuesIn(all_types())
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))
#define USE_ROI testing::Values(false, true)
#endif // __OPENCV_TEST_GPU_BASE_HPP__ #endif // __OPENCV_TEST_GPU_BASE_HPP__
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
using namespace cvtest;
using namespace testing;
//#define DUMP //#define DUMP
struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor
...@@ -169,7 +172,7 @@ struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor ...@@ -169,7 +172,7 @@ struct CV_GpuHogDetectTestRunner : cv::gpu::HOGDescriptor
#endif #endif
}; };
struct HogDetect : testing::TestWithParam<cv::gpu::DeviceInfo> struct Detect : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
...@@ -181,17 +184,15 @@ struct HogDetect : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -181,17 +184,15 @@ struct HogDetect : testing::TestWithParam<cv::gpu::DeviceInfo>
} }
}; };
TEST_P(HogDetect, Accuracy) TEST_P(Detect, Accuracy)
{ {
PRINT_PARAM(devInfo);
ASSERT_NO_THROW( ASSERT_NO_THROW(
CV_GpuHogDetectTestRunner runner; CV_GpuHogDetectTestRunner runner;
runner.run(); runner.run();
); );
} }
INSTANTIATE_TEST_CASE_P(HOG, HogDetect, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(HOG, Detect, ALL_DEVICES);
struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor
{ {
...@@ -301,7 +302,7 @@ struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor ...@@ -301,7 +302,7 @@ struct CV_GpuHogGetDescriptorsTestRunner : cv::gpu::HOGDescriptor
int block_hist_size; int block_hist_size;
}; };
struct HogGetDescriptors : testing::TestWithParam<cv::gpu::DeviceInfo> struct GetDescriptors : TestWithParam<cv::gpu::DeviceInfo>
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
...@@ -313,16 +314,14 @@ struct HogGetDescriptors : testing::TestWithParam<cv::gpu::DeviceInfo> ...@@ -313,16 +314,14 @@ struct HogGetDescriptors : testing::TestWithParam<cv::gpu::DeviceInfo>
} }
}; };
TEST_P(HogGetDescriptors, Accuracy) TEST_P(GetDescriptors, Accuracy)
{ {
PRINT_PARAM(devInfo);
ASSERT_NO_THROW( ASSERT_NO_THROW(
CV_GpuHogGetDescriptorsTestRunner runner; CV_GpuHogGetDescriptorsTestRunner runner;
runner.run(); runner.run();
); );
} }
INSTANTIATE_TEST_CASE_P(HOG, HogGetDescriptors, testing::ValuesIn(devices())); INSTANTIATE_TEST_CASE_P(HOG, GetDescriptors, ALL_DEVICES);
#endif // HAVE_CUDA #endif // HAVE_CUDA
This diff is collapsed.
...@@ -42,8 +42,15 @@ ...@@ -42,8 +42,15 @@
#include "test_precomp.hpp" #include "test_precomp.hpp"
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
#include <cuda_runtime_api.h> #include <cuda_runtime_api.h>
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
void print_info() void print_info()
{ {
printf("\n"); printf("\n");
...@@ -67,7 +74,7 @@ void print_info() ...@@ -67,7 +74,7 @@ void print_info()
# endif # endif
#endif #endif
int deviceCount = cv::gpu::getCudaEnabledDeviceCount(); int deviceCount = getCudaEnabledDeviceCount();
int driver; int driver;
cudaDriverGetVersion(&driver); cudaDriverGetVersion(&driver);
...@@ -75,10 +82,10 @@ void print_info() ...@@ -75,10 +82,10 @@ void print_info()
printf("CUDA Runtime version: %d\n", CUDART_VERSION); printf("CUDA Runtime version: %d\n", CUDART_VERSION);
printf("CUDA device count: %d\n\n", deviceCount); printf("CUDA device count: %d\n\n", deviceCount);
for (int i = 0; i < deviceCount; ++i) for (int i = 0; i < deviceCount; ++i)
{ {
cv::gpu::DeviceInfo info(i); DeviceInfo info(i);
printf("Device %d:\n", i); printf("Device %d:\n", i);
printf(" Name: %s\n", info.name().c_str()); printf(" Name: %s\n", info.name().c_str());
printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion()); printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion());
...@@ -106,14 +113,14 @@ extern OutputLevel nvidiaTestOutputLevel; ...@@ -106,14 +113,14 @@ extern OutputLevel nvidiaTestOutputLevel;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cvtest::TS::ptr()->init("gpu"); TS::ptr()->init("gpu");
testing::InitGoogleTest(&argc, argv); InitGoogleTest(&argc, argv);
const char* keys ="{ nvtest_output_level | nvtest_output_level | none | NVidia test verbosity level }"; const char* keys ="{ nvtest_output_level | nvtest_output_level | none | NVidia test verbosity level }";
cv::CommandLineParser parser(argc, (const char**)argv, keys); CommandLineParser parser(argc, (const char**)argv, keys);
std::string outputLevel = parser.get<std::string>("nvtest_output_level", "none"); string outputLevel = parser.get<string>("nvtest_output_level", "none");
if (outputLevel == "none") if (outputLevel == "none")
nvidiaTestOutputLevel = OutputLevelNone; nvidiaTestOutputLevel = OutputLevelNone;
...@@ -123,6 +130,7 @@ int main(int argc, char** argv) ...@@ -123,6 +130,7 @@ int main(int argc, char** argv)
nvidiaTestOutputLevel = OutputLevelFull; nvidiaTestOutputLevel = OutputLevelFull;
print_info(); print_info();
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "opencv2/calib3d/calib3d.hpp" #include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/ts/ts.hpp" #include "opencv2/ts/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
#include "opencv2/gpu/gpu.hpp" #include "opencv2/gpu/gpu.hpp"
#include "test_gpu_base.hpp" #include "test_gpu_base.hpp"
......
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