A Queue object contains a self-filling, asynchronous
queue of images retrieved from a Video or Stream
object. Retrieving an image from a video or camera stream is generally fast
but it still comes with a time penalty that can become significant when
processing large numbers of images and/or videos. A Queue object can
help save some of that lost time by reading and storing images from a video
or stream in parallel of the main R thread, for instance while other
operations are being performed by R on previously read images. These
pre-loaded frames are, therefore, immediately available when needed,
effectively eliminating the wait time between two frame reads (as long as
the queue reads and stores new frames faster than R can process them).
Function for creating Queue objects for
Video and Stream objects.
Arguments
- x
- size
The number of frames that the
Queueobject can store (default: 10). This number is fixed ifoverflowis set to"pause"or"replace". This number may increase ifoverflowis set to"grow"and the queue becomes full.- delay
Time in microseconds between two queue updates (default: 1000). Increasing the delay will slow down the speed at which the queue fills up. Decreasing it will fill up the queue faster but will use up more processing resources.
- overflow
A character string indicating what the
Queueobject should do when it is full. Three methods are available:- "pause":
the queue will stop retrieving and storing new frames until a frame is read by the user.
- "replace":
the oldest frame in the queue is discarded to make space for a new frame.
- "grow":
the size of the queue is doubled every time it fills up. This should be used with extreme caution as it can lead to excessive memory usage.
Slots
dim,ncol,nrowFunctions returning the dimensions of the frames in the queue.
lengthFunction returning the number of frames in the queue.
capacityFunction returning the maximum number of frames that the queue can hold at any one time.
frameFunction returning the index of the frame to be read next.
full,emptyFunction returning the state of the queue (full or empty or neither).
readNextFunction to access the next frame in the queue.
resetFunction to empty the queue and start collecting new frames.
Author
Simon Garnier, garnier@njit.edu
Examples
balloon <- video(system.file("sample_vid/Balloon.mp4", package = "Rvision"))
#> Error: Could not open the video.
buf <- queue(balloon)
#> Error in eval(expr, envir, enclos): object 'balloon' not found