Optimize OpenCL BackgroundSubstractionMOG2

This commit is contained in:
GlueCrow 2017-12-23 21:57:17 +08:00 committed by GitHub
parent 047764f476
commit 26d288bd11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,11 +11,6 @@
#define meanToFrame(a, b) *b = (float)a;
#endif
inline float sum(float val)
{
return val;
}
#else
#define T_MEAN float4
@ -40,11 +35,6 @@ inline float sum(float val)
b.z = a[2]; \
b.w = 0.0f;
inline float sum(const float4 val)
{
return (val.x + val.y + val.z);
}
#endif
__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
int mode_idx = mad24(mode, idx_step, pt_idx);
T_MEAN c_mean = _mean[mode_idx];
T_MEAN pix_mean = pix * c_mean;
float numerator = sum(pix_mean);
float numerator = dot(pix, c_mean);
float denominator = dot(c_mean, c_mean);
if (denominator == 0)