YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
depthCameraDriver.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef DEPTHCAMERA_DRIVER_H
7#define DEPTHCAMERA_DRIVER_H
8
9#include <string>
10#include <map>
11
15#include <yarp/sig/all.h>
16#include <yarp/sig/Matrix.h>
17#include <yarp/os/Stamp.h>
20#include <OpenNI.h>
21
22
23#ifndef RAD2DEG
24#define RAD2DEG (180/3.14159265359)
25#endif
26
27#ifndef DEG2RAD
28#define DEG2RAD (3.14159265359/180.0)
29#endif
30
32
184{
185private:
187 typedef yarp::os::Stamp Stamp;
190
191public:
194 static int pixFormatToCode(openni::PixelFormat p);
195
196 // DeviceDriver
197 bool open(yarp::os::Searchable& config) override;
198 bool close() override;
199
200 // IRGBDSensor
201 int getRgbHeight() override;
202 int getRgbWidth() override;
203 yarp::dev::ReturnValue getRgbSupportedConfigurations(std::vector<yarp::dev::CameraConfig>& configurations) override;
204 yarp::dev::ReturnValue getRgbResolution(int& width, int& height) override;
205 yarp::dev::ReturnValue setRgbResolution(int width, int height) override;
206 yarp::dev::ReturnValue getRgbFOV(double& horizontalFov, double& verticalFov) override;
207 yarp::dev::ReturnValue setRgbFOV(double horizontalFov, double verticalFov) override;
208 yarp::dev::ReturnValue getRgbMirroring(bool& mirror) override;
209 yarp::dev::ReturnValue setRgbMirroring(bool mirror) override;
210
211 int getDepthHeight() override;
212 int getDepthWidth() override;
214 yarp::dev::ReturnValue setDepthResolution(int width, int height) override;
215 yarp::dev::ReturnValue getDepthFOV(double& horizontalFov, double& verticalFov) override;
216 yarp::dev::ReturnValue setDepthFOV(double horizontalFov, double verticalFov) override;
220 yarp::dev::ReturnValue getDepthClipPlanes(double& nearPlane, double& farPlane) override;
221 yarp::dev::ReturnValue setDepthClipPlanes(double nearPlane, double farPlane) override;
222 yarp::dev::ReturnValue getDepthMirroring(bool& mirror) override;
223 yarp::dev::ReturnValue setDepthMirroring(bool mirror) override;
224
226 yarp::dev::ReturnValue getRgbImage(FlexImage& rgbImage, Stamp* timeStamp = NULL) override;
227 yarp::dev::ReturnValue getDepthImage(depthImage& depthImage, Stamp* timeStamp = NULL) override;
228 yarp::dev::ReturnValue getImages(FlexImage& colorFrame, depthImage& depthFrame, Stamp* colorStamp=NULL, Stamp* depthStamp=NULL) override;
229
231 std::string getLastErrorMsg(Stamp* timeStamp = NULL) override;
232
233 //IFrameGrabberControls
234 yarp::dev::ReturnValue getCameraDescription(CameraDescriptor *camera) override;
236 yarp::dev::ReturnValue setFeature(int feature, double value) override;
237 yarp::dev::ReturnValue getFeature(int feature, double* value) override;
238 yarp::dev::ReturnValue setFeature(int feature, double value1, double value2) override;
239 yarp::dev::ReturnValue getFeature(int feature, double* value1, double* value2) override;
240 yarp::dev::ReturnValue hasOnOff( int feature, bool* HasOnOff) override;
241 yarp::dev::ReturnValue setActive( int feature, bool onoff) override;
242 yarp::dev::ReturnValue getActive( int feature, bool* isActive) override;
243 yarp::dev::ReturnValue hasAuto( int feature, bool* hasAuto) override;
246 yarp::dev::ReturnValue setMode( int feature, FeatureMode mode) override;
247 yarp::dev::ReturnValue getMode( int feature, FeatureMode *mode) override;
249
250private:
251 //method
252 inline bool initializeOpeNIDevice();
253 inline bool setParams();
254 bool getImage(FlexImage& Frame, Stamp* Stamp, streamFrameListener *sourceFrame);
255 bool getImage(depthImage& Frame, Stamp* Stamp, streamFrameListener *sourceFrame);
256 bool setResolution(int w, int h, openni::VideoStream& stream);
257 bool setFOV(double horizontalFov, double verticalFov, openni::VideoStream& stream);
258 bool setIntrinsic(yarp::os::Property& intrinsic, const yarp::sig::IntrinsicParams& values);
259 void settingErrorMsg(const std::string& error, bool& ret);
260
261 //properties
262 openni::VideoStream m_depthStream;
263 openni::VideoStream m_imageStream;
264 openni::Device m_device;
265 streamFrameListener* m_depthFrame;
266 streamFrameListener* m_imageFrame;
267 std::string m_lastError;
269 bool m_depthRegistration;
270 std::vector<cameraFeature_id_t> m_supportedFeatures;
271};
272#endif
CameraDescriptor camera
FeatureMode mode
bool ret
contains the definition of a Matrix type
depthCamera: YARP driver for OpenNI2 compatible devices.
yarp::dev::ReturnValue getRgbImage(FlexImage &rgbImage, Stamp *timeStamp=NULL) override
Get the rgb frame from the device.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::ReturnValue setMode(int feature, FeatureMode mode) override
yarp::dev::ReturnValue setActive(int feature, bool onoff) override
yarp::dev::ReturnValue setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
yarp::dev::ReturnValue getDepthImage(depthImage &depthImage, Stamp *timeStamp=NULL) override
yarp::dev::ReturnValue setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
int getDepthHeight() override
Return the height of each frame.
yarp::dev::ReturnValue setDepthClipPlanes(double nearPlane, double farPlane) override
Set the clipping planes of the sensor.
int getRgbHeight() override
Return the height of each frame.
RGBDSensor_status getSensorStatus() override
yarp::dev::ReturnValue getCameraDescription(CameraDescriptor *camera) override
yarp::dev::ReturnValue getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getDepthAccuracy(double &accuracy) override
Get the minimum detectable variation in distance [meter].
yarp::dev::ReturnValue getActive(int feature, bool *isActive) override
yarp::dev::ReturnValue getDepthFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the depth camera.
yarp::dev::ReturnValue getRgbIntrinsicParam(Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
yarp::dev::ReturnValue setDepthResolution(int width, int height) override
Set the resolution of the depth image from the camera.
yarp::dev::ReturnValue getExtrinsicParam(yarp::sig::Matrix &extrinsic) override
Get the extrinsic parameters from the device.
yarp::dev::ReturnValue getMode(int feature, FeatureMode *mode) override
std::string getLastErrorMsg(Stamp *timeStamp=NULL) override
yarp::dev::ReturnValue getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
yarp::dev::ReturnValue getFeature(int feature, double *value) override
int getRgbWidth() override
Return the width of each frame.
int getDepthWidth() override
Return the height of each frame.
yarp::dev::ReturnValue getDepthClipPlanes(double &nearPlane, double &farPlane) override
Get the clipping planes of the sensor.
yarp::dev::ReturnValue setDepthFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the depth camera.
yarp::dev::ReturnValue getRgbSupportedConfigurations(std::vector< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
yarp::dev::ReturnValue getImages(FlexImage &colorFrame, depthImage &depthFrame, Stamp *colorStamp=NULL, Stamp *depthStamp=NULL) override
yarp::dev::ReturnValue getDepthIntrinsicParam(Property &intrinsic) override
Get the intrinsic parameters of the depth camera.
static int pixFormatToCode(openni::PixelFormat p)
yarp::dev::ReturnValue setFeature(int feature, double value) override
yarp::dev::ReturnValue setDepthAccuracy(double accuracy) override
Set the minimum detectable variation in distance [meter] when possible.
yarp::dev::ReturnValue setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
yarp::dev::ReturnValue getDepthMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
yarp::dev::ReturnValue setOnePush(int feature) override
yarp::dev::ReturnValue setDepthMirroring(bool mirror) override
Set the mirroring setting of the sensor.
yarp::dev::ReturnValue getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
Interface implemented by all device drivers.
Control interface for frame grabber devices.
A generic interface for cameras that have both color camera as well as depth camera sensor,...
Definition IRGBDSensor.h:39
The RGBDSensorParamParser class.
A class for storing options and configuration information.
Definition Property.h:33
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
Image class with user control of representation details.
Definition Image.h:361
Typed image class.
Definition Image.h:603
A class for a Matrix.
Definition Matrix.h:39
constexpr char accuracy[]
The IntrinsicParams struct to handle the intrinsic parameter of cameras(RGB and RGBD either).