Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
openni::VideoStream Class Reference

#include <OpenNI.h>

Classes

class  FrameAllocator
 
class  NewFrameListener
 

Public Member Functions

OniStreamHandle _getHandle () const
 
Status addNewFrameListener (NewFrameListener *pListener)
 
Status create (const Device &device, SensorType sensorType)
 
void destroy ()
 
CameraSettingsgetCameraSettings ()
 
bool getCropping (int *pOriginX, int *pOriginY, int *pWidth, int *pHeight) const
 
float getHorizontalFieldOfView () const
 
int getMaxPixelValue () const
 
int getMinPixelValue () const
 
bool getMirroringEnabled () const
 
Status getProperty (int propertyId, void *data, int *dataSize) const
 
template<class T >
Status getProperty (int propertyId, T *value) const
 
const SensorInfogetSensorInfo () const
 
float getVerticalFieldOfView () const
 
VideoMode getVideoMode () const
 
Status invoke (int commandId, void *data, int dataSize)
 
template<class T >
Status invoke (int commandId, T &value)
 
bool isCommandSupported (int commandId) const
 
bool isCroppingSupported () const
 
bool isPropertySupported (int propertyId) const
 
bool isValid () const
 
Status readFrame (VideoFrameRef *pFrame)
 
void removeNewFrameListener (NewFrameListener *pListener)
 
Status resetCropping ()
 
Status setCropping (int originX, int originY, int width, int height)
 
Status setFrameBuffersAllocator (FrameAllocator *pAllocator)
 
Status setMirroringEnabled (bool isEnabled)
 
Status setProperty (int propertyId, const void *data, int dataSize)
 
template<class T >
Status setProperty (int propertyId, const T &value)
 
Status setVideoMode (const VideoMode &videoMode)
 
Status start ()
 
void stop ()
 
 VideoStream ()
 
 VideoStream (OniStreamHandle handle)
 
 ~VideoStream ()
 

Private Member Functions

void _setHandle (OniStreamHandle stream)
 
VideoStreamoperator= (const VideoStream &other)
 
 VideoStream (const VideoStream &other)
 

Private Attributes

bool m_isOwner
 
CameraSettingsm_pCameraSettings
 
SensorInfo m_sensorInfo
 
OniStreamHandle m_stream
 

Friends

class Device
 

Detailed Description

The VideoStream object encapsulates a single video stream from a device. Once created, it is used to start data flow from the device, and to read individual frames of data. This is the central class used to obtain data in OpenNI. It provides the ability to manually read data in a polling loop, as well as providing events and a Listener class that can be used to implement event-driven data acquisition.

Aside from the video data frames themselves, the class offers a number of functions used for obtaining information about a VideoStream. Field of view, available video modes, and minimum and maximum valid pixel values can all be obtained.

In addition to obtaining data, the VideoStream object is used to set all configuration properties that apply to a specific stream (rather than to an entire device). In particular, it is used to control cropping, mirroring, and video modes.

A pointer to a valid, initialized device that provides the desired stream type is required to create a stream.

Several video streams can be created to stream data from the same sensor. This is useful if several components of an application need to read frames separately.

While some device might allow different streams from the same sensor to have different configurations, most devices will have a single configuration for the sensor, shared by all streams.

Definition at line 645 of file OpenNI.h.

Constructor & Destructor Documentation

openni::VideoStream::VideoStream ( )
inline

Default constructor. Creates a new, non-valid VideoStream object. The object created will be invalid until its create() function is called with a valid Device.

Definition at line 715 of file OpenNI.h.

openni::VideoStream::VideoStream ( OniStreamHandle  handle)
inlineexplicit

Handle constructor. Creates a VideoStream object based on the given initialized handle. This object will not destroy the underlying handle when destroy() or destructor is called

Definition at line 722 of file OpenNI.h.

openni::VideoStream::~VideoStream ( )
inline

Destructor. The destructor calls the destroy() function, but it is considered a best practice for applications to call destroy() manually on any VideoStream that they run create() on.

Definition at line 731 of file OpenNI.h.

openni::VideoStream::VideoStream ( const VideoStream other)
private

Member Function Documentation

OniStreamHandle openni::VideoStream::_getHandle ( ) const
inline

Definition at line 884 of file OpenNI.h.

void openni::VideoStream::_setHandle ( OniStreamHandle  stream)
inlineprivate

Definition at line 1205 of file OpenNI.h.

Status openni::VideoStream::addNewFrameListener ( NewFrameListener pListener)
inline

Adds a new Listener to receive this VideoStream onNewFrame event. See VideoStream::NewFrameListener for more information on implementing an event driven frame reading architecture. An instance of a listener can be added to only one source.

Parameters
[in]pListenerPointer to a VideoStream::NewFrameListener object (or a derivative) that will respond to this event.
Returns
Status code indicating success or failure of the operation.

Definition at line 833 of file OpenNI.h.

Status openni::VideoStream::create ( const Device device,
SensorType  sensorType 
)
inline

Creates a stream of frames from a specific sensor type of a specific device. You must supply a reference to a Device that supplies the sensor type requested. You can use Device::hasSensor() to check whether a given sensor is available on your target device before calling create().

Parameters
[in]deviceA reference to the Device you want to create the stream on.
[in]sensorTypeThe type of sensor the stream should produce data from.
Returns
Status code indicating success or failure for this operation.

Definition at line 2617 of file OpenNI.h.

void openni::VideoStream::destroy ( )
inline

Destroy this stream. This function is currently called automatically by the destructor, but it is considered a best practice for applications to manually call this function on any VideoStream that they call create() for.

Definition at line 2637 of file OpenNI.h.

CameraSettings* openni::VideoStream::getCameraSettings ( )
inline

Gets an object through which several camera settings can be configured.

Returns
NULL if the stream doesn't support camera settings.

Definition at line 893 of file OpenNI.h.

bool openni::VideoStream::getCropping ( int *  pOriginX,
int *  pOriginY,
int *  pWidth,
int *  pHeight 
) const
inline

Obtains the current cropping settings for this stream.

Parameters
[out]pOriginXX coordinate of the upper left corner of the cropping window
[out]pOriginYY coordinate of the upper left corner of the cropping window
[out]pWidthHorizontal width of the cropping window, in pixels
[out]pHeightVertical width of the cropping window, in pixels returns true if cropping is currently enabled, false if it is not.

Definition at line 1010 of file OpenNI.h.

float openni::VideoStream::getHorizontalFieldOfView ( ) const
inline

Gets the horizontal field of view of frames received from this stream.

Returns
Horizontal field of view, in radians.

Definition at line 1089 of file OpenNI.h.

int openni::VideoStream::getMaxPixelValue ( ) const
inline

Provides the maximum possible value for pixels obtained by this stream. This is most useful for getting the maximum possible value of depth streams.

Returns
Maximum possible pixel value.

Definition at line 966 of file OpenNI.h.

int openni::VideoStream::getMinPixelValue ( ) const
inline

Provides the smallest possible value for pixels obtains by this VideoStream. This is most useful for getting the minimum possible value that will be reported by a depth stream.

Returns
Minimum possible pixel value that can come from this stream.

Definition at line 982 of file OpenNI.h.

bool openni::VideoStream::getMirroringEnabled ( ) const
inline

Check whether mirroring is currently turned on for this stream.

Returns
true if mirroring is currently enabled, false otherwise.

Definition at line 1064 of file OpenNI.h.

Status openni::VideoStream::getProperty ( int  propertyId,
void *  data,
int *  dataSize 
) const
inline

General function for obtaining the value of stream specific properties. There are convenience functions available for all commonly used properties, so it is not expected that applications will make direct use of the getProperty function very often.

Parameters
[in]propertyIdThe numerical ID of the property to be queried.
[out]dataPlace to store the value of the property.
[in,out]dataSizeIN: Size of the buffer passed in the data argument. OUT: the actual written size.
Returns
Status code indicating success or failure of this operation.

Definition at line 905 of file OpenNI.h.

template<class T >
Status openni::VideoStream::getProperty ( int  propertyId,
T *  value 
) const
inline

Function for getting the value from a property using an arbitrary output type. There are convenience functions available for all commonly used properties, so it is not expected that applications will make direct use of this function very often.

Template Parameters
[in]T Data type of the value to be read.
Parameters
[in]propertyIdThe numerical ID of the property to be read.
[in,out]valuePointer to a place to store the value read from the property.
Returns
Status code indicating success or failure of this operation.

Definition at line 1132 of file OpenNI.h.

const SensorInfo& openni::VideoStream::getSensorInfo ( ) const
inline

Provides the SensorInfo object associated with the sensor that is producing this VideoStream. Note that this function will return NULL if the stream has not yet been initialized with the create() function.

SensorInfo is useful primarily as a means of learning which video modes are valid for this VideoStream.

Returns
Reference to the SensorInfo object associated with the sensor providing this stream.

Definition at line 771 of file OpenNI.h.

float openni::VideoStream::getVerticalFieldOfView ( ) const
inline

Gets the vertical field of view of frames received from this stream.

Returns
Vertical field of view, in radians.

Definition at line 1100 of file OpenNI.h.

VideoMode openni::VideoStream::getVideoMode ( ) const
inline

Get the current video mode information for this video stream. This includes its resolution, fps and stream format.

Returns
Current video mode information for this video stream.

Definition at line 941 of file OpenNI.h.

Status openni::VideoStream::invoke ( int  commandId,
void *  data,
int  dataSize 
)
inline

Invokes a command that takes an arbitrary data type as its input. It is not expected that application code will need this function frequently, as all commonly used properties have higher level functions provided.

Parameters
[in]commandIdNumerical code of the property to be invoked.
[in]dataData to be passed to the property.
[in]dataSizesize of the buffer passed in data.
Returns
Status code indicating success or failure of this operation.

Definition at line 1162 of file OpenNI.h.

template<class T >
Status openni::VideoStream::invoke ( int  commandId,
T &  value 
)
inline

Invokes a command that takes an arbitrary data type as its input. It is not expected that application code will need this function frequently, as all commonly used properties have higher level functions provided.

Template Parameters
[in]T Type of data to be passed to the property.
Parameters
[in]commandIdNumerical code of the property to be invoked.
[in]valueData to be passed to the property.
Returns
Status code indicating success or failure of this operation.

Definition at line 1182 of file OpenNI.h.

bool openni::VideoStream::isCommandSupported ( int  commandId) const
inline

Checks if a specific command is supported by the video stream.

Parameters
[in]commandIdCommand to be checked.
Returns
true if the command is supported, false otherwise.

Definition at line 1192 of file OpenNI.h.

bool openni::VideoStream::isCroppingSupported ( ) const
inline

Checks whether this stream supports cropping.

Returns
true if the stream supports cropping, false if it does not.

Definition at line 997 of file OpenNI.h.

bool openni::VideoStream::isPropertySupported ( int  propertyId) const
inline

Checks if a specific property is supported by the video stream.

Parameters
[in]propertyIdProperty to be checked.
Returns
true if the property is supported, false otherwise.

Definition at line 1143 of file OpenNI.h.

bool openni::VideoStream::isValid ( ) const
inline

Checks to see if this object has been properly initialized and currently points to a valid stream.

Returns
true if this object has been previously initialized, false otherwise.

Definition at line 740 of file OpenNI.h.

VideoStream& openni::VideoStream::operator= ( const VideoStream other)
private
Status openni::VideoStream::readFrame ( VideoFrameRef pFrame)
inline

Read the next frame from this video stream, delivered as a VideoFrameRef. This is the primary method for manually obtaining frames of video data. If no new frame is available, the call will block until one is available. To avoid blocking, use VideoStream::Listener to implement an event driven architecture. Another alternative is to use OpenNI::waitForAnyStream() to wait for new frames from several streams.

Parameters
[out]pFramePointer to a VideoFrameRef object to hold the reference to the new frame.
Returns
Status code to indicated success or failure of this function.

Definition at line 812 of file OpenNI.h.

void openni::VideoStream::removeNewFrameListener ( NewFrameListener pListener)
inline

Removes a Listener from this video stream list. The listener removed will no longer receive new frame events from this stream.

Parameters
[in]pListenerPointer to the listener object to be removed.

Definition at line 847 of file OpenNI.h.

Status openni::VideoStream::resetCropping ( )
inline

Disables cropping.

Returns
Status code indicating success or failure of this operation.

Definition at line 1053 of file OpenNI.h.

Status openni::VideoStream::setCropping ( int  originX,
int  originY,
int  width,
int  height 
)
inline

Changes the cropping settings for this stream. You can use the isCroppingSupported() function to make sure cropping is supported before calling this function.

Parameters
[in]originXNew X coordinate of the upper left corner of the cropping window.
[in]originYNew Y coordinate of the upper left corner of the cropping window.
[in]widthNew horizontal width for the cropping window, in pixels.
[in]heightNew vertical height for the cropping window, in pixels.
Returns
Status code indicating success or failure of this operation.

Definition at line 1038 of file OpenNI.h.

Status openni::VideoStream::setFrameBuffersAllocator ( FrameAllocator pAllocator)
inline

Sets the frame buffers allocator for this video stream.

Parameters
[in]pAllocatorPointer to the frame buffers allocator object. Pass NULL to return to default frame allocator.
Returns
ONI_STATUS_OUT_OF_FLOW The frame buffers allocator cannot be set while stream is streaming.

Definition at line 863 of file OpenNI.h.

Status openni::VideoStream::setMirroringEnabled ( bool  isEnabled)
inline

Enable or disable mirroring for this stream.

Parameters
[in]isEnabledtrue to enable mirroring, false to disable it.
Returns
Status code indicating the success or failure of this operation.

Definition at line 1080 of file OpenNI.h.

Status openni::VideoStream::setProperty ( int  propertyId,
const void *  data,
int  dataSize 
)
inline

General function for setting the value of stream specific properties. There are convenience functions available for all commonly used properties, so it is not expected that applications will make direct use of the setProperty function very often.

Parameters
[in]propertyIdThe numerical ID of the property to be set.
[in]dataPlace to store the data to be written to the property.
[in]dataSizeSize of the data to be written to the property.
Returns
Status code indicating success or failure of this operation.

Definition at line 925 of file OpenNI.h.

template<class T >
Status openni::VideoStream::setProperty ( int  propertyId,
const T &  value 
)
inline

Function for setting a value of a stream property using an arbitrary input type. There are convenience functions available for all commonly used properties, so it is not expected that applications will make direct use of this function very often.

Template Parameters
[in]T Data type of the value to be passed to the property.
Parameters
[in]propertyIdThe numerical ID of the property to be set.
[in]valueData to be sent to the property.
Returns
Status code indicating success or failure of this operation.

Definition at line 1117 of file OpenNI.h.

Status openni::VideoStream::setVideoMode ( const VideoMode videoMode)
inline

Changes the current video mode of this stream. Recommended practice is to use Device::getSensorInfo(), and then SensorInfo::getSupportedVideoModes() to obtain a list of valid video mode settings for this stream. Then, pass a valid VideoMode to setVideoMode to ensure correct operation.

Parameters
[in]videoModeDesired new video mode for this stream. returns Status code indicating success or failure of this operation.

Definition at line 956 of file OpenNI.h.

Status openni::VideoStream::start ( )
inline

Starts data generation from this video stream.

Definition at line 779 of file OpenNI.h.

void openni::VideoStream::stop ( )
inline

Stops data generation from this video stream.

Definition at line 792 of file OpenNI.h.

Friends And Related Function Documentation

friend class Device
friend

Definition at line 1203 of file OpenNI.h.

Member Data Documentation

bool openni::VideoStream::m_isOwner
private

Definition at line 1223 of file OpenNI.h.

CameraSettings* openni::VideoStream::m_pCameraSettings
private

Definition at line 1222 of file OpenNI.h.

SensorInfo openni::VideoStream::m_sensorInfo
private

Definition at line 1221 of file OpenNI.h.

OniStreamHandle openni::VideoStream::m_stream
private

Definition at line 1220 of file OpenNI.h.


The documentation for this class was generated from the following file:


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Thu Jun 6 2019 19:25:39