21 typedef std::shared_ptr<CDevice>
Ptr;
35 typedef std::shared_ptr<CStream>
Ptr;
39 openni::Device& m_device;
42 openni::VideoStream m_stream;
43 openni::PixelFormat m_format;
49 openni::PixelFormat
format, std::ostream& log,
bool verbose);
51 const std::string& getName()
const {
return m_strName; }
53 bool isMirrorSupported()
const;
54 bool setMirror(
bool flag);
55 void setCloseRange(
int&
value);
56 virtual bool open(
int w,
int h,
int fps);
58 virtual void destroy();
59 virtual bool getFrame(
60 openni::VideoFrameRef& frame,
uint64_t& timestamp,
61 bool& there_is_obs,
bool& hardware_error);
63 int getFrameWidth()
const 65 return m_stream.getVideoMode().getResolutionX();
67 int getFrameHeight()
const 69 return m_stream.getVideoMode().getResolutionY();
71 double getHFov()
const {
return m_stream.getHorizontalFieldOfView(); }
74 return getFrameWidth() / (2.0 * tan(getHFov() / 2.0));
76 double getVFov()
const {
return m_stream.getVerticalFieldOfView(); }
79 return getFrameHeight() / (2.0 * tan(getVFov() / 2.0));
81 double getCx()
const {
return (getFrameWidth() - 1) * 0.5; }
82 double getCy()
const {
return (getFrameHeight() - 1) * 0.5; }
83 void disableAutoExposure()
85 m_stream.getCameraSettings()->setAutoExposureEnabled(
false);
87 void enableAutoExposure()
89 m_stream.getCameraSettings()->setAutoExposureEnabled(
true);
94 param.ncols = getFrameWidth();
95 param.nrows = getFrameHeight();
104 openni::PixelFormat
format, std::ostream& log,
bool verbose);
106 openni::DeviceInfo m_info;
107 openni::Device m_device;
110 std::stringstream m_log;
113 bool synchMirrorMode();
130 inline void setPixel(
135 inline void setPixel(
138 static const double rate = 1.0 / 1000;
142 template <
class NI_PIXEL,
class MRPT_DATA>
143 void copyRow(
const char*
src, MRPT_DATA& rgb,
int w,
const int y)
145 const NI_PIXEL*
s = (
const NI_PIXEL*)
src;
146 for (
int xc = 0; xc <
w; ++xc, ++
s)
153 setPixel(*
s, rgb,
x,
y);
157 template <
class NI_PIXEL,
class MRPT_DATA>
158 void copyFrame(openni::VideoFrameRef& frame, MRPT_DATA&
dst)
160 const char*
data = (
const char*)frame.getData();
161 const int stride = frame.getStrideInBytes();
162 const int width = frame.getWidth();
163 const int height = frame.getHeight();
173 const openni::DeviceInfo& info, openni::PixelFormat rgb,
177 const openni::DeviceInfo& getInfo()
const {
return m_info; }
184 bool isMirrorMode()
const {
return m_mirror; }
185 void setMirrorMode(
bool mode) { m_mirror =
mode; }
186 bool hasColor()
const 193 bool hasDepth()
const 203 bool open(
int w,
int h,
int fps);
207 bool& hardware_error);
210 bool& hardware_error);
213 bool& hardware_error);
221 if (!m_streams[streamType] || m_streams[streamType]->isValid() ==
false)
225 m_streams[streamType]->getCameraParam(
param);
229 bool getSerialNumber(
unsigned int& sn);
232 const openni::DeviceInfo& info, openni::PixelFormat rgb,
233 openni::PixelFormat
depth,
bool verbose);
235 openni::Device& getDevicePtr() {
return m_device; }
239 #endif // MRPT_HAS_OPENNI2 void getNextFrameRGB(mrpt::utils::CImage &rgb_img, uint64_t ×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 class for storing images as grayscale or RGB bitmaps.
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...
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().
GLint GLint GLsizei GLsizei GLsizei depth
std::shared_ptr< CDevice > Ptr
GLubyte GLubyte GLubyte GLubyte w
bool start()
Open all sensor streams (normally called automatically at constructor, no need to call it manually)...
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...
GLsizei const GLchar ** string
void getNextFrameD(mrpt::math::CMatrix &depth_img, uint64_t ×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).
unsigned __int64 uint64_t
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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
mrpt::utils::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"...
This class is a "CSerializable" wrapper for "CMatrixFloat".
GLenum GLsizei GLsizei height
GLsizei GLsizei GLenum GLenum const GLvoid * data
GLuint GLuint GLsizei GLenum type
Structure to hold the parameters of a pinhole camera model.