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(
137 static const double rate = 1.0 / 1000;
141 template <
class NI_PIXEL,
class MRPT_DATA>
142 void copyRow(
const char*
src, MRPT_DATA& rgb,
int w,
const int y)
144 const auto*
s = (
const NI_PIXEL*)
src;
145 for (
int xc = 0; xc <
w; ++xc, ++
s)
152 setPixel(*
s, rgb,
x,
y);
156 template <
class NI_PIXEL,
class MRPT_DATA>
157 void copyFrame(openni::VideoFrameRef& frame, MRPT_DATA&
dst)
159 const char*
data = (
const char*)frame.getData();
160 const int stride = frame.getStrideInBytes();
161 const int width = frame.getWidth();
162 const int height = frame.getHeight();
172 const openni::DeviceInfo& info, openni::PixelFormat rgb,
176 const openni::DeviceInfo& getInfo()
const {
return m_info; }
183 bool isMirrorMode()
const {
return m_mirror; }
184 void setMirrorMode(
bool mode) { m_mirror =
mode; }
185 bool hasColor()
const 192 bool hasDepth()
const 202 bool open(
int w,
int h,
int fps);
206 bool& there_is_obs,
bool& hardware_error);
209 bool& there_is_obs,
bool& hardware_error);
212 bool& hardware_error);
220 if (!m_streams[streamType] || m_streams[streamType]->isValid() ==
false)
224 m_streams[streamType]->getCameraParam(
param);
228 bool getSerialNumber(
unsigned int& sn);
231 const openni::DeviceInfo& info, openni::PixelFormat rgb,
232 openni::PixelFormat
depth,
bool verbose);
234 openni::Device& getDevicePtr() {
return m_device; }
239 #endif // MRPT_HAS_OPENNI2
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.
GLint GLint GLsizei GLsizei GLsizei depth
mrpt::io::CStream CStream
GLubyte GLubyte GLubyte GLubyte w
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually)...
void resize(std::size_t width, std::size_t height, TImageChannels nChannels, PixelDepth depth=PixelDepth::D8U)
Changes the size of the image, erasing previous contents (does NOT scale its current content...
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"...
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.
GLsizei const GLchar ** string
void getNextFrameD(mrpt::math::CMatrixF &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 setPixel(int x, int y, size_t color) override
Changes the value of the pixel (x,y).
This class is a "CSerializable" wrapper for "CMatrixFloat".
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 ...
void open(unsigned sensor_id=0)
Try to open the camera (all the parameters [resolution,fps,...] must be set before calling this) - us...
GLenum GLsizei GLenum format
GLsizei const GLfloat * value
GLenum GLsizei GLsizei height
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLuint GLsizei GLenum type
std::shared_ptr< CDevice > Ptr
A class for storing images as grayscale or RGB bitmaps.