Learn R Programming

videoplayR (version 0.3.1)

backgrounder: Generate a background image from a video

Description

This function computes the background image of a video. It tries to determine the background value of each pixel by approximating its central value, either as the mean or as the median of a given number n of images spread throughout the video.

Usage

backgrounder(video, n = 10, method = "mean", color = FALSE)

Arguments

video
A vpVideo object from which a background image need to be computed.
n
The number of images to extract from the video in order to compute the background image. The images are taken at evenly spaced intervals throughout the video. The default is 10. Larger numbers will result in better accuracy, but might take longer to compute.
method
The type of computation to be performed in order to obtain the background image. The possible values are "mean" (default) and "median". "mean" is faster but is usually less accurate than "median".
color
A logical value indicating if the the background image should be color (TRUE) or grayscale (FALSE, default). Grayscale background image are faster to compute.

Value

This function returns a vpImage object.

Details

The vpImage object created by the backgrounder function is not a persistent object, but a pointer to a C++ object that cannot be saved for reuse in a different session.

See Also

vpImage

Examples

Run this code
filename <- system.file("sample_vid/Walk3.mp4", package = "videoplayR")
vid <- readVid(filename)
imshow(getFrame(vid, 125))
bg <- backgrounder(vid, n = 100, method = "median", color = TRUE)
imshow(bg)

Run the code above in your browser using DataLab