OpenCL version of cv::buildPyramid
This commit is contained in:
parent
d9b24457fa
commit
48a084c236
@ -207,6 +207,7 @@ public:
|
||||
virtual bool fixedType() const;
|
||||
virtual bool needed() const;
|
||||
virtual Mat& getMatRef(int i=-1) const;
|
||||
virtual UMat& getUMatRef(int i=-1) const;
|
||||
virtual cuda::GpuMat& getGpuMatRef() const;
|
||||
virtual ogl::Buffer& getOGlBufferRef() const;
|
||||
virtual cuda::CudaMem& getCudaMemRef() const;
|
||||
|
@ -2484,6 +2484,23 @@ Mat& _OutputArray::getMatRef(int i) const
|
||||
}
|
||||
}
|
||||
|
||||
UMat& _OutputArray::getUMatRef(int i) const
|
||||
{
|
||||
int k = kind();
|
||||
if( i < 0 )
|
||||
{
|
||||
CV_Assert( k == UMAT );
|
||||
return *(UMat*)obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert( k == STD_VECTOR_UMAT );
|
||||
std::vector<UMat>& v = *(std::vector<UMat>*)obj;
|
||||
CV_Assert( i < (int)v.size() );
|
||||
return v[i];
|
||||
}
|
||||
}
|
||||
|
||||
cuda::GpuMat& _OutputArray::getGpuMatRef() const
|
||||
{
|
||||
int k = kind();
|
||||
|
@ -100,6 +100,35 @@ OCL_PERF_TEST_P(PyrUpFixture, PyrUp,
|
||||
SANITY_CHECK(dst, eps);
|
||||
}
|
||||
|
||||
///////////// buildPyramid ////////////////////////
|
||||
|
||||
typedef Size_MatType BuildPyramidFixture;
|
||||
|
||||
OCL_PERF_TEST_P(BuildPyramidFixture, BuildPyramid,
|
||||
::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), maxLevel = 5;
|
||||
const double eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : 1e-5;
|
||||
|
||||
checkDeviceMaxMemoryAllocSize(srcSize, type);
|
||||
|
||||
std::vector<UMat> dst(maxLevel);
|
||||
UMat src(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
OCL_TEST_CYCLE() cv::buildPyramid(src, dst, maxLevel);
|
||||
|
||||
UMat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];
|
||||
|
||||
SANITY_CHECK(dst0, eps);
|
||||
SANITY_CHECK(dst1, eps);
|
||||
SANITY_CHECK(dst2, eps);
|
||||
SANITY_CHECK(dst3, eps);
|
||||
SANITY_CHECK(dst4, eps);
|
||||
}
|
||||
|
||||
} } // namespace cvtest::ocl
|
||||
|
||||
#endif // HAVE_OPENCL
|
||||
|
@ -556,6 +556,16 @@ void cv::pyrUp( InputArray _src, OutputArray _dst, const Size& _dsz, int borderT
|
||||
|
||||
void cv::buildPyramid( InputArray _src, OutputArrayOfArrays _dst, int maxlevel, int borderType )
|
||||
{
|
||||
if (_src.dims() <= 2 && _dst.isUMatVector())
|
||||
{
|
||||
UMat src = _src.getUMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getUMatRef(0) = src;
|
||||
for( int i = 1; i <= maxlevel; i++ )
|
||||
pyrDown( _dst.getUMatRef(i-1), _dst.getUMatRef(i), Size(), borderType );
|
||||
return;
|
||||
}
|
||||
|
||||
Mat src = _src.getMat();
|
||||
_dst.create( maxlevel + 1, 1, 0 );
|
||||
_dst.getMatRef(0) = src;
|
||||
|
Loading…
x
Reference in New Issue
Block a user