Skip to content

Commit 26d288b

Browse files
authored
Optimize OpenCL BackgroundSubstractionMOG2
1 parent 047764f commit 26d288b

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

modules/video/src/opencl/bgfg_mog2.cl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
#define meanToFrame(a, b) *b = (float)a;
1212
#endif
1313

14-
inline float sum(float val)
15-
{
16-
return val;
17-
}
18-
1914
#else
2015

2116
#define T_MEAN float4
@@ -40,11 +35,6 @@ inline float sum(float val)
4035
b.z = a[2]; \
4136
b.w = 0.0f;
4237

43-
inline float sum(const float4 val)
44-
{
45-
return (val.x + val.y + val.z);
46-
}
47-
4838
#endif
4939

5040
__kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame_offset, int frame_row, int frame_col, //uchar || uchar3
@@ -210,9 +200,7 @@ __kernel void mog2_kernel(__global const uchar* frame, int frame_step, int frame
210200
int mode_idx = mad24(mode, idx_step, pt_idx);
211201
T_MEAN c_mean = _mean[mode_idx];
212202

213-
T_MEAN pix_mean = pix * c_mean;
214-
215-
float numerator = sum(pix_mean);
203+
float numerator = dot(pix, c_mean);
216204
float denominator = dot(c_mean, c_mean);
217205

218206
if (denominator == 0)

0 commit comments

Comments
 (0)