RecFusion SDK
RecFusion::Sensor Class Reference

Provides access to OpenNI-based RGB-D sensors. More...

Public Member Functions

 Sensor ()
 Create Sensor object. To open the sensor, enumerate the available devices and open a sensor by its URI.
 
 ~Sensor ()
 Destroy Sensor object.
 
int deviceCount () const
 Get number of available sensors. More...
 
int deviceName (int id, char *name, int len) const
 Get sensor name. More...
 
int uuid (int id, char *name, int len) const
 Get sensor uuid. More...
 
bool open (int id=0, int colorWidth=640, int colorHeight=480, int depthWidth=640, int depthHeight=480, double maxFps=30, int hd2c=-1)
 Open sensor. Must be called before any other functions can be used. More...
 
bool open (const char *uuid, int colorWidth=640, int colorHeight=480, int depthWidth=640, int depthHeight=480, double maxFps=30, int hd2c=-1)
 Open sensor based on USB identifier. Must be called before any other functions can be used. More...
 
bool close ()
 Close sensor.
 
bool start ()
 Start callback-based capture.
 
void stop ()
 Stop callback-based capture.
 
bool readImage (DepthImage &imgDepth, ColorImage &imgColor, int timeOut=2000)
 Read image from sensor. The images passed in need to be allocated by the caller. More...
 
bool isOpen () const
 Return true when sensor is open and ready for acquisition.
 
int depthWidth () const
 Return width of depth image returned by sensor.
 
int depthHeight () const
 Return height of depth image returned by sensor.
 
int colorWidth () const
 Return width of color image returned by sensor.
 
int colorHeight () const
 Return height of color image returned by sensor.
 
Mat3 depthIntrinsics () const
 Return depth sensor intrinsics as 3x3 matrix. Returns zero matrix when no depth intrinsics are available.
 
Mat3 colorIntrinsics () const
 Return color sensor intrinsics as 3x3 matrix. Returns zero matrix when no color intrinsics are available.
 
Mat4 depthToColorTransformation () const
 Return depth to color transformation as 4x4 matrix. Returns zero matrix when no transformation is available.
 
bool supportsColor () const
 Return true if sensor supports color.
 
bool setLaserState (bool enable)
 Turn laser on or off. More...
 
bool supportsAutoWhiteBalance () const
 Return true if sensor supports auto white-balance.
 
bool setAutoWhiteBalanceEnabled (bool enable)
 Set auto white-balance state. More...
 
bool isAutoWhiteBalanceEnabled () const
 Get auto white-balance state.
 
bool supportsAutoExposure () const
 Return true if sensor supports auto exposure.
 
bool setAutoExposureEnabled (bool enable)
 Set auto exposure state. More...
 
bool isAutoExposureEnabled () const
 Get auto exposure state.
 
bool setExposure (int exposureTimeMs)
 Set auto exposure to specified value in ms. Only works when auto exposure is disabled.
 
int exposure () const
 Get exposure time in non-auto mode in ms.
 
void addListener (SensorListener *listener)
 Register sensor listener. More...
 
void removeListener (const SensorListener *listener)
 Remove previously registered sensor listener. More...
 

Detailed Description

Provides access to OpenNI-based RGB-D sensors.

Member Function Documentation

◆ addListener()

void RecFusion::Sensor::addListener ( SensorListener listener)

Register sensor listener.

Parameters
listenerSensor listener

◆ deviceCount()

int RecFusion::Sensor::deviceCount ( ) const

Get number of available sensors.

Returns
Number of available sensors.

◆ deviceName()

int RecFusion::Sensor::deviceName ( int  id,
char *  name,
int  len 
) const

Get sensor name.

Parameters
idSensor ID in the range 0 to deviceCount-1
[out]nameOutput char buffer for sensor name.
[in]lenOutput buffer length.
Returns
Return codes: >= 0 sensor name length, < 0 error (-1 invalid sensor number, -2 output name buffer too small).

◆ open() [1/2]

bool RecFusion::Sensor::open ( const char *  uuid,
int  colorWidth = 640,
int  colorHeight = 480,
int  depthWidth = 640,
int  depthHeight = 480,
double  maxFps = 30,
int  hd2c = -1 
)

Open sensor based on USB identifier. Must be called before any other functions can be used.

Parameters
idUSB sensor identifier.
colorWidthDesired color image width.
colorHeightDesired color image height.
colorHeightDesired color image height.
depthWidthDesired depth image width.
depthHeightDesired depth image height.
maxFpsMaximum framerate to use.
hd2cHardware depth-to-color alignment mode (-1 = auto (default), 0 = off, 1 = on)
Returns
True if sensor supports the requested resolution on both depth and color sensor and could be opened, false otherwise.

◆ open() [2/2]

bool RecFusion::Sensor::open ( int  id = 0,
int  colorWidth = 640,
int  colorHeight = 480,
int  depthWidth = 640,
int  depthHeight = 480,
double  maxFps = 30,
int  hd2c = -1 
)

Open sensor. Must be called before any other functions can be used.

Parameters
idSensor number (0 to deviceCount-1).
colorWidthDesired color image width.
colorHeightDesired color image height.
colorHeightDesired color image height.
depthWidthDesired depth image width.
depthHeightDesired depth image height.
maxFpsMaximum framerate to use.
hd2cHardware depth-to-color alignment mode (-1 = auto (default), 0 = off, 1 = on)
Returns
True if sensor supports the requested resolution on both depth and color sensor and could be opened, false otherwise.

◆ readImage()

bool RecFusion::Sensor::readImage ( DepthImage imgDepth,
ColorImage imgColor,
int  timeOut = 2000 
)

Read image from sensor. The images passed in need to be allocated by the caller.

Parameters
imgDepthPointer to depth image of size width() x heigt(). Will contain depth measurements in mm for valid pixels and zero for other pixels upon return.
imgColorPointer to depth image of size width() x heigt(). Will contain color image in RGB-format upon return.
timeOutTime out to wait for data in ms.
Returns
True if successful, false on error.

◆ removeListener()

void RecFusion::Sensor::removeListener ( const SensorListener listener)

Remove previously registered sensor listener.

Parameters
listenerSensor listener

◆ setAutoExposureEnabled()

bool RecFusion::Sensor::setAutoExposureEnabled ( bool  enable)

Set auto exposure state.

Parameters
enableTrue to enable, false to disable auto exposure

◆ setAutoWhiteBalanceEnabled()

bool RecFusion::Sensor::setAutoWhiteBalanceEnabled ( bool  enable)

Set auto white-balance state.

Parameters
enableTrue to enable, false to disable auto white-balance

◆ setLaserState()

bool RecFusion::Sensor::setLaserState ( bool  enable)

Turn laser on or off.

Parameters
enableTrue to enable, false to disable laser

◆ uuid()

int RecFusion::Sensor::uuid ( int  id,
char *  name,
int  len 
) const

Get sensor uuid.

Parameters
idSensor ID in the range 0 to deviceCount-1
[out]nameOutput char buffer for sensor uuid.
[in]lenOutput buffer length.
Returns
Return codes: >= 0 sensor name length, < 0 error (-1 invalid sensor number, -2 output name buffer too small).

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