Capturing frames on demand
The ColorImageStream
class has a public method named OpenNextFrame()
. Using the OpenNextFrame()
method, you can request an image frame from the sensor. This is how the polling model works for retrieving image frames.
In the polling model, the application opens a channel for the stream, and whenever the application needs a frame, it sends a request to get the frame. OpenNextFrame ()
accepts one parameter called millisecondsWait
, which specifies how long the sensor should wait before it sends the image frame. If there is no frame ready within the provided time, the method will return null. The following is the general syntax of using OpenNextFrame()
; in our case we have used a waiting time of 10 milliseconds:
int millisecondsWait = 10;
if (this.sensor.ColorStream.IsEnabled)
{
ColorImageFrame colorImageFrame = this.sensor.ColorStream.OpenNextFrame(millisecondsWait);
}
The colorImageFrame
class will return an image frame after the provided waiting time. This frame will...