Skip to content

Commit bfd8003

Browse files
committed
use "double" from scalar only for CV_64F input
Restore "DstType" in AbsDiffScalarOp template arguments, even if eventually it will be equal to SrcType use "double" from scalar only for CV_64F input
1 parent 2375e58 commit bfd8003

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/cudaarithm/src/cuda/absdiff_scalar.cu

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const G
5656

5757
namespace
5858
{
59-
template <typename SrcType, typename ScalarType> struct AbsDiffScalarOp : unary_function<SrcType, SrcType>
59+
template <typename SrcType, typename ScalarType, typename DstType> struct AbsDiffScalarOp : unary_function<SrcType, DstType>
6060
{
6161
ScalarType val;
6262

63-
__device__ __forceinline__ SrcType operator ()(SrcType a) const
63+
__device__ __forceinline__ DstType operator ()(SrcType a) const
6464
{
6565
abs_func<ScalarType> f;
66-
return saturate_cast<SrcType>(f(saturate_cast<ScalarType>(a) - val));
66+
return saturate_cast<DstType>(f(saturate_cast<ScalarType>(a) - val));
6767
}
6868
};
6969

@@ -84,7 +84,7 @@ namespace
8484

8585
cv::Scalar_<ScalarDepth> value_ = value;
8686

87-
AbsDiffScalarOp<SrcType, ScalarType> op;
87+
AbsDiffScalarOp<SrcType, ScalarType, SrcType> op;
8888
op.val = VecTraits<ScalarType>::make(value_.val);
8989
gridTransformUnary_< TransformPolicy<ScalarDepth> >(globPtr<SrcType>(src), globPtr<SrcType>(dst), op, stream);
9090
}
@@ -96,22 +96,22 @@ void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const G
9696
static const func_t funcs[7][4] =
9797
{
9898
{
99-
absDiffScalarImpl<uchar, double>, absDiffScalarImpl<uchar2, double>, absDiffScalarImpl<uchar3, double>, absDiffScalarImpl<uchar4, double>
99+
absDiffScalarImpl<uchar, float>, absDiffScalarImpl<uchar2, float>, absDiffScalarImpl<uchar3, float>, absDiffScalarImpl<uchar4, float>
100100
},
101101
{
102-
absDiffScalarImpl<schar, double>, absDiffScalarImpl<char2, double>, absDiffScalarImpl<char3, double>, absDiffScalarImpl<char4, double>
102+
absDiffScalarImpl<schar, float>, absDiffScalarImpl<char2, float>, absDiffScalarImpl<char3, float>, absDiffScalarImpl<char4, float>
103103
},
104104
{
105-
absDiffScalarImpl<ushort, double>, absDiffScalarImpl<ushort2, double>, absDiffScalarImpl<ushort3, double>, absDiffScalarImpl<ushort4, double>
105+
absDiffScalarImpl<ushort, float>, absDiffScalarImpl<ushort2, float>, absDiffScalarImpl<ushort3, float>, absDiffScalarImpl<ushort4, float>
106106
},
107107
{
108-
absDiffScalarImpl<short, double>, absDiffScalarImpl<short2, double>, absDiffScalarImpl<short3, double>, absDiffScalarImpl<short4, double>
108+
absDiffScalarImpl<short, float>, absDiffScalarImpl<short2, float>, absDiffScalarImpl<short3, float>, absDiffScalarImpl<short4, float>
109109
},
110110
{
111-
absDiffScalarImpl<int, double>, absDiffScalarImpl<int2, double>, absDiffScalarImpl<int3, double>, absDiffScalarImpl<int4, double>
111+
absDiffScalarImpl<int, float>, absDiffScalarImpl<int2, float>, absDiffScalarImpl<int3, float>, absDiffScalarImpl<int4, float>
112112
},
113113
{
114-
absDiffScalarImpl<float, double>, absDiffScalarImpl<float2, double>, absDiffScalarImpl<float3, double>, absDiffScalarImpl<float4, double>
114+
absDiffScalarImpl<float, float>, absDiffScalarImpl<float2, float>, absDiffScalarImpl<float3, float>, absDiffScalarImpl<float4, float>
115115
},
116116
{
117117
absDiffScalarImpl<double, double>, absDiffScalarImpl<double2, double>, absDiffScalarImpl<double3, double>, absDiffScalarImpl<double4, double>

0 commit comments

Comments
 (0)