19 using Ptr = std::shared_ptr<CDevice>;
33 using Ptr = std::shared_ptr<CStream>;
37 openni::Device& m_device;
40 openni::VideoStream m_stream;
41 openni::PixelFormat m_format;
47 openni::PixelFormat
format, std::ostream& log,
bool verbose);
49 const std::string& getName()
const {
return m_strName; }
51 bool isMirrorSupported()
const;
52 bool setMirror(
bool flag);
53 void setCloseRange(
int&
value);
54 virtual bool open(
int w,
int h,
int fps);
56 virtual void destroy();
57 virtual bool getFrame(
59 bool& there_is_obs,
bool& hardware_error);
61 int getFrameWidth()
const
63 return m_stream.getVideoMode().getResolutionX();
65 int getFrameHeight()
const
67 return m_stream.getVideoMode().getResolutionY();
69 double getHFov()
const {
return m_stream.getHorizontalFieldOfView(); }
72 return getFrameWidth() / (2.0 * tan(getHFov() / 2.0));
74 double getVFov()
const {
return m_stream.getVerticalFieldOfView(); }
77 return getFrameHeight() / (2.0 * tan(getVFov() / 2.0));
79 double getCx()
const {
return (getFrameWidth() - 1) * 0.5; }
80 double getCy()
const {
return (getFrameHeight() - 1) * 0.5; }
81 void disableAutoExposure()
83 m_stream.getCameraSettings()->setAutoExposureEnabled(
false);
85 void enableAutoExposure()
87 m_stream.getCameraSettings()->setAutoExposureEnabled(
true);
92 param.ncols = getFrameWidth();
93 param.nrows = getFrameHeight();
102 openni::PixelFormat
format, std::ostream& log,
bool verbose);
104 openni::DeviceInfo m_info;
105 openni::Device m_device;
108 std::stringstream m_log;
111 bool synchMirrorMode();
128 inline void setPixel(
133 inline void setPixel(
136 static const double rate = 1.0 / 1000;
140 template <
class NI_PIXEL,
class MRPT_DATA>
141 void copyRow(
const char*
src, MRPT_DATA& rgb,
int w,
const int y)
143 const NI_PIXEL*
s = (
const NI_PIXEL*)
src;
144 for (
int xc = 0; xc <
w; ++xc, ++
s)
151 setPixel(*
s, rgb,
x,
y);
155 template <
class NI_PIXEL,
class MRPT_DATA>
156 void copyFrame(openni::VideoFrameRef& frame, MRPT_DATA&
dst)
158 const char*
data = (
const char*)frame.getData();
159 const int stride = frame.getStrideInBytes();
160 const int width = frame.getWidth();
161 const int height = frame.getHeight();
171 const openni::DeviceInfo& info, openni::PixelFormat rgb,
175 const openni::DeviceInfo& getInfo()
const {
return m_info; }
182 bool isMirrorMode()
const {
return m_mirror; }
183 void setMirrorMode(
bool mode) { m_mirror =
mode; }
184 bool hasColor()
const
191 bool hasDepth()
const
201 bool open(
int w,
int h,
int fps);
205 bool& hardware_error);
208 bool& hardware_error);
211 bool& hardware_error);
219 if (!m_streams[streamType] || m_streams[streamType]->isValid() ==
false)
223 m_streams[streamType]->getCameraParam(
param);
227 bool getSerialNumber(
unsigned int& sn);
230 const openni::DeviceInfo& info, openni::PixelFormat rgb,
231 openni::PixelFormat
depth,
bool verbose);
233 openni::Device& getDevicePtr() {
return m_device; }
std::shared_ptr< CDevice > Ptr
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,...
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().
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().
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().
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually).
void open(unsigned sensor_id=0)
Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - us...
A class for storing images as grayscale or RGB bitmaps.
void setPixel(int x, int y, size_t color) override
Changes the value of the pixel (x,y).
void resize(unsigned int width, unsigned int height, TImageChannels nChannels, bool originTopLeft)
Changes the size of the image, erasing previous contents (does NOT scale its current content,...
Structure to hold the parameters of a pinhole camera model.
This class is a "CSerializable" wrapper for "CMatrixFloat".
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage".
void rangeImage_setSize(const int HEIGHT, const int WIDTH)
Similar to calling "rangeImage.setSize(H,W)" but this method provides memory pooling to speed-up the ...
GLint GLint GLsizei GLsizei GLsizei depth
GLubyte GLubyte GLubyte GLubyte w
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLuint GLsizei GLenum type
GLenum GLsizei GLsizei height
GLenum GLsizei GLenum format
GLsizei const GLfloat * value
GLsizei const GLchar ** string
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Contains classes for various device interfaces.
mrpt::io::CStream CStream