|
|
|
@ -47,6 +47,7 @@ |
|
|
|
|
// */
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp" |
|
|
|
|
#include "opencl_kernels.hpp" |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
@ -1901,7 +1902,7 @@ private: |
|
|
|
|
}; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
static bool ocl_resize( InputArray _src, OutputArray _dst, |
|
|
|
|
static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize, |
|
|
|
|
double fx, double fy, int interpolation) |
|
|
|
|
{ |
|
|
|
|
int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); |
|
|
|
@ -1909,7 +1910,9 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, |
|
|
|
|
(interpolation == INTER_NEAREST || |
|
|
|
|
(interpolation == INTER_LINEAR && (depth == CV_8U || depth == CV_32F)))) ) |
|
|
|
|
return false; |
|
|
|
|
UMat src = _src.getUMat(), dst = _dst.getUMat(); |
|
|
|
|
UMat src = _src.getUMat(); |
|
|
|
|
_dst.create(dsize, type); |
|
|
|
|
UMat dst = _dst.getUMat(); |
|
|
|
|
ocl::Kernel k; |
|
|
|
|
|
|
|
|
|
if (interpolation == INTER_LINEAR) |
|
|
|
@ -2051,25 +2054,26 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize, |
|
|
|
|
Size ssize = _src.size(); |
|
|
|
|
|
|
|
|
|
CV_Assert( ssize.area() > 0 ); |
|
|
|
|
CV_Assert( dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0) ); |
|
|
|
|
if( !dsize.area() ) |
|
|
|
|
CV_Assert( dsize.area() > 0 || (inv_scale_x > 0 && inv_scale_y > 0) ); |
|
|
|
|
if( dsize.area() == 0 ) |
|
|
|
|
{ |
|
|
|
|
dsize = Size(saturate_cast<int>(ssize.width*inv_scale_x), |
|
|
|
|
saturate_cast<int>(ssize.height*inv_scale_y)); |
|
|
|
|
CV_Assert( dsize.area() ); |
|
|
|
|
CV_Assert( dsize.area() > 0 ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
inv_scale_x = (double)dsize.width/ssize.width; |
|
|
|
|
inv_scale_y = (double)dsize.height/ssize.height; |
|
|
|
|
} |
|
|
|
|
_dst.create(dsize, _src.type()); |
|
|
|
|
|
|
|
|
|
if( ocl::useOpenCL() && _dst.kind() == _InputArray::UMAT && |
|
|
|
|
ocl_resize(_src, _dst, inv_scale_x, inv_scale_y, interpolation) ) |
|
|
|
|
ocl_resize(_src, _dst, dsize, inv_scale_x, inv_scale_y, interpolation) ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
Mat src = _src.getMat(), dst = _dst.getMat(); |
|
|
|
|
Mat src = _src.getMat(); |
|
|
|
|
_dst.create(dsize, src.type()); |
|
|
|
|
Mat dst = _dst.getMat(); |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_TEGRA_OPTIMIZATION |
|
|
|
|
if (tegra::resize(src, dst, (float)inv_scale_x, (float)inv_scale_y, interpolation)) |
|
|
|
|