17 #include <mrpt/3rdparty/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 65 : m_rgb_format(openni::PIXEL_FORMAT_RGB888),
66 m_depth_format(openni::PIXEL_FORMAT_DEPTH_1_MM)
69 const char* sVerbose = getenv(
"MRPT_HWDRIVERS_VERBOSE");
70 m_verbose = (sVerbose !=
nullptr) && atoi(sVerbose) != 0;
76 "After initialization:\n %s\n",
77 openni::OpenNI::getExtendedError()));
83 int width,
int height,
float fps,
bool open_streams_now)
88 m_rgb_format(openni::PIXEL_FORMAT_RGB888),
89 m_depth_format(openni::PIXEL_FORMAT_DEPTH_1_MM),
94 m_grab_3D_points(true)
96 const char* sVerbose = getenv(
"MRPT_HWDRIVERS_VERBOSE");
97 m_verbose = (sVerbose !=
nullptr) && atoi(sVerbose) != 0;
105 "After initialization:\n %s\n",
106 openni::OpenNI::getExtendedError()));
123 std::cerr <<
"[" << __FUNCTION__ <<
"]" << std::endl
124 <<
" Initialized OpenNI2." << std::endl;
131 #endif // MRPT_HAS_OPENNI2 148 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
159 std::cerr << message;
169 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
171 openni::Array<openni::DeviceInfo> oni2InfoArray;
172 openni::OpenNI::enumerateDevices(&oni2InfoArray);
174 const size_t numDevices = oni2InfoArray.getSize();
177 " Get device list. %d devices connected.\n", (
int)numDevices));
180 std::set<int> newDevices;
181 for (
unsigned i = 0; i < numDevices; i++)
183 const openni::DeviceInfo& info = oni2InfoArray[i];
185 showLog(oni2DevInfoStr(info, 3) +
"\n");
187 bool isExist =
false;
188 for (
unsigned int j = 0, j_end =
vDevices.size();
189 j < j_end && isExist ==
false; ++j)
191 if (cmpONI2Device(info,
vDevices[j]->getInfo()))
196 if (isExist ==
false)
198 newDevices.insert(i);
202 for (
int newDevice : newDevices)
204 const openni::DeviceInfo& info = oni2InfoArray[newDevice];
211 if (device->getSerialNumber(sn))
214 "Device[%d]: serial number: `%u`\n", newDevice, sn));
221 showLog(
" No devices connected -> EXIT\n");
230 #endif // MRPT_HAS_OPENNI2 235 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
238 openni::OpenNI::shutdown();
241 #endif // MRPT_HAS_OPENNI2 247 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
252 return vDevices[sensor_id]->isOpen();
256 #endif // MRPT_HAS_OPENNI2 262 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
271 "Sensor index is higher than the number of connected devices.");
279 mrpt::format(
" The sensor [%d] is already opened\n", sensor_id));
284 "[COpenNI2Generic] DBG: [%s] about to call vDevices[%d]->open()\n",
285 __FUNCTION__, sensor_id);
291 showLog(
" open successfully.\n");
297 std::this_thread::sleep_for(1000ms);
301 #endif // MRPT_HAS_OPENNI2 305 const std::set<unsigned>& serial_required)
308 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
310 unsigned num_open_dev = 0;
311 for (
unsigned sensor_id = 0; sensor_id <
vDevices.size(); sensor_id++)
313 unsigned int serialNum;
314 if (
vDevices[sensor_id]->getSerialNumber(serialNum) ==
false)
321 "[COpenNI2Generic::openDevicesBySerialNum] checking device " 322 "with serial '%d'\n",
325 if (serial_required.find(serialNum) == serial_required.end())
339 "[COpenNI2Generic] DBG: [%s] about to call " 340 "vDevices[%d]->open(%d,%d,%d)\n",
341 __FUNCTION__, sensor_id, width, height, (
int)
m_fps);
350 "[COpenNI2Generic] DBG: [%s] now has %d devices open\n",
351 __FUNCTION__, num_open_dev);
357 #endif // MRPT_HAS_OPENNI2 361 const unsigned int SerialRequired)
363 std::set<unsigned> serial_required;
364 serial_required.insert(SerialRequired);
369 const unsigned int SerialRequired,
int& sensor_id)
const 372 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
373 for (
size_t i = 0, i_end =
vDevices.size(); i < i_end; ++i)
376 if (
vDevices[i]->getSerialNumber(sn) ==
false)
380 if (sn == SerialRequired)
391 #endif // MRPT_HAS_OPENNI2 397 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
406 "Sensor index is higher than the number of connected devices.");
412 #endif // MRPT_HAS_OPENNI2 426 bool& there_is_obs,
bool& hardware_error,
unsigned sensor_id)
437 "Sensor index is higher than the number of connected devices.");
440 rgb_img, timestamp, there_is_obs, hardware_error) ==
false)
453 #endif // MRPT_HAS_OPENNI2 458 bool& there_is_obs,
bool& hardware_error,
unsigned sensor_id)
469 "Sensor index is higher than the number of connected devices.");
472 depth_img_mm, timestamp, there_is_obs, hardware_error) ==
false)
485 #endif // MRPT_HAS_OPENNI2 498 bool& hardware_error,
unsigned sensor_id)
509 "Sensor index is higher than the number of connected devices.");
512 out_obs, there_is_obs, hardware_error) ==
false)
524 #endif // MRPT_HAS_OPENNI2 531 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
532 if (
isOpen(sensor_id) ==
false)
541 #endif // MRPT_HAS_OPENNI2 548 std::lock_guard<std::recursive_mutex> lock(
vDevices_mx);
549 if (
isOpen(sensor_id) ==
false)
558 #endif // MRPT_HAS_OPENNI2 571 bool setONI2StreamMode(
572 openni::VideoStream& stream,
int w,
int h,
int fps,
573 openni::PixelFormat
format)
578 const openni::Array<openni::VideoMode>& modes =
579 stream.getSensorInfo().getSupportedVideoModes();
580 for (
int i = 0, i_end = modes.getSize(); i < i_end; ++i)
586 if (modes[i].getResolutionX() != w)
590 if (modes[i].getResolutionY() != h)
594 if (modes[i].getFps() != fps)
598 if (modes[i].getPixelFormat() !=
format)
602 openni::Status rc = stream.setVideoMode(modes[i]);
603 if (rc != openni::STATUS_OK)
612 std::string oni2DevInfoStr(
const openni::DeviceInfo& info,
int tab)
614 std::stringstream sst;
616 for (
int i = 0; i < tab; ++i)
620 sst << space <<
"name=" << info.getName() << std::endl;
621 sst << space <<
"uri=" << info.getUri() << std::endl;
622 sst << space <<
"vendor=" << info.getVendor() << std::endl;
623 sst << space <<
"product=" << info.getUsbProductId();
627 bool cmpONI2Device(
const openni::DeviceInfo& i1,
const openni::DeviceInfo& i2)
629 return (strcmp(i1.getUri(), i2.getUri()) == 0);
632 COpenNI2Generic::CDevice::CDevice(
633 const openni::DeviceInfo& info, openni::PixelFormat rgb,
634 openni::PixelFormat depth,
bool verbose)
635 : m_info(info), m_mirror(true), m_verbose(
verbose)
637 m_streams[COLOR_STREAM] =
638 CStream::create(m_device, openni::SENSOR_COLOR, rgb, m_log,
m_verbose);
639 m_streams[IR_STREAM] =
640 CStream::create(m_device, openni::SENSOR_IR, rgb, m_log,
m_verbose);
641 m_streams[DEPTH_STREAM] = CStream::create(
642 m_device, openni::SENSOR_DEPTH, depth, m_log,
m_verbose);
645 COpenNI2Generic::CDevice::~CDevice() {
close(); }
646 bool COpenNI2Generic::CDevice::synchMirrorMode()
650 for (
auto& m_stream : m_streams)
652 if (!m_stream)
continue;
656 mirror_support = m_stream->isMirrorSupported();
658 catch (std::logic_error& e)
662 if (mirror_support ==
false)
664 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl;
665 m_log <<
" openni::STREAM_PROPERTY_MIRRORING is not supported on " 666 << m_stream->getName() <<
"." << std::endl;
667 m_log <<
" We assume this is MS Kinect and taken images are " 668 "inverted to right and left." 677 for (
auto& m_stream : m_streams)
679 if (!m_stream)
continue;
680 if (m_stream->isMirrorSupported() ==
false)
684 if (m_stream->setMirror(m_mirror) ==
false)
692 bool COpenNI2Generic::CDevice::startStreams()
696 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
698 if (!m_streams[i])
continue;
700 printf(
" [%s] calling m_streams[%d]->start()\n", __FUNCTION__, i);
701 if (m_streams[i]->
start() ==
false)
705 " [%s] m_streams[%d]->start() returned FALSE!\n",
714 " [%s] m_streams[%d]->start() returned TRUE\n", __FUNCTION__,
719 " [COpenNI2Generic::CDevice::startStreams()] %d streams were " 726 bool COpenNI2Generic::CDevice::isOpen()
const 728 return (m_streams[COLOR_STREAM] && m_streams[COLOR_STREAM]->isValid()) ||
729 (m_streams[DEPTH_STREAM] && m_streams[DEPTH_STREAM]->isValid());
732 void COpenNI2Generic::CDevice::close()
734 for (
auto& m_stream : m_streams)
736 if (!m_stream)
continue;
742 bool COpenNI2Generic::CDevice::open(
int w,
int h,
int fps)
747 " [COpenNI2Generic::CDevice::open()] Called with w=%i h=%i " 752 openni::Status rc = m_device.open(getInfo().getUri());
753 if (rc != openni::STATUS_OK)
755 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
756 <<
" Failed to open device " << getInfo().getUri() <<
" " 757 << openni::OpenNI::getExtendedError() << std::endl;
760 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
762 if (!m_streams[i])
continue;
764 printf(
" [%s] calling m_streams[%d]->open()\n", __FUNCTION__, i);
766 if (m_streams[i]->
open(w, h, fps) ==
false)
770 " [%s] m_streams[%d]->open() returned FALSE\n",
776 " [%s] m_streams[%d]->open() returned OK\n", __FUNCTION__, i);
779 if (synchMirrorMode() ==
false)
785 if (m_streams[DEPTH_STREAM])
788 m_streams[DEPTH_STREAM]->setCloseRange(CloseRange);
789 m_log <<
" Close range: " << (CloseRange ?
"On" :
"Off") << std::endl;
793 printf(
" DBG: checking if imageRegistrationMode is supported\n");
794 if (m_device.isImageRegistrationModeSupported(
795 openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR) &&
796 m_streams[DEPTH_STREAM] && m_streams[DEPTH_STREAM]->isValid() &&
797 m_streams[COLOR_STREAM] && m_streams[COLOR_STREAM]->isValid())
802 if (m_device.setImageRegistrationMode(
803 openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR) != openni::STATUS_OK)
805 m_log <<
" setImageRegistrationMode() Failed:" 806 << openni::OpenNI::getExtendedError() << endl;
810 m_log <<
" setImageRegistrationMode() Success" << endl;
815 m_log <<
" Device doesn't do image registration!" << endl;
820 m_streams[COLOR_STREAM]->disableAutoExposure();
821 printf(
"DBG: returned from disableAutoExposure()\n");
824 if (startStreams() ==
false)
833 bool COpenNI2Generic::CDevice::getNextFrameRGB(
835 bool& there_is_obs,
bool& hardware_error)
842 openni::VideoFrameRef frame;
843 if (m_streams[COLOR_STREAM]->getFrame(
844 frame, timestamp, there_is_obs, hardware_error) ==
false)
848 copyFrame<openni::RGB888Pixel, mrpt::img::CImage>(frame, img);
854 bool COpenNI2Generic::CDevice::getNextFrameD(
856 bool& there_is_obs,
bool& hardware_error)
863 openni::VideoFrameRef frame;
864 if (m_streams[DEPTH_STREAM]->getFrame(
865 frame, timestamp, there_is_obs, hardware_error) ==
false)
869 copyFrame<openni::DepthPixel, mrpt::math::CMatrix_u16>(frame, depth_mm);
875 bool COpenNI2Generic::CDevice::getNextFrameRGBD(
877 bool& hardware_error)
881 there_is_obs =
false;
882 hardware_error =
false;
894 openni::VideoFrameRef frame[STREAM_TYPE_SIZE];
895 for (
int i = 0; i < STREAM_TYPE_SIZE; ++i)
897 if (!m_streams[i] || !m_streams[i]->isValid())
continue;
898 if (m_streams[i]->getFrame(
899 frame[i], tm, there_is_obs, hardware_error) ==
false)
903 if (there_is_obs ==
false || hardware_error ==
true)
909 const int width = frame[COLOR_STREAM].getWidth();
910 const int height = frame[COLOR_STREAM].getHeight();
911 if ((frame[DEPTH_STREAM].getWidth() != width) ||
912 (frame[DEPTH_STREAM].
getHeight() != height))
914 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
915 <<
" Both frames don't have the same size." << std::endl;
925 resize(obs, width, height);
927 const char*
data[STREAM_TYPE_SIZE] = {
928 (
const char*)frame[COLOR_STREAM].getData(),
929 (
const char*)frame[DEPTH_STREAM].getData()};
930 const int step[STREAM_TYPE_SIZE] = {frame[COLOR_STREAM].getStrideInBytes(),
931 frame[DEPTH_STREAM].getStrideInBytes()};
933 for (
int yc = 0; yc < height; ++yc)
935 const auto* pRgb = (
const openni::RGB888Pixel*)
data[COLOR_STREAM];
936 const auto* pDepth = (
const openni::DepthPixel*)
data[DEPTH_STREAM];
937 for (
int xc = 0; xc < width; ++xc, ++pDepth, ++pRgb)
947 data[COLOR_STREAM] += step[COLOR_STREAM];
948 data[DEPTH_STREAM] += step[DEPTH_STREAM];
956 const openni::DeviceInfo& info, openni::PixelFormat rgb,
957 openni::PixelFormat depth,
bool verbose)
959 return std::make_shared<CDevice>(info, rgb, depth,
verbose);
962 bool COpenNI2Generic::CDevice::getSerialNumber(std::string& sn)
967 if (isOpened ==
false)
969 rc = m_device.open(getInfo().getUri());
970 if (rc != openni::STATUS_OK)
972 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
973 <<
" Failed to open device " << getInfo().getUri() <<
" " 974 << openni::OpenNI::getExtendedError() << std::endl;
978 char serialNumber[16];
979 rc = m_device.getProperty(ONI_DEVICE_PROPERTY_SERIAL_NUMBER, &serialNumber);
980 if (rc != openni::STATUS_OK)
982 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
983 <<
" Failed to getProperty(ONI_DEVICE_PROPERTY_SERIAL_NUMBER) " 984 << getInfo().getUri() <<
" " << openni::OpenNI::getExtendedError()
988 sn = std::string(serialNumber);
989 if (isOpened ==
false)
996 bool COpenNI2Generic::CDevice::getSerialNumber(
unsigned int& sn)
999 if (getSerialNumber(str) ==
false)
1003 std::stringstream sst;
1011 std::ostream& log,
bool verbose)
1014 m_strName(
"Unknown"),
1019 if (m_type == openni::SENSOR_COLOR)
1021 m_strName =
"openni::SENSOR_COLOR";
1023 else if (m_type == openni::SENSOR_DEPTH)
1025 m_strName =
"openni::SENSOR_DEPTH";
1027 else if (m_type == openni::SENSOR_IR)
1029 m_strName =
"openni::SENSOR_IR";
1033 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1034 <<
" Unknown SensorType -> " << m_type << std::endl;
1038 COpenNI2Generic::CDevice::CStream::~CStream() { destroy(); }
1039 bool COpenNI2Generic::CDevice::CStream::isMirrorSupported()
const 1041 if (isValid() ==
false)
1045 return m_stream.isPropertySupported(openni::STREAM_PROPERTY_MIRRORING);
1048 bool COpenNI2Generic::CDevice::CStream::setMirror(
bool flag)
1050 if (isValid() ==
false)
1052 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1053 <<
" " << getName() <<
" is not opened." << std::endl;
1056 if (m_stream.isPropertySupported(openni::STREAM_PROPERTY_MIRRORING) ==
1061 if (m_stream.setMirroringEnabled(flag) != openni::STATUS_OK)
1063 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1064 <<
" setMirroringEnabled() failed: " 1065 << openni::OpenNI::getExtendedError() << std::endl;
1071 bool COpenNI2Generic::CDevice::CStream::isValid()
const 1073 return m_stream.isValid();
1076 void COpenNI2Generic::CDevice::CStream::destroy() { m_stream.destroy(); }
1077 void COpenNI2Generic::CDevice::CStream::setCloseRange(
int& value)
1081 " [CDevice::CStream::setCloseRange] entry with value=%d\n",
1083 m_stream.setProperty(XN_STREAM_PROPERTY_CLOSE_RANGE, value);
1086 " [CDevice::CStream::setCloseRange] returned from " 1087 "mstream.setProperty()\n");
1088 m_stream.getProperty(XN_STREAM_PROPERTY_CLOSE_RANGE, &value);
1091 " [CDevice::CStream::setCloseRange] returned from " 1092 "mstream.getProperty() ... value %d\n",
1096 bool COpenNI2Generic::CDevice::CStream::open(
int w,
int h,
int fps)
1099 if (m_type != openni::SENSOR_COLOR && m_type != openni::SENSOR_DEPTH &&
1100 m_type != openni::SENSOR_IR)
1102 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1103 <<
" Unknown SensorType -> " << m_type << std::endl;
1108 " [COpenNI2Generic::CDevice::CStream::open] opening sensor " 1109 "stream with m_type == %d\n",
1111 openni::Status rc = openni::STATUS_OK;
1118 rc = m_stream.create(m_device, m_type);
1119 if (rc != openni::STATUS_OK)
1121 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1122 <<
" Couldn't find sensor " << m_strName <<
":" 1123 << openni::OpenNI::getExtendedError() << std::endl;
1124 if (m_type == openni::SENSOR_COLOR)
1126 m_type = openni::SENSOR_IR;
1127 m_strName =
"openni::SENSOR_IR";
1129 printf(
"DBG: changing type to SENSOR_IR (%d)\n", (
int)m_type);
1130 rc = m_stream.create(m_device, m_type);
1135 if (m_verbose) printf(
"returned OK from stream.create()\n");
1136 openni::VideoMode options = m_stream.getVideoMode();
1137 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl;
1138 m_log <<
" " << m_strName << std::endl;
1141 "Initial resolution (%d, %d) FPS %d Format %d",
1142 options.getResolutionX(), options.getResolutionY(),
1143 options.getFps(), options.getPixelFormat())
1145 if (m_verbose) printf(
"DBG: calling setONI2StreamMode()\n");
1146 if (setONI2StreamMode(m_stream, w, h, fps, m_format) ==
false)
1148 m_log <<
" Can't find desired mode in the " << getName() << std::endl;
1152 if (m_verbose) printf(
"DBG: returned OK from setONI2StreamMode()\n");
1153 if (m_verbose) printf(
"DBG: calling stream.getVideoMode()\n");
1154 options = m_stream.getVideoMode();
1157 "-> (%d, %d) FPS %d Format %d", options.getResolutionX(),
1158 options.getResolutionY(), options.getFps(),
1159 options.getPixelFormat())
1163 " [COpenNI2Generic::CDevice::CStream::open] returning TRUE\n");
1167 bool COpenNI2Generic::CDevice::CStream::start()
1169 if (isValid() ==
false)
1171 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1172 <<
" " << getName() <<
" is not opened." << std::endl;
1175 if (m_stream.start() != openni::STATUS_OK)
1177 m_log <<
"[" << __FUNCTION__ <<
"]" << std::endl
1178 <<
" Couldn't start " << getName()
1179 <<
" stream:" << openni::OpenNI::getExtendedError() << std::endl;
1186 COpenNI2Generic::CDevice::CStream::Ptr
1187 COpenNI2Generic::CDevice::CStream::create(
1189 openni::PixelFormat
format, std::ostream& log,
bool verbose)
1191 return std::make_shared<CStream>(device, type,
format, log,
verbose);
1194 bool COpenNI2Generic::CDevice::CStream::getFrame(
1196 bool& there_is_obs,
bool& hardware_error)
1198 there_is_obs =
false;
1199 hardware_error =
false;
1200 if (isValid() ==
false)
1204 openni::Status rc = m_stream.readFrame(&frame);
1205 if (rc != openni::STATUS_OK)
1207 hardware_error =
true;
1208 std::string message =
1209 mrpt::format(
"Failed to grab frame from %s", getName().c_str());
1212 there_is_obs =
true;
1217 #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
app initialize(argc, argv)
#define THROW_EXCEPTION(msg)
std::string std::string format(std::string_view fmt, ARGS &&... args)
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().
A range or depth 3D scan measurement, as from a time-of-flight range camera or a structured-light dep...
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)
mrpt::io::CStream CStream
int m_width
The same options (width, height and fps) are set for all the sensors.
void kill()
Kill the OpenNI2 driver.
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)...
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().
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.
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...
Parameters for the Brown-Conrady camera lens distortion model.
std::atomic< int > numInstances(0)
mrpt::math::CMatrix_u16 rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters)...
bool hasPoints3D
true means the field points3D contains valid data.
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.
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'.
int getConnectedDevices()
Get a list of the connected OpenNI2 sensors.
void showLog(const std::string &message) const
~COpenNI2Generic()
Default ctor.
double getHeight(const TPolygon3D &p, const TPoint3D &c)
bool range_is_depth
true: Kinect-like ranges: entries of rangeImage are distances along the +X axis; false: Ranges in ran...
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.
static struct FontData data