MRPT
1.9.9
|
An abstract class for accessing OpenNI2 compatible sensors.
This class permits to access several sensors simultaneously. The same options (resolution, fps, etc.) are used for every sensor.
More references to read:
Definition at line 23 of file COpenNI2Generic.h.
#include <mrpt/hwdrivers/COpenNI2Generic.h>
Classes | |
class | CDevice |
Public Member Functions | |
COpenNI2Generic () | |
Default ctor (width=640, height=480, fps=30) More... | |
COpenNI2Generic (int width, int height, float fps=30.0f, bool open_streams_now=true) | |
Ctor. More... | |
~COpenNI2Generic () | |
Default ctor. More... | |
void | getNextFrameRGB (mrpt::img::CImage &rgb_img, mrpt::system::TTimeStamp ×tamp, bool &there_is_obs, bool &hardware_error, unsigned sensor_id=0) |
The main data retrieving function, to be called after calling loadConfig() and initialize(). More... | |
void | getNextFrameD (mrpt::math::CMatrix_u16 &depth_img_mm, mrpt::system::TTimeStamp ×tamp, bool &there_is_obs, bool &hardware_error, unsigned sensor_id=0) |
The main data retrieving function, to be called after calling loadConfig() and initialize(). More... | |
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(). More... | |
void | setVerbose (bool verbose) |
bool | isVerbose () const |
bool | getColorSensorParam (mrpt::img::TCamera ¶m, unsigned sensor_id=0) const |
bool | getDepthSensorParam (mrpt::img::TCamera ¶m, unsigned sensor_id=0) const |
Open/Close device 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. More... | |
unsigned int | openDevicesBySerialNum (const std::set< unsigned > &vSerialRequired) |
Open a set of RGBD devices specified by their serial number. More... | |
unsigned int | openDeviceBySerial (const unsigned int SerialRequired) |
Open a RGBD device specified by its serial number. More... | |
bool | getDeviceIDFromSerialNum (const unsigned int SerialRequired, int &sensor_id) const |
Get the ID of the device corresponding to 'SerialRequired'. More... | |
bool | start () |
Open all sensor streams (normally called automatically at constructor, no need to call it manually). More... | |
void | kill () |
Kill the OpenNI2 driver. More... | |
bool | isOpen (const unsigned sensor_id) const |
Whether there is a working connection to the sensor. More... | |
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. More... | |
int | getNumDevices () const |
The number of available devices at initialization. More... | |
int | getConnectedDevices () |
Get a list of the connected OpenNI2 sensors. More... | |
Static Public Member Functions | |
static int | getNumInstances () |
Get the number of OpenNI2 cameras currently open via COpenNI2Generic. More... | |
Protected Member Functions | |
void | showLog (const std::string &message) const |
Protected Attributes | |
std::vector< int > | vSerialNums |
A vector with the serial numbers of the available devices. More... | |
int | m_width {640} |
The same options (width, height and fps) are set for all the sensors. More... | |
int | m_height {480} |
float | m_fps {30.0f} |
int | m_rgb_format |
int | m_depth_format |
bool | m_verbose {false} |
bool | m_grab_image {true} |
The data that the RGBD sensors can return. More... | |
bool | m_grab_depth {true} |
bool | m_grab_3D_points {true} |
COpenNI2Generic::COpenNI2Generic | ( | ) |
Default ctor (width=640, height=480, fps=30)
Definition at line 63 of file COpenNI2Generic.cpp.
References mrpt::format(), and THROW_EXCEPTION.
COpenNI2Generic::COpenNI2Generic | ( | int | width, |
int | height, | ||
float | fps = 30.0f , |
||
bool | open_streams_now = true |
||
) |
Ctor.
Definition at line 82 of file COpenNI2Generic.cpp.
References mrpt::format(), m_verbose, start(), and THROW_EXCEPTION.
COpenNI2Generic::~COpenNI2Generic | ( | ) |
Default ctor.
Definition at line 137 of file COpenNI2Generic.cpp.
References kill(), and numInstances().
void COpenNI2Generic::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.
Definition at line 390 of file COpenNI2Generic.cpp.
References getNumDevices(), THROW_EXCEPTION, vDevices, and vDevices_mx.
bool COpenNI2Generic::getColorSensorParam | ( | mrpt::img::TCamera & | param, |
unsigned | sensor_id = 0 |
||
) | const |
Definition at line 513 of file COpenNI2Generic.cpp.
References mrpt::hwdrivers::COpenNI2Generic::CDevice::COLOR_STREAM, isOpen(), THROW_EXCEPTION, vDevices, and vDevices_mx.
int COpenNI2Generic::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.
This | method must throw an exception with a descriptive message if some critical error is found. |
Definition at line 166 of file COpenNI2Generic.cpp.
References mrpt::format(), getNumDevices(), m_depth_format, m_rgb_format, m_verbose, showLog(), THROW_EXCEPTION, vDevices, and vDevices_mx.
bool COpenNI2Generic::getDepthSensorParam | ( | mrpt::img::TCamera & | param, |
unsigned | sensor_id = 0 |
||
) | const |
Definition at line 529 of file COpenNI2Generic.cpp.
References mrpt::hwdrivers::COpenNI2Generic::CDevice::DEPTH_STREAM, isOpen(), THROW_EXCEPTION, vDevices, and vDevices_mx.
bool COpenNI2Generic::getDeviceIDFromSerialNum | ( | const unsigned int | SerialRequired, |
int & | sensor_id | ||
) | const |
Get the ID of the device corresponding to 'SerialRequired'.
Definition at line 365 of file COpenNI2Generic.cpp.
References THROW_EXCEPTION, vDevices, and vDevices_mx.
void COpenNI2Generic::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().
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. |
Definition at line 448 of file COpenNI2Generic.cpp.
References mrpt::format(), getNumDevices(), showLog(), THROW_EXCEPTION, and vDevices.
void COpenNI2Generic::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().
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. |
Definition at line 419 of file COpenNI2Generic.cpp.
References mrpt::format(), getNumDevices(), showLog(), THROW_EXCEPTION, and vDevices.
void COpenNI2Generic::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().
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. |
Definition at line 485 of file COpenNI2Generic.cpp.
References mrpt::format(), getNumDevices(), showLog(), THROW_EXCEPTION, and vDevices.
int COpenNI2Generic::getNumDevices | ( | ) | const |
The number of available devices at initialization.
Definition at line 146 of file COpenNI2Generic.cpp.
References vDevices, and vDevices_mx.
Referenced by close(), getConnectedDevices(), getNextFrameD(), getNextFrameRGB(), getNextFrameRGBD(), isOpen(), and open().
|
static |
Get the number of OpenNI2 cameras currently open via COpenNI2Generic.
Definition at line 55 of file COpenNI2Generic.cpp.
References numInstances().
bool COpenNI2Generic::isOpen | ( | const unsigned | sensor_id | ) | const |
Whether there is a working connection to the sensor.
Definition at line 244 of file COpenNI2Generic.cpp.
References getNumDevices(), vDevices, and vDevices_mx.
Referenced by getColorSensorParam(), getDepthSensorParam(), open(), and openDevicesBySerialNum().
bool COpenNI2Generic::isVerbose | ( | ) | const |
Definition at line 152 of file COpenNI2Generic.cpp.
References m_verbose.
Referenced by showLog().
void COpenNI2Generic::kill | ( | ) |
Kill the OpenNI2 driver.
Definition at line 233 of file COpenNI2Generic.cpp.
References THROW_EXCEPTION, vDevices, and vDevices_mx.
Referenced by ~COpenNI2Generic().
void COpenNI2Generic::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.
std::exception | A textual description of the error. |
Definition at line 258 of file COpenNI2Generic.cpp.
References mrpt::format(), getNumDevices(), isOpen(), m_fps, m_height, m_verbose, m_width, showLog(), THROW_EXCEPTION, vDevices, and vDevices_mx.
Referenced by openDevicesBySerialNum().
unsigned int COpenNI2Generic::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.
Definition at line 357 of file COpenNI2Generic.cpp.
References openDevicesBySerialNum().
unsigned int COpenNI2Generic::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)
Definition at line 302 of file COpenNI2Generic.cpp.
References mrpt::format(), isOpen(), m_fps, m_height, m_verbose, m_width, open(), showLog(), THROW_EXCEPTION, vDevices, and vDevices_mx.
Referenced by openDeviceBySerial().
void COpenNI2Generic::setVerbose | ( | bool | verbose | ) |
Definition at line 151 of file COpenNI2Generic.cpp.
|
protected |
Definition at line 153 of file COpenNI2Generic.cpp.
References isVerbose().
Referenced by getConnectedDevices(), getNextFrameD(), getNextFrameRGB(), getNextFrameRGBD(), open(), and openDevicesBySerialNum().
bool COpenNI2Generic::start | ( | ) |
Open all sensor streams (normally called automatically at constructor, no need to call it manually).
Definition at line 112 of file COpenNI2Generic.cpp.
References initialize(), numInstances(), and THROW_EXCEPTION.
Referenced by COpenNI2Generic().
|
protected |
Definition at line 155 of file COpenNI2Generic.h.
Referenced by getConnectedDevices().
|
protected |
Definition at line 154 of file COpenNI2Generic.h.
Referenced by open(), and openDevicesBySerialNum().
|
protected |
Definition at line 161 of file COpenNI2Generic.h.
Referenced by mrpt::hwdrivers::COpenNI2Sensor::enableGrab3DPoints(), and mrpt::hwdrivers::COpenNI2Sensor::isGrab3DPointsEnabled().
|
protected |
Definition at line 161 of file COpenNI2Generic.h.
Referenced by mrpt::hwdrivers::COpenNI2Sensor::enableGrabDepth(), and mrpt::hwdrivers::COpenNI2Sensor::isGrabDepthEnabled().
|
protected |
The data that the RGBD sensors can return.
Default: all true
Definition at line 161 of file COpenNI2Generic.h.
Referenced by mrpt::hwdrivers::COpenNI2Sensor::enableGrabRGB(), and mrpt::hwdrivers::COpenNI2Sensor::isGrabRGBEnabled().
|
protected |
Definition at line 153 of file COpenNI2Generic.h.
Referenced by open(), and openDevicesBySerialNum().
|
protected |
Definition at line 155 of file COpenNI2Generic.h.
Referenced by getConnectedDevices().
|
protected |
Definition at line 156 of file COpenNI2Generic.h.
Referenced by COpenNI2Generic(), getConnectedDevices(), isVerbose(), open(), openDevicesBySerialNum(), and setVerbose().
|
protected |
The same options (width, height and fps) are set for all the sensors.
(This could be changed if necessary)
Definition at line 153 of file COpenNI2Generic.h.
Referenced by open(), and openDevicesBySerialNum().
|
protected |
A vector with the serial numbers of the available devices.
Definition at line 145 of file COpenNI2Generic.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020 |