class mrpt::hwdrivers::COpenNI2Generic
Overview
An abstract class for accessing OpenNI2 compatible sensors.
This class permits one to access several sensors simultaneously. The same options (resolution, fps, etc.) are used for every sensor.
More references to read:
#include <mrpt/hwdrivers/COpenNI2Generic.h> class COpenNI2Generic { public: // classes class CDevice; // construction COpenNI2Generic(); COpenNI2Generic(int width, int height, float fps = 30.0f, bool open_streams_now = true); // methods void open(unsigned sensor_id = 0); unsigned int openDevicesBySerialNum(const std::set<unsigned>& vSerialRequired); unsigned int openDeviceBySerial(const unsigned int SerialRequired); bool getDeviceIDFromSerialNum(const unsigned int SerialRequired, int& sensor_id) const; bool start(); void kill(); bool isOpen(const unsigned sensor_id) const; void close(unsigned sensor_id = 0); int getNumDevices() const; int getConnectedDevices(); void getNextFrameRGB( mrpt::img::CImage& rgb_img, mrpt::system::TTimeStamp& timestamp, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 ); void getNextFrameD( mrpt::math::CMatrix_u16& depth_img_mm, mrpt::system::TTimeStamp& timestamp, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 ); void getNextFrameRGBD( mrpt::obs::CObservation3DRangeScan& out_obs, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 ); void setVerbose(bool verbose); bool isVerbose() const; bool getColorSensorParam( mrpt::img::TCamera& param, unsigned sensor_id = 0 ) const; bool getDepthSensorParam( mrpt::img::TCamera& param, unsigned sensor_id = 0 ) const; static int getNumInstances(); }; // direct descendants class COpenNI2Sensor; class COpenNI2_RGBD360;
Construction
COpenNI2Generic()
Default ctor (width=640, height=480, fps=30)
COpenNI2Generic( int width, int height, float fps = 30.0f, bool open_streams_now = true )
Ctor.
See also:
Methods
void open(unsigned sensor_id = 0)
Try to open the camera (all the parameters [resolution,fps,…] must be set before calling this) - users may also call initialize(), which in turn calls this method.
Raises an exception upon error.
Parameters:
std::exception |
A textual description of the error. |
unsigned int openDevicesBySerialNum(const std::set<unsigned>& vSerialRequired)
Open a set of RGBD devices specified by their serial number.
Raises an exception when the demanded serial numbers are not among the connected devices. This function also fills a vector with the serial numbers of the connected OpenNI2 sensors (this requires openning the sensors which are still closed to read their serial)
unsigned int openDeviceBySerial(const unsigned int SerialRequired)
Open a RGBD device specified by its serial number.
This method is a wrapper for openDevicesBySerialNum(const std::set<unsigned>& vSerialRequired) This method requires to open the sensors which are still closed to read their serial.
bool getDeviceIDFromSerialNum(const unsigned int SerialRequired, int& sensor_id) const
Get the ID of the device corresponding to ‘SerialRequired’.
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually).
Returns:
false on error
See also:
void kill()
Kill the OpenNI2 driver.
See also:
bool isOpen(const unsigned sensor_id) const
Whether there is a working connection to the sensor.
void close(unsigned sensor_id = 0)
Close the connection to the sensor (no need to call it manually unless desired for some reason, since it’s called at destructor.
int getNumDevices() const
The number of available devices at initialization.
int getConnectedDevices()
Get a list of the connected OpenNI2 sensors.
This method can or cannot be implemented in the derived class, depending on the need for it.
Parameters:
This |
method must throw an exception with a descriptive message if some critical error is found. |
void getNextFrameRGB( mrpt::img::CImage& rgb_img, mrpt::system::TTimeStamp& timestamp, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 )
The main data retrieving function, to be called after calling loadConfig() and initialize().
Parameters:
out_img |
The output retrieved RGB image (only if there_is_obs=true). |
timestamp |
The timestamp of the capture (only if there_is_obs=true). |
there_is_obs |
If set to false, there was no new observation. |
hardware_error |
True on hardware/comms error. |
sensor_id |
The index of the sensor accessed. |
out_obs |
The output retrieved observation (only if there_is_obs=true). |
timestamp |
The timestamp of the capture (only if there_is_obs=true). |
there_is_obs |
If set to false, there was no new observation. |
hardware_error |
True on hardware/comms error. |
sensor_id |
The index of the sensor accessed. |
void getNextFrameD( mrpt::math::CMatrix_u16& depth_img_mm, mrpt::system::TTimeStamp& timestamp, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 )
The main data retrieving function, to be called after calling loadConfig() and initialize().
Parameters:
depth_img |
The output retrieved depth image (only if there_is_obs=true). |
timestamp |
The timestamp of the capture (only if there_is_obs=true). |
there_is_obs |
If set to false, there was no new observation. |
hardware_error |
True on hardware/comms error. |
sensor_id |
The index of the sensor accessed. |
void getNextFrameRGBD( mrpt::obs::CObservation3DRangeScan& out_obs, bool& there_is_obs, bool& hardware_error, unsigned sensor_id = 0 )
The main data retrieving function, to be called after calling loadConfig() and initialize().
Parameters:
out_obs |
The output retrieved observation (only if there_is_obs=true). |
there_is_obs |
If set to false, there was no new observation. |
hardware_error |
True on hardware/comms error. |
sensor_id |
The index of the sensor accessed. |
out_obs |
The output retrieved observation (only if there_is_obs=true). |
there_is_obs |
If set to false, there was no new observation. |
hardware_error |
True on hardware/comms error. |
sensor_id |
The index of the sensor accessed. |
See also:
doProcess
static int getNumInstances()
Get the number of OpenNI2 cameras currently open via COpenNI2Generic.