17 #include <mrpt/otherlibs/do_opencv_includes.h> 41 std::vector<std::shared_ptr<COpenNI2Generic::CDevice>>
vDevices;
46 bool setONI2StreamMode(
47 openni::VideoStream& stream,
int w,
int h,
int fps,
48 openni::PixelFormat
format);
49 std::string oni2DevInfoStr(
const openni::DeviceInfo& info,
int tab = 0);
50 bool cmpONI2Device(
const openni::DeviceInfo& i1,
const openni::DeviceInfo& i2);
51 #endif // MRPT_HAS_OPENNI2 68 m_rgb_format(openni::PIXEL_FORMAT_RGB888),
69 m_depth_format(openni::PIXEL_FORMAT_DEPTH_1_MM),
74 m_grab_3D_points(true)
76 const char* sVerbose = getenv(
"MRPT_HWDRIVERS_VERBOSE");
77 m_verbose = (sVerbose !=
nullptr) && atoi(sVerbose) != 0;
83 "After initialization:\n %s\n", openni::OpenNI::getExtendedError()))
89 int width,
int height,
float fps,
bool open_streams_now)
94 m_rgb_format(openni::PIXEL_FORMAT_RGB888),
95 m_depth_format(openni::PIXEL_FORMAT_DEPTH_1_MM),
100 m_grab_3D_points(true)
102 const char* sVerbose = getenv(
"MRPT_HWDRIVERS_VERBOSE");
103 m_verbose = (sVerbose !=
nullptr) && atoi(sVerbose) != 0;
105 if (open_streams_now)
111 "After initialization:\n %s\n",
112 openni::OpenNI::getExtendedError()))
123 if (openni::OpenNI::initialize() != openni::STATUS_OK)
129 std::cerr <<
"[" << __FUNCTION__ <<
"]" << std::endl
130 <<
" Initialized OpenNI2." << std::endl;
137 #endif // MRPT_HAS_OPENNI2 154 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
165 std::cerr << message;
175 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
177 openni::Array<openni::DeviceInfo> oni2InfoArray;
178 openni::OpenNI::enumerateDevices(&oni2InfoArray);
180 const size_t numDevices = oni2InfoArray.getSize();
183 " Get device list. %d devices connected.\n", (
int)numDevices));
186 std::set<int> newDevices;
187 for (
unsigned i = 0; i < numDevices; i++)
189 const openni::DeviceInfo& info = oni2InfoArray[i];
191 showLog(oni2DevInfoStr(info, 3) +
"\n");
193 bool isExist =
false;
194 for (
unsigned int j = 0, j_end =
vDevices.size();
195 j < j_end && isExist ==
false; ++j)
197 if (cmpONI2Device(info,
vDevices[j]->getInfo()))
202 if (isExist ==
false)
204 newDevices.insert(i);
209 it_end = newDevices.end();
212 const openni::DeviceInfo& info = oni2InfoArray[*it];
219 if (device->getSerialNumber(sn))
222 mrpt::format(
"Device[%d]: serial number: `%u`\n", *it, sn));
229 showLog(
" No devices connected -> EXIT\n");
238 #endif // MRPT_HAS_OPENNI2 243 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
246 openni::OpenNI::shutdown();
249 #endif // MRPT_HAS_OPENNI2 255 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
260 return vDevices[sensor_id]->isOpen();
264 #endif // MRPT_HAS_OPENNI2 270 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
279 "Sensor index is higher than the number of connected devices.")
287 mrpt::format(
" The sensor [%d] is already opened\n", sensor_id));
292 "[COpenNI2Generic] DBG: [%s] about to call vDevices[%d]->open()\n",
293 __FUNCTION__, sensor_id);
299 showLog(
" open successfully.\n");
305 std::this_thread::sleep_for(1000ms);
309 #endif // MRPT_HAS_OPENNI2 313 const std::set<unsigned>& serial_required)
316 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
318 unsigned num_open_dev = 0;
319 for (
unsigned sensor_id = 0; sensor_id <
vDevices.size(); sensor_id++)
321 unsigned int serialNum;
322 if (
vDevices[sensor_id]->getSerialNumber(serialNum) ==
false)
329 "[COpenNI2Generic::openDevicesBySerialNum] checking device " 330 "with serial '%d'\n",
333 if (serial_required.find(serialNum) == serial_required.end())
347 "[COpenNI2Generic] DBG: [%s] about to call " 348 "vDevices[%d]->open(%d,%d,%d)\n",
358 "[COpenNI2Generic] DBG: [%s] now has %d devices open\n",
359 __FUNCTION__, num_open_dev);
365 #endif // MRPT_HAS_OPENNI2 369 const unsigned int SerialRequired)
371 std::set<unsigned> serial_required;
372 serial_required.insert(SerialRequired);
377 const unsigned int SerialRequired,
int& sensor_id)
const 380 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
381 for (
size_t i = 0, i_end =
vDevices.size(); i < i_end; ++i)
384 if (
vDevices[i]->getSerialNumber(sn) ==
false)
388 if (sn == SerialRequired)
399 #endif // MRPT_HAS_OPENNI2 405 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
414 "Sensor index is higher than the number of connected devices.")
420 #endif // MRPT_HAS_OPENNI2 434 bool& there_is_obs,
bool& hardware_error,
unsigned sensor_id)
445 "Sensor index is higher than the number of connected devices.")
448 rgb_img, timestamp, there_is_obs, hardware_error) ==
false)
461 #endif // MRPT_HAS_OPENNI2 476 bool& there_is_obs,
bool& hardware_error,
unsigned sensor_id)
487 "Sensor index is higher than the number of connected devices.")
490 depth_img, timestamp, there_is_obs, hardware_error) ==
false)
503 #endif // MRPT_HAS_OPENNI2 516 bool& hardware_error,
unsigned sensor_id)
527 "Sensor index is higher than the number of connected devices.")
530 out_obs, there_is_obs, hardware_error) ==
false)
542 #endif // MRPT_HAS_OPENNI2 549 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
550 if (
isOpen(sensor_id) ==
false)
559 #endif // MRPT_HAS_OPENNI2 566 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
567 if (
isOpen(sensor_id) ==
false)
576 #endif // MRPT_HAS_OPENNI2 589 bool setONI2StreamMode(
590 openni::VideoStream& stream,
int w,
int h,
int fps,
591 openni::PixelFormat
format)
596 const openni::Array<openni::VideoMode>& modes =
597 stream.getSensorInfo().getSupportedVideoModes();
598 for (
int i = 0, i_end = modes.getSize(); i < i_end; ++i)
604 if (modes[i].getResolutionX() !=
w)
608 if (modes[i].getResolutionY() != h)
612 if (modes[i].getFps() != fps)
616 if (modes[i].getPixelFormat() !=
format)
621 if (rc != openni::STATUS_OK)
630 std::string oni2DevInfoStr(
const openni::DeviceInfo& info,
int tab)
632 std::stringstream sst;
634 for (
int i = 0; i < tab; ++i)
638 sst << space <<
"name=" << info.getName() << std::endl;
639 sst << space <<
"uri=" << info.getUri() << std::endl;
640 sst << space <<
"vendor=" << info.getVendor() << std::endl;
641 sst << space <<
"product=" << info.getUsbProductId();
645 bool cmpONI2Device(
const openni::DeviceInfo& i1,
const openni::DeviceInfo& i2)
647 return (strcmp(i1.getUri(), i2.getUri()) == 0);
650 COpenNI2Generic::CDevice::CDevice(
651 const openni::DeviceInfo& info, openni::PixelFormat rgb,
652 openni::PixelFormat
depth,
bool verbose)
653 : m_info(info), m_mirror(true), m_verbose(verbose)
655 m_streams[COLOR_STREAM] =
656 CStream::create(m_device, openni::SENSOR_COLOR, rgb, m_log,
m_verbose);
657 m_streams[IR_STREAM] =
658 CStream::create(m_device, openni::SENSOR_IR, rgb, m_log,
m_verbose);
659 m_streams[DEPTH_STREAM] = CStream::create(
663 COpenNI2Generic::CDevice::~CDevice() {
close(); }
664 bool COpenNI2Generic::CDevice::synchMirrorMode()
668 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
670 if (!m_streams[i])
continue;
674 mirror_support = m_streams[i]->isMirrorSupported();
676 catch (std::logic_error& e)
680 if (mirror_support ==
false)
682 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl;
683 m_log <<
" openni::STREAM_PROPERTY_MIRRORING is not supported on " 684 << m_streams[i]->getName() <<
"." << std::endl;
685 m_log <<
" We assume this is MS Kinect and taken images are " 686 "inverted to right and left." 695 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
697 if (!m_streams[i])
continue;
698 if (m_streams[i]->isMirrorSupported() ==
false)
702 if (m_streams[i]->setMirror(m_mirror) ==
false)
710 bool COpenNI2Generic::CDevice::startStreams()
714 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
716 if (!m_streams[i])
continue;
718 printf(
" [%s] calling m_streams[%d]->start()\n", __FUNCTION__, i);
719 if (m_streams[i]->
start() ==
false)
723 " [%s] m_streams[%d]->start() returned FALSE!\n",
732 " [%s] m_streams[%d]->start() returned TRUE\n", __FUNCTION__,
737 " [COpenNI2Generic::CDevice::startStreams()] %d streams were " 744 bool COpenNI2Generic::CDevice::isOpen()
const 746 return (m_streams[COLOR_STREAM] && m_streams[COLOR_STREAM]->isValid()) ||
747 (m_streams[DEPTH_STREAM] && m_streams[DEPTH_STREAM]->isValid());
750 void COpenNI2Generic::CDevice::close()
752 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
754 if (!m_streams[i])
continue;
755 m_streams[i]->destroy();
760 bool COpenNI2Generic::CDevice::open(
int w,
int h,
int fps)
765 " [COpenNI2Generic::CDevice::open()] Called with w=%i h=%i " 771 if (rc != openni::STATUS_OK)
773 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
774 <<
" Failed to open device " << getInfo().getUri() <<
" " 775 << openni::OpenNI::getExtendedError() << std::endl;
778 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
780 if (!m_streams[i])
continue;
782 printf(
" [%s] calling m_streams[%d]->open()\n", __FUNCTION__, i);
784 if (m_streams[i]->
open(
w, h, fps) ==
false)
788 " [%s] m_streams[%d]->open() returned FALSE\n",
794 " [%s] m_streams[%d]->open() returned OK\n", __FUNCTION__, i);
797 if (synchMirrorMode() ==
false)
803 if (m_streams[DEPTH_STREAM])
806 m_streams[DEPTH_STREAM]->setCloseRange(CloseRange);
807 m_log <<
" Close range: " << (CloseRange ?
"On" :
"Off") << std::endl;
811 printf(
" DBG: checking if imageRegistrationMode is supported\n");
812 if (m_device.isImageRegistrationModeSupported(
813 openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR) &&
814 m_streams[DEPTH_STREAM] && m_streams[DEPTH_STREAM]->isValid() &&
815 m_streams[COLOR_STREAM] && m_streams[COLOR_STREAM]->isValid())
820 if (m_device.setImageRegistrationMode(
821 openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR) != openni::STATUS_OK)
823 m_log <<
" setImageRegistrationMode() Failed:" 824 << openni::OpenNI::getExtendedError() << endl;
828 m_log <<
" setImageRegistrationMode() Success" << endl;
833 m_log <<
" Device doesn't do image registration!" << endl;
838 m_streams[COLOR_STREAM]->disableAutoExposure();
839 printf(
"DBG: returned from disableAutoExposure()\n");
842 if (startStreams() ==
false)
851 bool COpenNI2Generic::CDevice::getNextFrameRGB(
853 bool& there_is_obs,
bool& hardware_error)
860 openni::VideoFrameRef frame;
861 if (m_streams[COLOR_STREAM]->getFrame(
862 frame, timestamp, there_is_obs, hardware_error) ==
false)
866 copyFrame<openni::RGB888Pixel, mrpt::img::CImage>(frame,
img);
872 bool COpenNI2Generic::CDevice::getNextFrameD(
874 bool& there_is_obs,
bool& hardware_error)
881 openni::VideoFrameRef frame;
882 if (m_streams[DEPTH_STREAM]->getFrame(
883 frame, timestamp, there_is_obs, hardware_error) ==
false)
887 copyFrame<openni::DepthPixel, mrpt::math::CMatrix>(frame,
img);
893 bool COpenNI2Generic::CDevice::getNextFrameRGBD(
895 bool& hardware_error)
899 there_is_obs =
false;
900 hardware_error =
false;
912 openni::VideoFrameRef frame[STREAM_TYPE_SIZE];
913 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
915 if (!m_streams[i] || !m_streams[i]->isValid())
continue;
916 if (m_streams[i]->getFrame(
917 frame[i], tm, there_is_obs, hardware_error) ==
false)
921 if (there_is_obs ==
false || hardware_error ==
true)
927 const int width = frame[COLOR_STREAM].getWidth();
928 const int height = frame[COLOR_STREAM].getHeight();
929 if ((frame[DEPTH_STREAM].getWidth() !=
width) ||
932 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
933 <<
" Both frames don't have the same size." << std::endl;
945 const char*
data[STREAM_TYPE_SIZE] = {
946 (
const char*)frame[COLOR_STREAM].getData(),
947 (
const char*)frame[DEPTH_STREAM].getData()};
948 const int step[STREAM_TYPE_SIZE] = {frame[COLOR_STREAM].getStrideInBytes(),
949 frame[DEPTH_STREAM].getStrideInBytes()};
951 for (
int yc = 0; yc <
height; ++yc)
953 const openni::RGB888Pixel* pRgb =
954 (
const openni::RGB888Pixel*)
data[COLOR_STREAM];
955 const openni::DepthPixel* pDepth =
956 (
const openni::DepthPixel*)
data[DEPTH_STREAM];
957 for (
int xc = 0; xc <
width; ++xc, ++pDepth, ++pRgb)
967 data[COLOR_STREAM] += step[COLOR_STREAM];
968 data[DEPTH_STREAM] += step[DEPTH_STREAM];
976 const openni::DeviceInfo& info, openni::PixelFormat rgb,
977 openni::PixelFormat
depth,
bool verbose)
979 return Ptr(
new CDevice(info, rgb,
depth, verbose));
982 bool COpenNI2Generic::CDevice::getSerialNumber(
std::string& sn)
987 if (isOpened ==
false)
989 rc = m_device.open(getInfo().getUri());
990 if (rc != openni::STATUS_OK)
992 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
993 <<
" Failed to open device " << getInfo().getUri() <<
" " 994 << openni::OpenNI::getExtendedError() << std::endl;
998 char serialNumber[16];
999 rc = m_device.getProperty(ONI_DEVICE_PROPERTY_SERIAL_NUMBER, &serialNumber);
1000 if (rc != openni::STATUS_OK)
1002 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1003 <<
" Failed to getProperty(ONI_DEVICE_PROPERTY_SERIAL_NUMBER) " 1004 << getInfo().getUri() <<
" " << openni::OpenNI::getExtendedError()
1009 if (isOpened ==
false)
1016 bool COpenNI2Generic::CDevice::getSerialNumber(
unsigned int& sn)
1019 if (getSerialNumber(str) ==
false)
1023 std::stringstream sst;
1031 std::ostream& log,
bool verbose)
1034 m_strName(
"Unknown"),
1039 if (m_type == openni::SENSOR_COLOR)
1041 m_strName =
"openni::SENSOR_COLOR";
1043 else if (m_type == openni::SENSOR_DEPTH)
1045 m_strName =
"openni::SENSOR_DEPTH";
1047 else if (m_type == openni::SENSOR_IR)
1049 m_strName =
"openni::SENSOR_IR";
1053 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1054 <<
" Unknown SensorType -> " << m_type << std::endl;
1058 COpenNI2Generic::CDevice::CStream::~CStream() { destroy(); }
1059 bool COpenNI2Generic::CDevice::CStream::isMirrorSupported()
const 1061 if (isValid() ==
false)
1065 return m_stream.isPropertySupported(openni::STREAM_PROPERTY_MIRRORING);
1068 bool COpenNI2Generic::CDevice::CStream::setMirror(
bool flag)
1070 if (isValid() ==
false)
1072 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1073 <<
" " << getName() <<
" is not opened." << std::endl;
1076 if (m_stream.isPropertySupported(openni::STREAM_PROPERTY_MIRRORING) ==
1081 if (m_stream.setMirroringEnabled(flag) != openni::STATUS_OK)
1083 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1084 <<
" setMirroringEnabled() failed: " 1085 << openni::OpenNI::getExtendedError() << std::endl;
1091 bool COpenNI2Generic::CDevice::CStream::isValid()
const 1093 return m_stream.isValid();
1096 void COpenNI2Generic::CDevice::CStream::destroy() { m_stream.destroy(); }
1097 void COpenNI2Generic::CDevice::CStream::setCloseRange(
int&
value)
1101 " [CDevice::CStream::setCloseRange] entry with value=%d\n",
1103 m_stream.setProperty(XN_STREAM_PROPERTY_CLOSE_RANGE,
value);
1106 " [CDevice::CStream::setCloseRange] returned from " 1107 "mstream.setProperty()\n");
1108 m_stream.getProperty(XN_STREAM_PROPERTY_CLOSE_RANGE, &
value);
1111 " [CDevice::CStream::setCloseRange] returned from " 1112 "mstream.getProperty() ... value %d\n",
1116 bool COpenNI2Generic::CDevice::CStream::open(
int w,
int h,
int fps)
1119 if (m_type != openni::SENSOR_COLOR && m_type != openni::SENSOR_DEPTH &&
1120 m_type != openni::SENSOR_IR)
1122 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1123 <<
" Unknown SensorType -> " << m_type << std::endl;
1128 " [COpenNI2Generic::CDevice::CStream::open] opening sensor " 1129 "stream with m_type == %d\n",
1138 rc = m_stream.create(m_device, m_type);
1139 if (rc != openni::STATUS_OK)
1141 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1142 <<
" Couldn't find sensor " << m_strName <<
":" 1143 << openni::OpenNI::getExtendedError() << std::endl;
1144 if (m_type == openni::SENSOR_COLOR)
1146 m_type = openni::SENSOR_IR;
1147 m_strName =
"openni::SENSOR_IR";
1149 printf(
"DBG: changing type to SENSOR_IR (%d)\n", (
int)m_type);
1150 rc = m_stream.create(m_device, m_type);
1155 if (m_verbose) printf(
"returned OK from stream.create()\n");
1156 openni::VideoMode options = m_stream.getVideoMode();
1157 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl;
1158 m_log <<
" " << m_strName << std::endl;
1161 "Initial resolution (%d, %d) FPS %d Format %d",
1162 options.getResolutionX(), options.getResolutionY(),
1163 options.getFps(), options.getPixelFormat())
1165 if (m_verbose) printf(
"DBG: calling setONI2StreamMode()\n");
1166 if (setONI2StreamMode(m_stream,
w, h, fps, m_format) ==
false)
1168 m_log <<
" Can't find desired mode in the " << getName() << std::endl;
1172 if (m_verbose) printf(
"DBG: returned OK from setONI2StreamMode()\n");
1173 if (m_verbose) printf(
"DBG: calling stream.getVideoMode()\n");
1174 options = m_stream.getVideoMode();
1177 "-> (%d, %d) FPS %d Format %d", options.getResolutionX(),
1178 options.getResolutionY(), options.getFps(),
1179 options.getPixelFormat())
1183 " [COpenNI2Generic::CDevice::CStream::open] returning TRUE\n");
1189 if (isValid() ==
false)
1191 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1192 <<
" " << getName() <<
" is not opened." << std::endl;
1195 if (m_stream.start() != openni::STATUS_OK)
1197 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1198 <<
" Couldn't start " << getName()
1199 <<
" stream:" << openni::OpenNI::getExtendedError() << std::endl;
1206 COpenNI2Generic::CDevice::CStream::Ptr
1207 COpenNI2Generic::CDevice::CStream::create(
1209 openni::PixelFormat
format, std::ostream& log,
bool verbose)
1214 bool COpenNI2Generic::CDevice::CStream::getFrame(
1216 bool& there_is_obs,
bool& hardware_error)
1218 there_is_obs =
false;
1219 hardware_error =
false;
1220 if (isValid() ==
false)
1225 if (rc != openni::STATUS_OK)
1227 hardware_error =
true;
1229 mrpt::format(
"Failed to grab frame from %s", getName().c_str());
1232 there_is_obs =
true;
1237 #endif // MRPT_HAS_OPENNI2
void setVerbose(bool verbose)
int getNumDevices() const
The number of available devices at initialization.
bool getDepthSensorParam(mrpt::img::TCamera ¶m, unsigned sensor_id=0) const
#define THROW_EXCEPTION(msg)
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
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().
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
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().
Contains classes for various device interfaces.
COpenNI2Generic()
Default ctor (width=640, height=480, fps=30)
GLint GLint GLsizei GLsizei GLsizei depth
mrpt::io::CStream CStream
GLubyte GLubyte GLubyte GLubyte w
int m_width
The same options (width, height and fps) are set for all the sensors.
void kill()
Kill the OpenNI2 driver.
mrpt::math::CMatrix rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) ...
std::vector< std::shared_ptr< COpenNI2Generic::CDevice > > vDevices
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
unsigned int openDeviceBySerial(const unsigned int SerialRequired)
Open a RGBD device specified by its serial number.
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually)...
bool getColorSensorParam(mrpt::img::TCamera ¶m, unsigned sensor_id=0) const
bool isOpen(const unsigned sensor_id) const
Whether there is a working connection to the sensor.
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"...
static int getNumInstances()
Get the number of OpenNI2 cameras currently open via COpenNI2Generic.
This namespace contains representation of robot actions and observations.
void getNextFrameD(mrpt::math::CMatrix &depth_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().
bool hasRangeImage
true means the field rangeImage contains valid data
void close(unsigned sensor_id=0)
Close the connection to the sensor (no need to call it manually unless desired for some reason...
Structure to hold the parameters of a pinhole camera model.
std::atomic< int > numInstances(0)
enum Status { eInsideTag=0, eOutsideTag } Status
bool hasPoints3D
true means the field points3D contains valid data.
GLsizei const GLchar ** string
unsigned int openDevicesBySerialNum(const std::set< unsigned > &vSerialRequired)
Open a set of RGBD devices specified by their serial number.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
bool hasIntensityImage
true means the field intensityImage contains valid data
std::recursive_mutex vDevices_mx
void open(unsigned sensor_id=0)
Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - us...
bool getDeviceIDFromSerialNum(const unsigned int SerialRequired, int &sensor_id) const
Get the ID of the device corresponding to 'SerialRequired'.
GLenum GLsizei GLenum format
int getConnectedDevices()
Get a list of the connected OpenNI2 sensors.
GLsizei const GLfloat * value
void showLog(const std::string &message) const
~COpenNI2Generic()
Default ctor.
This class is a "CSerializable" wrapper for "CMatrixFloat".
double getHeight(const TPolygon3D &p, const TPoint3D &c)
GLenum GLsizei GLsizei height
bool range_is_depth
true: Kinect-like ranges: entries of rangeImage are distances along the +X axis; false: Ranges in ran...
GLsizei GLsizei GLenum GLenum const GLvoid * data
const Scalar * const_iterator
GLuint GLuint GLsizei GLenum type
A class for storing images as grayscale or RGB bitmaps.
bool hasConfidenceImage
true means the field confidenceImage contains valid data
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.