A Counting BackgroundSubtractor (CNT stands for ‘CouNT)

  • BackgroundSubtractorCNT is a drop in replacement API for the background subtraction solutions supplied with OpenCV 3.1.0 and above.
  • It is much faster than any other background subtraction solutions in OpenCV (without NVidia CUDA) on low spec hardware.
  • It has both a C++ API and a python API.
  • A drop in replacement means you simply change a single line of your code to get this amazing speed improvement.
  • It is using an inovative new algorithm.
  • It is compared here to MOG2 which is the previous fastest at the time of writing.

How much faster is it?

Here is an output of benchmarking on Raspberry Pi3 both MOG2 (MOG2 was the previous fastest at the time) and CNT BackgroundSubtractors:

pi@pilab2:~/tmp/mnt/build_pi3 $ ./demo -file=/home/pi/tmp/mnt2/samples/data/768x576.avi -nogui -type="MOG2"
Execution took 40.964450 seconds.
pi@pilab2:~/tmp/mnt/build_pi3 $ ./demo -file=/home/pi/tmp/mnt2/samples/data/768x576.avi -nogui -type="CNT"
Execution took 17.633301 seconds.

For more details see this blog post


  • Make it faster.
  • Shadow detection.