@@ -56,14 +56,14 @@ void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const G
56
56
57
57
namespace
58
58
{
59
- template <typename SrcType, typename ScalarType, typename DstType > struct AbsDiffScalarOp : unary_function<SrcType, DstType >
59
+ template <typename SrcType, typename ScalarType> struct AbsDiffScalarOp : unary_function<SrcType, SrcType >
60
60
{
61
61
ScalarType val;
62
62
63
- __device__ __forceinline__ DstType operator ()(SrcType a) const
63
+ __device__ __forceinline__ SrcType operator ()(SrcType a) const
64
64
{
65
65
abs_func<ScalarType> f;
66
- return saturate_cast<DstType >(f (saturate_cast<ScalarType>(a) - val));
66
+ return saturate_cast<SrcType >(f (saturate_cast<ScalarType>(a) - val));
67
67
}
68
68
};
69
69
@@ -77,14 +77,14 @@ namespace
77
77
};
78
78
};
79
79
80
- template <typename SrcType, typename ScalarDepth, typename DstType >
80
+ template <typename SrcType, typename ScalarDepth>
81
81
void absDiffScalarImpl (const GpuMat& src, cv::Scalar value, GpuMat& dst, Stream& stream)
82
82
{
83
83
typedef typename MakeVec<ScalarDepth, VecTraits<SrcType>::cn>::type ScalarType;
84
84
85
85
cv::Scalar_<ScalarDepth> value_ = value;
86
86
87
- AbsDiffScalarOp<SrcType, ScalarType, DstType > op;
87
+ AbsDiffScalarOp<SrcType, ScalarType> op;
88
88
op.val = VecTraits<ScalarType>::make (value_.val );
89
89
gridTransformUnary_< TransformPolicy<ScalarDepth> >(globPtr<SrcType>(src), globPtr<SrcType>(dst), op, stream);
90
90
}
@@ -93,81 +93,38 @@ namespace
93
93
void absDiffScalar (const GpuMat& src, cv::Scalar val, bool , GpuMat& dst, const GpuMat&, double , Stream& stream, int )
94
94
{
95
95
typedef void (*func_t )(const GpuMat& src, cv::Scalar val, GpuMat& dst, Stream& stream);
96
- static const func_t funcs[7 ][7 ][ 4 ] =
96
+ static const func_t funcs[7 ][4 ] =
97
97
{
98
98
{
99
- {absDiffScalarImpl<uchar, float , uchar>, absDiffScalarImpl<uchar2 , float , uchar2 >, absDiffScalarImpl<uchar3 , float , uchar3 >, absDiffScalarImpl<uchar4 , float , uchar4 >},
100
- {absDiffScalarImpl<uchar, float , schar>, absDiffScalarImpl<uchar2 , float , char2 >, absDiffScalarImpl<uchar3 , float , char3 >, absDiffScalarImpl<uchar4 , float , char4 >},
101
- {absDiffScalarImpl<uchar, float , ushort>, absDiffScalarImpl<uchar2 , float , ushort2 >, absDiffScalarImpl<uchar3 , float , ushort3 >, absDiffScalarImpl<uchar4 , float , ushort4 >},
102
- {absDiffScalarImpl<uchar, float , short >, absDiffScalarImpl<uchar2 , float , short2 >, absDiffScalarImpl<uchar3 , float , short3 >, absDiffScalarImpl<uchar4 , float , short4 >},
103
- {absDiffScalarImpl<uchar, float , int >, absDiffScalarImpl<uchar2 , float , int2 >, absDiffScalarImpl<uchar3 , float , int3 >, absDiffScalarImpl<uchar4 , float , int4 >},
104
- {absDiffScalarImpl<uchar, float , float >, absDiffScalarImpl<uchar2 , float , float2 >, absDiffScalarImpl<uchar3 , float , float3 >, absDiffScalarImpl<uchar4 , float , float4 >},
105
- {absDiffScalarImpl<uchar, double , double >, absDiffScalarImpl<uchar2 , double , double2 >, absDiffScalarImpl<uchar3 , double , double3 >, absDiffScalarImpl<uchar4 , double , double4 >}
99
+ absDiffScalarImpl<uchar, double >, absDiffScalarImpl<uchar2 , double >, absDiffScalarImpl<uchar3 , double >, absDiffScalarImpl<uchar4 , double >
106
100
},
107
101
{
108
- {absDiffScalarImpl<schar, float , uchar>, absDiffScalarImpl<char2 , float , uchar2 >, absDiffScalarImpl<char3 , float , uchar3 >, absDiffScalarImpl<char4 , float , uchar4 >},
109
- {absDiffScalarImpl<schar, float , schar>, absDiffScalarImpl<char2 , float , char2 >, absDiffScalarImpl<char3 , float , char3 >, absDiffScalarImpl<char4 , float , char4 >},
110
- {absDiffScalarImpl<schar, float , ushort>, absDiffScalarImpl<char2 , float , ushort2 >, absDiffScalarImpl<char3 , float , ushort3 >, absDiffScalarImpl<char4 , float , ushort4 >},
111
- {absDiffScalarImpl<schar, float , short >, absDiffScalarImpl<char2 , float , short2 >, absDiffScalarImpl<char3 , float , short3 >, absDiffScalarImpl<char4 , float , short4 >},
112
- {absDiffScalarImpl<schar, float , int >, absDiffScalarImpl<char2 , float , int2 >, absDiffScalarImpl<char3 , float , int3 >, absDiffScalarImpl<char4 , float , int4 >},
113
- {absDiffScalarImpl<schar, float , float >, absDiffScalarImpl<char2 , float , float2 >, absDiffScalarImpl<char3 , float , float3 >, absDiffScalarImpl<char4 , float , float4 >},
114
- {absDiffScalarImpl<schar, double , double >, absDiffScalarImpl<char2 , double , double2 >, absDiffScalarImpl<char3 , double , double3 >, absDiffScalarImpl<char4 , double , double4 >}
102
+ absDiffScalarImpl<schar, double >, absDiffScalarImpl<char2 , double >, absDiffScalarImpl<char3 , double >, absDiffScalarImpl<char4 , double >
115
103
},
116
104
{
117
- {0 /* absDiffScalarImpl<ushort, float, uchar>*/ , 0 /* absDiffScalarImpl<ushort2, float, uchar2>*/ , 0 /* absDiffScalarImpl<ushort3, float, uchar3>*/ , 0 /* absDiffScalarImpl<ushort4, float, uchar4>*/ },
118
- {0 /* absDiffScalarImpl<ushort, float, schar>*/ , 0 /* absDiffScalarImpl<ushort2, float, char2>*/ , 0 /* absDiffScalarImpl<ushort3, float, char3>*/ , 0 /* absDiffScalarImpl<ushort4, float, char4>*/ },
119
- {absDiffScalarImpl<ushort, float , ushort>, absDiffScalarImpl<ushort2 , float , ushort2 >, absDiffScalarImpl<ushort3 , float , ushort3 >, absDiffScalarImpl<ushort4 , float , ushort4 >},
120
- {absDiffScalarImpl<ushort, float , short >, absDiffScalarImpl<ushort2 , float , short2 >, absDiffScalarImpl<ushort3 , float , short3 >, absDiffScalarImpl<ushort4 , float , short4 >},
121
- {absDiffScalarImpl<ushort, float , int >, absDiffScalarImpl<ushort2 , float , int2 >, absDiffScalarImpl<ushort3 , float , int3 >, absDiffScalarImpl<ushort4 , float , int4 >},
122
- {absDiffScalarImpl<ushort, float , float >, absDiffScalarImpl<ushort2 , float , float2 >, absDiffScalarImpl<ushort3 , float , float3 >, absDiffScalarImpl<ushort4 , float , float4 >},
123
- {absDiffScalarImpl<ushort, double , double >, absDiffScalarImpl<ushort2 , double , double2 >, absDiffScalarImpl<ushort3 , double , double3 >, absDiffScalarImpl<ushort4 , double , double4 >}
105
+ absDiffScalarImpl<ushort, double >, absDiffScalarImpl<ushort2 , double >, absDiffScalarImpl<ushort3 , double >, absDiffScalarImpl<ushort4 , double >
124
106
},
125
107
{
126
- {0 /* absDiffScalarImpl<short, float, uchar>*/ , 0 /* absDiffScalarImpl<short2, float, uchar2>*/ , 0 /* absDiffScalarImpl<short3, float, uchar3>*/ , 0 /* absDiffScalarImpl<short4, float, uchar4>*/ },
127
- {0 /* absDiffScalarImpl<short, float, schar>*/ , 0 /* absDiffScalarImpl<short2, float, char2>*/ , 0 /* absDiffScalarImpl<short3, float, char3>*/ , 0 /* absDiffScalarImpl<short4, float, char4>*/ },
128
- {absDiffScalarImpl<short , float , ushort>, absDiffScalarImpl<short2 , float , ushort2 >, absDiffScalarImpl<short3 , float , ushort3 >, absDiffScalarImpl<short4 , float , ushort4 >},
129
- {absDiffScalarImpl<short , float , short >, absDiffScalarImpl<short2 , float , short2 >, absDiffScalarImpl<short3 , float , short3 >, absDiffScalarImpl<short4 , float , short4 >},
130
- {absDiffScalarImpl<short , float , int >, absDiffScalarImpl<short2 , float , int2 >, absDiffScalarImpl<short3 , float , int3 >, absDiffScalarImpl<short4 , float , int4 >},
131
- {absDiffScalarImpl<short , float , float >, absDiffScalarImpl<short2 , float , float2 >, absDiffScalarImpl<short3 , float , float3 >, absDiffScalarImpl<short4 , float , float4 >},
132
- {absDiffScalarImpl<short , double , double >, absDiffScalarImpl<short2 , double , double2 >, absDiffScalarImpl<short3 , double , double3 >, absDiffScalarImpl<short4 , double , double4 >}
108
+ absDiffScalarImpl<short , double >, absDiffScalarImpl<short2 , double >, absDiffScalarImpl<short3 , double >, absDiffScalarImpl<short4 , double >
133
109
},
134
110
{
135
- {0 /* absDiffScalarImpl<int, float, uchar>*/ , 0 /* absDiffScalarImpl<int2, float, uchar2>*/ , 0 /* absDiffScalarImpl<int3, float, uchar3>*/ , 0 /* absDiffScalarImpl<int4, float, uchar4>*/ },
136
- {0 /* absDiffScalarImpl<int, float, schar>*/ , 0 /* absDiffScalarImpl<int2, float, char2>*/ , 0 /* absDiffScalarImpl<int3, float, char3>*/ , 0 /* absDiffScalarImpl<int4, float, char4>*/ },
137
- {0 /* absDiffScalarImpl<int, float, ushort>*/ , 0 /* absDiffScalarImpl<int2, float, ushort2>*/ , 0 /* absDiffScalarImpl<int3, float, ushort3>*/ , 0 /* absDiffScalarImpl<int4, float, ushort4>*/ },
138
- {0 /* absDiffScalarImpl<int, float, short>*/ , 0 /* absDiffScalarImpl<int2, float, short2>*/ , 0 /* absDiffScalarImpl<int3, float, short3>*/ , 0 /* absDiffScalarImpl<int4, float, short4>*/ },
139
- {absDiffScalarImpl<int , float , int >, absDiffScalarImpl<int2 , float , int2 >, absDiffScalarImpl<int3 , float , int3 >, absDiffScalarImpl<int4 , float , int4 >},
140
- {absDiffScalarImpl<int , float , float >, absDiffScalarImpl<int2 , float , float2 >, absDiffScalarImpl<int3 , float , float3 >, absDiffScalarImpl<int4 , float , float4 >},
141
- {absDiffScalarImpl<int , double , double >, absDiffScalarImpl<int2 , double , double2 >, absDiffScalarImpl<int3 , double , double3 >, absDiffScalarImpl<int4 , double , double4 >}
111
+ absDiffScalarImpl<int , double >, absDiffScalarImpl<int2 , double >, absDiffScalarImpl<int3 , double >, absDiffScalarImpl<int4 , double >
142
112
},
143
113
{
144
- {0 /* absDiffScalarImpl<float, float, uchar>*/ , 0 /* absDiffScalarImpl<float2, float, uchar2>*/ , 0 /* absDiffScalarImpl<float3, float, uchar3>*/ , 0 /* absDiffScalarImpl<float4, float, uchar4>*/ },
145
- {0 /* absDiffScalarImpl<float, float, schar>*/ , 0 /* absDiffScalarImpl<float2, float, char2>*/ , 0 /* absDiffScalarImpl<float3, float, char3>*/ , 0 /* absDiffScalarImpl<float4, float, char4>*/ },
146
- {0 /* absDiffScalarImpl<float, float, ushort>*/ , 0 /* absDiffScalarImpl<float2, float, ushort2>*/ , 0 /* absDiffScalarImpl<float3, float, ushort3>*/ , 0 /* absDiffScalarImpl<float4, float, ushort4>*/ },
147
- {0 /* absDiffScalarImpl<float, float, short>*/ , 0 /* absDiffScalarImpl<float2, float, short2>*/ , 0 /* absDiffScalarImpl<float3, float, short3>*/ , 0 /* absDiffScalarImpl<float4, float, short4>*/ },
148
- {0 /* absDiffScalarImpl<float, float, int>*/ , 0 /* absDiffScalarImpl<float2, float, int2>*/ , 0 /* absDiffScalarImpl<float3, float, int3>*/ , 0 /* absDiffScalarImpl<float4, float, int4>*/ },
149
- {absDiffScalarImpl<float , float , float >, absDiffScalarImpl<float2 , float , float2 >, absDiffScalarImpl<float3 , float , float3 >, absDiffScalarImpl<float4 , float , float4 >},
150
- {absDiffScalarImpl<float , double , double >, absDiffScalarImpl<float2 , double , double2 >, absDiffScalarImpl<float3 , double , double3 >, absDiffScalarImpl<float4 , double , double4 >}
114
+ absDiffScalarImpl<float , double >, absDiffScalarImpl<float2 , double >, absDiffScalarImpl<float3 , double >, absDiffScalarImpl<float4 , double >
151
115
},
152
116
{
153
- {0 /* absDiffScalarImpl<double, double, uchar>*/ , 0 /* absDiffScalarImpl<double2, double, uchar2>*/ , 0 /* absDiffScalarImpl<double3, double, uchar3>*/ , 0 /* absDiffScalarImpl<double4, double, uchar4>*/ },
154
- {0 /* absDiffScalarImpl<double, double, schar>*/ , 0 /* absDiffScalarImpl<double2, double, char2>*/ , 0 /* absDiffScalarImpl<double3, double, char3>*/ , 0 /* absDiffScalarImpl<double4, double, char4>*/ },
155
- {0 /* absDiffScalarImpl<double, double, ushort>*/ , 0 /* absDiffScalarImpl<double2, double, ushort2>*/ , 0 /* absDiffScalarImpl<double3, double, ushort3>*/ , 0 /* absDiffScalarImpl<double4, double, ushort4>*/ },
156
- {0 /* absDiffScalarImpl<double, double, short>*/ , 0 /* absDiffScalarImpl<double2, double, short2>*/ , 0 /* absDiffScalarImpl<double3, double, short3>*/ , 0 /* absDiffScalarImpl<double4, double, short4>*/ },
157
- {0 /* absDiffScalarImpl<double, double, int>*/ , 0 /* absDiffScalarImpl<double2, double, int2>*/ , 0 /* absDiffScalarImpl<double3, double, int3>*/ , 0 /* absDiffScalarImpl<double4, double, int4>*/ },
158
- {0 /* absDiffScalarImpl<double, double, float>*/ , 0 /* absDiffScalarImpl<double2, double, float2>*/ , 0 /* absDiffScalarImpl<double3, double, float3>*/ , 0 /* absDiffScalarImpl<double4, double, float4>*/ },
159
- {absDiffScalarImpl<double , double , double >, absDiffScalarImpl<double2 , double , double2 >, absDiffScalarImpl<double3 , double , double3 >, absDiffScalarImpl<double4 , double , double4 >}
117
+ absDiffScalarImpl<double , double >, absDiffScalarImpl<double2 , double >, absDiffScalarImpl<double3 , double >, absDiffScalarImpl<double4 , double >
160
118
}
161
119
};
162
120
163
121
const int sdepth = src.depth ();
164
122
const int ddepth = dst.depth ();
165
123
const int cn = src.channels ();
166
124
167
- CV_DbgAssert ( sdepth <= CV_64F && ddepth <= CV_64F && cn <= 4 );
168
-
169
- const func_t func = funcs[sdepth][ddepth][cn - 1 ];
125
+ CV_DbgAssert ( sdepth <= CV_64F && ddepth <= CV_64F && cn <= 4 && src.type () == dst.type ());
170
126
127
+ const func_t func = funcs[sdepth][cn - 1 ];
171
128
if (!func)
172
129
CV_Error (cv::Error::StsUnsupportedFormat, " Unsupported combination of source and destination types" );
173
130
0 commit comments