20 #ifndef YARP_DEVICE_USBCAMERA_LINUX_V4L_CAMERA_H
21 #define YARP_DEVICE_USBCAMERA_LINUX_V4L_CAMERA_H
31 #include <asm/types.h>
32 #include <opencv2/opencv.hpp>
39 #include <libv4lconvert.h>
40 #include <linux/videodev2.h>
45 #include <sys/ioctl.h>
49 #include <sys/types.h>
52 #define CLEAR(x) memset(&(x), 0, sizeof(x))
55 #define DEFAULT_WIDTH 640
56 #define DEFAULT_HEIGHT 480
57 #define DEFAULT_FRAMERATE 30
58 #define VIDIOC_REQBUFS_COUNT 2
129 struct v4l2_format src_fmt;
130 struct v4l2_format dst_fmt;
131 struct v4l2_requestbuffers req;
155 bool close()
override;
170 int height()
const override;
176 int width()
const override;
184 bool getRgbFOV(
double& horizontalFov,
double& verticalFov)
override;
185 bool setRgbFOV(
double horizontalFov,
double verticalFov)
override;
194 bool setFeature(
int feature,
double value)
override;
195 bool getFeature(
int feature,
double* value)
override;
196 bool setFeature(
int feature,
double value1,
double value2)
override;
197 bool getFeature(
int feature,
double* value1,
double* value2)
override;
198 bool hasOnOff(
int feature,
bool* _hasOnOff)
override;
199 bool setActive(
int feature,
bool onoff)
override;
200 bool getActive(
int feature,
bool* _isActive)
override;
201 bool hasAuto(
int feature,
bool* _hasAuto)
override;
202 bool hasManual(
int feature,
bool* _hasManual)
override;
203 bool hasOnePush(
int feature,
bool* _hasOnePush)
override;
210 v4lconvert_data* _v4lconvert_data;
211 bool use_exposure_absolute;
216 bool configFx, configFy;
217 bool configPPx, configPPy;
218 bool configRet, configDistM;
223 double timeStart, timeTot, timeNow, timeElapsed;
227 std::map<std::string, supported_cams> camMap;
231 void populateConfigurations();
233 int convertV4L_to_YARP_format(
int format);
246 bool threadInit()
override;
248 void threadRelease()
override;
256 bool readInit(
unsigned int buffer_size);
262 bool userptrInit(
unsigned int buffer_size);
271 bool full_FrameRead();
278 void imagePreProcess();
299 int xioctl(
int fd,
int request,
void* argp);
301 int convertYARP_to_V4L(
int feature);
302 void enumerate_menu();
303 bool enumerate_controls();
304 bool check_V4L2_control(uint32_t
id);
305 bool set_V4L2_control(u_int32_t
id,
double value,
bool verbatim =
false);
306 double get_V4L2_control(uint32_t
id,
bool verbatim =
false);
308 double toEpochOffset;
define common interfaces to discover remote camera capabilities
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.
bool getRgbBuffer(unsigned char *buffer) override
Get a rgb buffer from the frame grabber, if required demosaicking/color reconstruction is applied.
int height() const override
Return the height of each frame.
int getRawBufferSize() override
Get the size of the card's internal buffer, the user should use this method to allocate the storage t...
bool getRawBuffer(unsigned char *buffer) override
Get the raw buffer 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.
RGB Interface to a FrameGrabber device.
Common interface to a FrameGrabber.
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