Background Subtraction


class gpu::VIBE_GPU

Class used for background/foreground segmentation.

class VIBE_GPU
    explicit VIBE_GPU(unsigned long rngSeed = 1234567);

    void initialize(const GpuMat& firstFrame, Stream& stream = Stream::Null());

    void operator()(const GpuMat& frame, GpuMat& fgmask, Stream& stream = Stream::Null());

    void release();


The class discriminates between foreground and background pixels by building and maintaining a model of the background. Any pixel which does not fit this model is then deemed to be foreground. The class implements algorithm described in [VIBE2011].


The constructor.

C++: gpu::VIBE_GPU::VIBE_GPU(unsigned long rngSeed=1234567)
  • rngSeed – Value used to initiate a random sequence.

Default constructor sets all parameters to default values.


Initialize background model and allocates all inner buffers.

C++: void gpu::VIBE_GPU::initialize(const GpuMat& firstFrame, Stream& stream=Stream::Null())
  • firstFrame – First frame from video sequence.
  • stream – Stream for the asynchronous version.


Updates the background model and returns the foreground mask

C++: void gpu::VIBE_GPU::operator()(const GpuMat& frame, GpuMat& fgmask, Stream& stream=Stream::Null())
  • frame – Next video frame.
  • fgmask – The output foreground mask as an 8-bit binary image.
  • stream – Stream for the asynchronous version.


Releases all inner buffer’s memory.

C++: void gpu::VIBE_GPU::release()
  1. Barnich and M. Van D Roogenbroeck. ViBe: A universal background subtraction algorithm for video sequences. IEEE Transactions on Image Processing, 20(6) :1709-1724, June 2011