ROC SDK  2.4.0
Scalable Face Recognition Software
Typedefs | Functions
Foreground Modeling

Detect foreground movement in video frames by looking for changes relative to a static background. More...

Typedefs

typedef struct roc_foreground_type * roc_foreground
 Handle to a private foreground modeling type.
 

Functions

roc_error roc_new_foreground (roc_foreground *foreground)
 Initialize a new foreground model. More...
 
roc_error roc_foreground_add_frame (roc_foreground foreground, const roc_image frame, roc_image *mask)
 Classify image pixels into foreground and background. More...
 
roc_error roc_foreground_quality (const roc_image mask, float *foreground_quality)
 Calculate a quality value based on the number of foreground pixels in the image. More...
 
roc_error roc_foreground_roi (const roc_image mask, size_t *x, size_t *y, size_t *width, size_t *height)
 Identify a rectangular region of interest that captures the foreground content. More...
 
roc_error roc_foreground_render (const roc_image frame, const roc_image mask, roc_image *rendering)
 Construct an image that visualizes the foreground. More...
 
roc_error roc_free_foreground (roc_foreground *foreground)
 Free a foreground model. More...
 

Detailed Description

Detect foreground movement in video frames by looking for changes relative to a static background.

Function Documentation

◆ roc_new_foreground()

roc_error roc_new_foreground ( roc_foreground foreground)

Initialize a new foreground model.

Add images to the model with roc_foreground_add_frame.

Example
roc_foreground foreground;
roc_new_foreground(&foreground);
Parameters
[out]foregroundForeground model to initialize.
Remarks
This function is reentrant.
See also
roc_free_foreground

◆ roc_foreground_add_frame()

roc_error roc_foreground_add_frame ( roc_foreground  foreground,
const roc_image  frame,
roc_image mask 
)

Classify image pixels into foreground and background.

The output mask is a ROC_GRAY8 image the same size as the input frames. Values in mask are either zero to indicate background, or 255 to indicate foreground. The mask can be passed to roc_foreground_quality or roc_foreground_roi. Free mask after use with roc_free_image.

For a visual understanding of the algorithm see roc_foreground_render.

Example
roc_foreground foreground = ...;
roc_image frame = ...;
roc_image mask;
roc_model_foreground(foreground, frame, &mask);
Parameters
[in,out]foregroundBackground model to update.
[in]frameImage to model.
[out]maskROC_GRAY8 foreground/foreground mask.
Remarks
This function is thread-safe.
See also
roc_foreground_quality roc_foreground_roi

◆ roc_foreground_quality()

roc_error roc_foreground_quality ( const roc_image  mask,
float *  foreground_quality 
)

Calculate a quality value based on the number of foreground pixels in the image.

foreground_quality = (number of pixels in mask) ^ 2 / (number pixels in motion region * number pixels in image)

Parameters
[in]maskInput foreground mask from roc_foreground_add_frame.
[out]foreground_qualityQuality value based on the number of foreground pixels in the image.
Remarks
This function is thread-safe.
See also
roc_foreground_add_frame.

◆ roc_foreground_roi()

roc_error roc_foreground_roi ( const roc_image  mask,
size_t *  x,
size_t *  y,
size_t *  width,
size_t *  height 
)

Identify a rectangular region of interest that captures the foreground content.

Parameters
[in]maskInput foreground mask from roc_foreground_add_frame.
[out]xOutput region of interest rectangle, top-left corner horizontal position.
[out]yOutput region of interest rectangle, top-left corner vertical position.
[out]widthOutput region of interest rectangle width.
[out]heightOutput region of interest rectangle height.
Remarks
This function is thread-safe.
See also
roc_foreground_add_frame

◆ roc_foreground_render()

roc_error roc_foreground_render ( const roc_image  frame,
const roc_image  mask,
roc_image rendering 
)

Construct an image that visualizes the foreground.

Free rendering

Parameters
[in]frameInput frame from roc_foreground_add_frame.
[in]maskResulting mask from roc_foreground_add_frame.
[out]renderingRendered image the same size as frame.
Remarks
This function is thread-safe.

◆ roc_free_foreground()

roc_error roc_free_foreground ( roc_foreground foreground)

Free a foreground model.

Deallocate memory for foreground previously allocated with roc_new_foreground.

Example
roc_foreground foreground = ...;
roc_free_foreground(foreground);
Parameters
[in]foregroundBackground to free.
Remarks
This function is reentrant.
See also
roc_new_foreground