VPI - Vision Programming Interface

1.2 Release

Background Subtractor

Separate foreground and background from video. More...

Data Structures

struct  VPIBackgroundSubtractorParams
 Structure that defines the parameters for vpiCreateBackgroundSubtractor. More...
 

Functions

VPIStatus vpiInitBackgroundSubtractorParams (VPIBackgroundSubtractorParams *params)
 Initializes VPIBackgroundSubtractorParams with default values. More...
 
VPIStatus vpiCreateBackgroundSubtractor (uint32_t backends, int32_t imageWidth, int32_t imageHeight, VPIImageFormat inputFormat, VPIPayload *payload)
 Creates payload for vpiSubmitBackgroundSubtractor. More...
 
VPIStatus vpiSubmitBackgroundSubtractor (VPIStream stream, uint32_t backend, VPIPayload payload, VPIImage inFrame, VPIImage outFGMask, VPIImage outBGImage, const VPIBackgroundSubtractorParams *params)
 Submits a background subtractor operation to the stream associated with the given payload. More...
 

Detailed Description

Separate foreground and background from video.


Data Structure Documentation

◆ VPIBackgroundSubtractorParams

struct VPIBackgroundSubtractorParams

Structure that defines the parameters for vpiCreateBackgroundSubtractor.

Definition at line 80 of file BackgroundSubtractor.h.

+ Collaboration diagram for VPIBackgroundSubtractorParams:
Data Fields
uint8_t detectShadow The algorithm will detect shadows and mark them if this is set to non-zero value.
float learningRate Learning rate that indicates how fast the background model is learnt.

This value should be between 0 and 1. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame.

uint8_t shadowPixelValue Pixel value for shadow.
float varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model to decide whether a pixel is well described by the background model.

This parameter does not affect the background update.

Function Documentation

◆ vpiCreateBackgroundSubtractor()

VPIStatus vpiCreateBackgroundSubtractor ( uint32_t  backends,
int32_t  imageWidth,
int32_t  imageHeight,
VPIImageFormat  inputFormat,
VPIPayload payload 
)

#include <vpi/algo/BackgroundSubtractor.h>

Creates payload for vpiSubmitBackgroundSubtractor.

Parameters
[in]backendsVPI backends that are eligible to execute the algorithm. Currently only one backend is accepted.
[in]imageWidth,imageHeightInput image dimensions
[in]inputFormatInput image format.
[out]payloadPointer to memory where the created payload handle will be written to.
Returns
an error code on failure else VPI_SUCCESS

◆ vpiInitBackgroundSubtractorParams()

VPIStatus vpiInitBackgroundSubtractorParams ( VPIBackgroundSubtractorParams params)

#include <vpi/algo/BackgroundSubtractor.h>

Initializes VPIBackgroundSubtractorParams with default values.

Defaults:

  • varThreshold: 16
  • detectShadow: true
  • shadowPixelValue: 127
  • learningRate: 0.001
Parameters
[in]paramsStructure to be filled with default values.
Returns
an error code on failure else VPI_SUCCESS

◆ vpiSubmitBackgroundSubtractor()

VPIStatus vpiSubmitBackgroundSubtractor ( VPIStream  stream,
uint32_t  backend,
VPIPayload  payload,
VPIImage  inFrame,
VPIImage  outFGMask,
VPIImage  outBGImage,
const VPIBackgroundSubtractorParams params 
)

#include <vpi/algo/BackgroundSubtractor.h>

Submits a background subtractor operation to the stream associated with the given payload.

Runs background subtractor on the incoming image from the video and outputs a foreground mask. Please refer to Limitations and Constraints for information on limitations for some parameters.

Parameters
[in]streamThe stream where the operation will be queued in.
[in]backendBackend that will execute the algorithm. Must be one of the backends specified during payload creation. If 0, VPI will select one of the eligible backends from the payload that accepts the given parameters, usually the fastest one.
[in]payloadPayload to be submitted along the other parameters.
[in]inFrameIncoming frame from the video.
[out]outFGMaskThe output foreground mask as an 8-bit binary image.
[out]outBGImageBackground image, can pass nullptr if not needed.
[in]paramsalgorithm control parameters. Pass NULL to use defaults.
Returns
an error code on failure else VPI_SUCCESS