7#ifndef YARP_DEVICE_USBCAMERA_LINUX_V4L_CAMERA_H
8#define YARP_DEVICE_USBCAMERA_LINUX_V4L_CAMERA_H
20#include <opencv2/opencv.hpp>
27#include <libv4lconvert.h>
28#include <linux/videodev2.h>
40#define CLEAR(x) memset(&(x), 0, sizeof(x))
43#define DEFAULT_WIDTH 640
44#define DEFAULT_HEIGHT 480
45#define DEFAULT_FRAMERATE 30
46#define VIDIOC_REQBUFS_COUNT 2
117 struct v4l2_format src_fmt;
118 struct v4l2_format dst_fmt;
119 struct v4l2_requestbuffers req;
143 bool close()
override;
150 int height()
const override;
151 int width()
const override;
159 bool getRgbFOV(
double& horizontalFov,
double& verticalFov)
override;
160 bool setRgbFOV(
double horizontalFov,
double verticalFov)
override;
169 bool setFeature(
int feature,
double value)
override;
170 bool getFeature(
int feature,
double* value)
override;
171 bool setFeature(
int feature,
double value1,
double value2)
override;
172 bool getFeature(
int feature,
double* value1,
double* value2)
override;
173 bool hasOnOff(
int feature,
bool* _hasOnOff)
override;
174 bool setActive(
int feature,
bool onoff)
override;
175 bool getActive(
int feature,
bool* _isActive)
override;
176 bool hasAuto(
int feature,
bool* _hasAuto)
override;
177 bool hasManual(
int feature,
bool* _hasManual)
override;
178 bool hasOnePush(
int feature,
bool* _hasOnePush)
override;
185 v4lconvert_data* _v4lconvert_data;
186 bool use_exposure_absolute;
191 bool configFx, configFy;
192 bool configPPx, configPPy;
193 bool configRet, configDistM;
198 double timeStart, timeTot, timeNow, timeElapsed;
202 std::map<std::string, supported_cams> camMap;
206 void populateConfigurations();
208 int convertV4L_to_YARP_format(
int format);
221 bool threadInit()
override;
223 void threadRelease()
override;
231 bool readInit(
unsigned int buffer_size);
237 bool userptrInit(
unsigned int buffer_size);
246 bool full_FrameRead();
253 void imagePreProcess();
274 int xioctl(
int fd,
int request,
void* argp);
276 int convertYARP_to_V4L(
int feature);
277 void enumerate_menu();
278 bool enumerate_controls();
279 bool check_V4L2_control(uint32_t
id);
280 bool set_V4L2_control(u_int32_t
id,
double value,
bool verbatim =
false);
281 double get_V4L2_control(uint32_t
id,
bool verbatim =
false);
283 double toEpochOffset;
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
int getRgbWidth() override
Return the width of each frame.
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
bool hasOnePush(int feature, bool *_hasOnePush) override
Check if the requested feature has the 'onePush' mode.
bool close() override
close device
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ... )
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
bool hasOnOff(int feature, bool *_hasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
int getRgbHeight() override
Return the height of each frame.
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
bool hasAuto(int feature, bool *_hasAuto) override
Check if the requested feature has the 'auto' mode.
int width() const override
Return the width of each frame.
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ... )
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ... )
bool getActive(int feature, bool *_isActive) override
Get the current status of the feature, on or off.
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
int height() const override
Return the height of each frame.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an image from the frame grabber.
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
bool open(yarp::os::Searchable &config) override
open device
bool hasManual(int feature, bool *_hasManual) override
Check if the requested feature has the 'manual' mode.
Interface implemented by all device drivers.
Control interface for frame grabber devices.
An interface for retrieving intrinsic parameter from a rgb camera.
An abstraction for a periodic thread.
A class for storing options and configuration information.
A base class for nested structures that can be searched.
A class for thread synchronization and mutual exclusion.
An abstraction for a time stamp and/or sequence number.
unsigned char * read_image
yarp::sig::VectorOf< yarp::dev::CameraConfig > configurations
unsigned char * raw_image
unsigned char * dst_image_rgb
yarp::os::Property intrinsic
unsigned char * src_image
unsigned int dst_image_size_rgb
unsigned int src_image_size
unsigned int raw_image_size