Skip to content

Commit f4265d2

Browse files
committed
Merge pull request opencv#9579 from alalek:ocl_float_calc
2 parents 2ac57a2 + 89bb028 commit f4265d2

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

modules/imgproc/src/imgwarp.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,8 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
25472547
(!doubleSupport && depth == CV_64F) || cn > 4)
25482548
return false;
25492549

2550+
bool useDouble = depth == CV_64F;
2551+
25502552
const char * const interpolationMap[3] = { "NEAREST", "LINEAR", "CUBIC" };
25512553
ocl::ProgramSource program = op_type == OCL_OP_AFFINE ?
25522554
ocl::imgproc::warp_affine_oclsrc : ocl::imgproc::warp_perspective_oclsrc;
@@ -2561,23 +2563,27 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
25612563
String opts;
25622564
if (interpolation == INTER_NEAREST)
25632565
{
2564-
opts = format("-D INTER_NEAREST -D T=%s%s -D T1=%s -D ST=%s -D cn=%d -D rowsPerWI=%d",
2565-
ocl::typeToStr(type), doubleSupport ? " -D DOUBLE_SUPPORT" : "",
2566+
opts = format("-D INTER_NEAREST -D T=%s%s -D CT=%s -D T1=%s -D ST=%s -D cn=%d -D rowsPerWI=%d",
2567+
ocl::typeToStr(type),
2568+
doubleSupport ? " -D DOUBLE_SUPPORT" : "",
2569+
useDouble ? "double" : "float",
25662570
ocl::typeToStr(CV_MAT_DEPTH(type)),
25672571
ocl::typeToStr(sctype), cn, rowsPerWI);
25682572
}
25692573
else
25702574
{
25712575
char cvt[2][50];
25722576
opts = format("-D INTER_%s -D T=%s -D T1=%s -D ST=%s -D WT=%s -D depth=%d"
2573-
" -D convertToWT=%s -D convertToT=%s%s -D cn=%d -D rowsPerWI=%d",
2577+
" -D convertToWT=%s -D convertToT=%s%s -D CT=%s -D cn=%d -D rowsPerWI=%d",
25742578
interpolationMap[interpolation], ocl::typeToStr(type),
25752579
ocl::typeToStr(CV_MAT_DEPTH(type)),
25762580
ocl::typeToStr(sctype),
25772581
ocl::typeToStr(CV_MAKE_TYPE(wdepth, cn)), depth,
25782582
ocl::convertTypeStr(depth, wdepth, cn, cvt[0]),
25792583
ocl::convertTypeStr(wdepth, depth, cn, cvt[1]),
2580-
doubleSupport ? " -D DOUBLE_SUPPORT" : "", cn, rowsPerWI);
2584+
doubleSupport ? " -D DOUBLE_SUPPORT" : "",
2585+
useDouble ? "double" : "float",
2586+
cn, rowsPerWI);
25812587
}
25822588

25832589
k.create(kernelName, program, opts);
@@ -2614,7 +2620,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
26142620
M[2] = b1; M[5] = b2;
26152621
}
26162622
}
2617-
matM.convertTo(M0, doubleSupport ? CV_64F : CV_32F);
2623+
matM.convertTo(M0, useDouble ? CV_64F : CV_32F);
26182624

26192625
k.args(ocl::KernelArg::ReadOnly(src), ocl::KernelArg::WriteOnly(dst), ocl::KernelArg::PtrReadOnly(M0),
26202626
ocl::KernelArg(ocl::KernelArg::CONSTANT, 0, 0, 0, borderBuf, CV_ELEM_SIZE(sctype)));

modules/imgproc/src/opencl/warp_affine.cl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
#elif defined (cl_khr_fp64)
5050
#pragma OPENCL EXTENSION cl_khr_fp64:enable
5151
#endif
52-
#define CT double
53-
#else
54-
#define CT float
5552
#endif
5653

5754
#define INTER_BITS 5

modules/imgproc/src/opencl/warp_perspective.cl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
#elif defined (cl_khr_fp64)
5050
#pragma OPENCL EXTENSION cl_khr_fp64:enable
5151
#endif
52-
#define CT double
53-
#else
54-
#define CT float
5552
#endif
5653

5754
#define INTER_BITS 5

0 commit comments

Comments
 (0)