19 typedef stlplus::smart_ptr<CDevice>
Ptr;
28 typedef stlplus::smart_ptr<CStream>
Ptr;
32 openni::Device& m_device;
35 openni::VideoStream m_stream;
36 openni::PixelFormat m_format;
41 const std::string& getName()
const{
return m_strName; }
43 bool isMirrorSupported()
const;
44 bool setMirror(
bool flag);
45 void setCloseRange(
int&
value);
46 virtual bool open(
int w,
int h,
int fps);
48 virtual void destroy();
49 virtual bool getFrame(openni::VideoFrameRef& frame,
uint64_t ×tamp,
bool &there_is_obs,
bool &hardware_error);
51 int getFrameWidth()
const{
return m_stream.getVideoMode().getResolutionX(); }
52 int getFrameHeight()
const{
return m_stream.getVideoMode().getResolutionY(); }
53 double getHFov()
const{
return m_stream.getHorizontalFieldOfView(); }
54 double getFx()
const{
return getFrameWidth() / (2.0 * tan(getHFov() / 2.0)); }
55 double getVFov()
const{
return m_stream.getVerticalFieldOfView(); }
56 double getFy()
const{
return getFrameHeight() / (2.0 * tan(getVFov() / 2.0)); }
57 double getCx()
const{
return (getFrameWidth() - 1) * 0.5; }
58 double getCy()
const{
return (getFrameHeight() - 1) * 0.5; }
60 void disableAutoExposure() {m_stream.getCameraSettings()->setAutoExposureEnabled(
false); }
61 void enableAutoExposure() {m_stream.getCameraSettings()->setAutoExposureEnabled(
true); }
64 param.ncols = getFrameWidth();
65 param.nrows = getFrameHeight();
74 openni::DeviceInfo m_info;
75 openni::Device m_device;
78 std::stringstream m_log;
81 bool synchMirrorMode();
93 static const double rate = 1.0 / 1000;
97 template <
class NI_PIXEL,
class MRPT_DATA>
98 void copyRow(
const char*
src, MRPT_DATA& rgb,
int w,
const int y){
99 const NI_PIXEL*
s = (
const NI_PIXEL*)
src;
100 for (
int xc = 0; xc <
w; ++xc, ++
s){
105 setPixel(*
s, rgb,
x,
y);
109 template <
class NI_PIXEL,
class MRPT_DATA>
110 void copyFrame(openni::VideoFrameRef& frame, MRPT_DATA&
dst){
111 const char*
data = (
const char*)frame.getData();
112 const int stride = frame.getStrideInBytes();
113 const int width = frame.getWidth();
114 const int height = frame.getHeight();
125 const openni::DeviceInfo& getInfo()
const{
return m_info; }
128 void clearLog(){ m_log.str(
""); m_log.clear(); }
129 bool isMirrorMode()
const{
return m_mirror; }
130 void setMirrorMode(
bool mode){ m_mirror =
mode; }
136 bool open(
int w,
int h,
int fps);
146 if(!m_streams[streamType] || m_streams[streamType]->isValid() ==
false){
return false; }
147 m_streams[streamType]->getCameraParam(
param);
151 bool getSerialNumber(
unsigned int& sn);
153 static Ptr create(
const openni::DeviceInfo&
info, openni::PixelFormat rgb, openni::PixelFormat
depth,
bool verbose);
155 openni::Device & getDevicePtr(){
return m_device; }
160 #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().
stlplus::smart_ptr< CDevice > Ptr
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
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().
unsigned __int64 uint64_t
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
class HWDRIVERS_IMPEXP CDevice
The list of available devices.
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
void setPixel(int x, int y, size_t color) MRPT_OVERRIDE
Changes the value of the pixel (x,y).
Structure to hold the parameters of a pinhole camera model.