mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
imgproc(ocl): don't use doubles to process float data
This commit is contained in:
parent
2ac57a2b1f
commit
89bb028bfc
@ -2547,6 +2547,8 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
|
|||||||
(!doubleSupport && depth == CV_64F) || cn > 4)
|
(!doubleSupport && depth == CV_64F) || cn > 4)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool useDouble = depth == CV_64F;
|
||||||
|
|
||||||
const char * const interpolationMap[3] = { "NEAREST", "LINEAR", "CUBIC" };
|
const char * const interpolationMap[3] = { "NEAREST", "LINEAR", "CUBIC" };
|
||||||
ocl::ProgramSource program = op_type == OCL_OP_AFFINE ?
|
ocl::ProgramSource program = op_type == OCL_OP_AFFINE ?
|
||||||
ocl::imgproc::warp_affine_oclsrc : ocl::imgproc::warp_perspective_oclsrc;
|
ocl::imgproc::warp_affine_oclsrc : ocl::imgproc::warp_perspective_oclsrc;
|
||||||
@ -2561,8 +2563,10 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
|
|||||||
String opts;
|
String opts;
|
||||||
if (interpolation == INTER_NEAREST)
|
if (interpolation == INTER_NEAREST)
|
||||||
{
|
{
|
||||||
opts = format("-D INTER_NEAREST -D T=%s%s -D T1=%s -D ST=%s -D cn=%d -D rowsPerWI=%d",
|
opts = format("-D INTER_NEAREST -D T=%s%s -D CT=%s -D T1=%s -D ST=%s -D cn=%d -D rowsPerWI=%d",
|
||||||
ocl::typeToStr(type), doubleSupport ? " -D DOUBLE_SUPPORT" : "",
|
ocl::typeToStr(type),
|
||||||
|
doubleSupport ? " -D DOUBLE_SUPPORT" : "",
|
||||||
|
useDouble ? "double" : "float",
|
||||||
ocl::typeToStr(CV_MAT_DEPTH(type)),
|
ocl::typeToStr(CV_MAT_DEPTH(type)),
|
||||||
ocl::typeToStr(sctype), cn, rowsPerWI);
|
ocl::typeToStr(sctype), cn, rowsPerWI);
|
||||||
}
|
}
|
||||||
@ -2570,14 +2574,16 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
|
|||||||
{
|
{
|
||||||
char cvt[2][50];
|
char cvt[2][50];
|
||||||
opts = format("-D INTER_%s -D T=%s -D T1=%s -D ST=%s -D WT=%s -D depth=%d"
|
opts = format("-D INTER_%s -D T=%s -D T1=%s -D ST=%s -D WT=%s -D depth=%d"
|
||||||
" -D convertToWT=%s -D convertToT=%s%s -D cn=%d -D rowsPerWI=%d",
|
" -D convertToWT=%s -D convertToT=%s%s -D CT=%s -D cn=%d -D rowsPerWI=%d",
|
||||||
interpolationMap[interpolation], ocl::typeToStr(type),
|
interpolationMap[interpolation], ocl::typeToStr(type),
|
||||||
ocl::typeToStr(CV_MAT_DEPTH(type)),
|
ocl::typeToStr(CV_MAT_DEPTH(type)),
|
||||||
ocl::typeToStr(sctype),
|
ocl::typeToStr(sctype),
|
||||||
ocl::typeToStr(CV_MAKE_TYPE(wdepth, cn)), depth,
|
ocl::typeToStr(CV_MAKE_TYPE(wdepth, cn)), depth,
|
||||||
ocl::convertTypeStr(depth, wdepth, cn, cvt[0]),
|
ocl::convertTypeStr(depth, wdepth, cn, cvt[0]),
|
||||||
ocl::convertTypeStr(wdepth, depth, cn, cvt[1]),
|
ocl::convertTypeStr(wdepth, depth, cn, cvt[1]),
|
||||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "", cn, rowsPerWI);
|
doubleSupport ? " -D DOUBLE_SUPPORT" : "",
|
||||||
|
useDouble ? "double" : "float",
|
||||||
|
cn, rowsPerWI);
|
||||||
}
|
}
|
||||||
|
|
||||||
k.create(kernelName, program, opts);
|
k.create(kernelName, program, opts);
|
||||||
@ -2614,7 +2620,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
|
|||||||
M[2] = b1; M[5] = b2;
|
M[2] = b1; M[5] = b2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matM.convertTo(M0, doubleSupport ? CV_64F : CV_32F);
|
matM.convertTo(M0, useDouble ? CV_64F : CV_32F);
|
||||||
|
|
||||||
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(M0),
|
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(M0),
|
||||||
ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
|
ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));
|
||||||
|
@ -49,9 +49,6 @@
|
|||||||
#elif defined (cl_khr_fp64)
|
#elif defined (cl_khr_fp64)
|
||||||
#pragma OPENCL EXTENSION cl_khr_fp64:enable
|
#pragma OPENCL EXTENSION cl_khr_fp64:enable
|
||||||
#endif
|
#endif
|
||||||
#define CT double
|
|
||||||
#else
|
|
||||||
#define CT float
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INTER_BITS 5
|
#define INTER_BITS 5
|
||||||
|
@ -49,9 +49,6 @@
|
|||||||
#elif defined (cl_khr_fp64)
|
#elif defined (cl_khr_fp64)
|
||||||
#pragma OPENCL EXTENSION cl_khr_fp64:enable
|
#pragma OPENCL EXTENSION cl_khr_fp64:enable
|
||||||
#endif
|
#endif
|
||||||
#define CT double
|
|
||||||
#else
|
|
||||||
#define CT float
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INTER_BITS 5
|
#define INTER_BITS 5
|
||||||
|
Loading…
Reference in New Issue
Block a user