The VideoFrameRef class encapsulates a single video frame - the output of a VideoStream at a specific time. The data contained will be a single frame of color, IR, or depth video, along with associated meta data.
An object of type VideoFrameRef does not actually hold the data of the frame, but only a reference to it. OpenNI uses a ref-count to decide when the data buffer can be freed. Once the frame is no longer needed, it can be released by calling the release() method. Although the finalization process of the garbage collector also releases the reference, it is preferable to manually release it by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.
The usual way to obtain VideoFrameRef objects is by a call to VideoStream#readFrame(). Please note that the returned frame holds native memory. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.
All data references by a VideoFrameRef is stored as a primitive array of pixels. Each pixel will be of a type according to the configured pixel format (see VideoMode).
int org.openni.VideoFrameRef.getFrameIndex |
( |
| ) |
|
|
inline |
Frames are provided sequential frame ID numbers by the sensor that produced them. If frame synchronization has been enabled for a device via Device#setDepthColorSyncEnabled(boolean), then frame numbers for corresponding frames of depth and color are guaranteed to match.
If frame synchronization is not enabled, then there is no guarantee of matching frame indexes between VideoStream "VideoStreams". In the latter case, applications should use timestamps instead of frame indexes to align frames in time.
- 返回
- Index number for this frame.
void org.openni.VideoFrameRef.release |
( |
| ) |
|
|
inline |
Release the reference to the frame. Once this method is called, the object becomes invalid, and no method should be called other than the assignment operator, or passing this object to a VideoStream::readFrame() call.
Although the finalization process of the garbage collector also releases the reference, it is preferable to manually release it by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time.