KNN background subtraction algorithm

We are implementing a video‑based motion detection feature (detecting all moving objects) on an ARM architecture. When using OpenCV’s KNN background subtraction algorithm, we observe high CPU usage while processing multiple video streams simultaneously. Could anyone suggest effective optimization strategies?

what number of streams, resolutions, frame rates?

what is the cpu, what are its specs? what is the CPU load?

why are you suspecting bgsub when it could just be that the CPU cannot keep up with decoding the streams?

get a more powerful CPU?

downsample the video frames before bgsub processing?

20 video streams, resolution 1080P. Hardware decoding is used for video decoding, and the CPU is a Huawei Kunpeng CPU. The CPU is at full capacity, with only 1–2% remaining processing power. The background modeling algorithm (KNN) accounts for 85% of the total CPU usage time.

That looks like a very capable CPU. Internet says it can have up to 64 cores.

I see these options:

  • shrink the video frames (pyrDown(), or resize() with INTER_AREA), because nothing of interest ever is just a single pixel in size
  • or switch to a lighter background modeling algorithm