YARP
Yet Another Robot Platform
USBcamera.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 
20 #ifndef YARP_DEVICE_USBCAMERA_COMMON_USBCAMERA_H
21 #define YARP_DEVICE_USBCAMERA_COMMON_USBCAMERA_H
22 
23 
24 #include <yarp/os/Bottle.h>
25 #include <yarp/os/Semaphore.h>
26 #include <yarp/os/Stamp.h>
27 
28 #include <yarp/dev/DeviceDriver.h>
30 #include <yarp/dev/IVisualParams.h>
32 
48 {
49  USBCameraDriver(const USBCameraDriver&) = delete;
50  void operator=(const USBCameraDriver&) = delete;
51 
52 protected:
59 
60  size_t _width;
61  size_t _height;
62  int pixelType;
63 
64 public:
69 
73  ~USBCameraDriver() override;
74 
80  bool open(yarp::os::Searchable& config) override;
81 
86  bool close() override;
87 
91  int height() const override;
92 
96  int width() const override;
97 
103  bool getRawBuffer(unsigned char* buffer) override;
104 
110  int getRawBufferSize() override;
111 
119  bool getRgbBuffer(unsigned char* buffer) override;
120 
126 
132  bool getCameraDescription(CameraDescriptor* camera) override;
133  bool hasFeature(int feature, bool* hasFeature) override;
134  bool setFeature(int feature, double value) override;
135  bool getFeature(int feature, double* value) override;
136  bool setFeature(int feature, double value1, double value2) override;
137  bool getFeature(int feature, double* value1, double* value2) override;
138  bool hasOnOff(int feature, bool* HasOnOff) override;
139  bool setActive(int feature, bool onoff) override;
140  bool getActive(int feature, bool* isActive) override;
141  bool hasAuto(int feature, bool* hasAuto) override;
142  bool hasManual(int feature, bool* hasManual) override;
143  bool hasOnePush(int feature, bool* hasOnePush) override;
144  bool setMode(int feature, FeatureMode mode) override;
145  bool getMode(int feature, FeatureMode* mode) override;
146  bool setOnePush(int feature) override;
151  int getRgbHeight() override;
152 
157  int getRgbWidth() override;
158 
173  bool getRgbResolution(int& width, int& height) override;
174 
182  bool setRgbResolution(int width, int height) override;
183 
191  bool getRgbFOV(double& horizontalFov, double& verticalFov) override;
192 
200  bool setRgbFOV(double horizontalFov, double verticalFov) override;
201 
210  bool getRgbIntrinsicParam(yarp::os::Property& intrinsic) override;
211 
218  bool getRgbMirroring(bool& mirror) override;
219 
226  bool setRgbMirroring(bool mirror) override;
227 };
228 
229 
231  public USBCameraDriver,
234 {
235 private:
236  USBCameraDriverRgb(const USBCameraDriverRgb&) = delete;
237  void operator=(const USBCameraDriverRgb&) = delete;
238 
239 public:
241  ~USBCameraDriverRgb() override;
242 
251 
259 
264  int height() const override;
265 
270  int width() const override;
271 };
272 
279  public USBCameraDriver,
281 {
282 private:
283  USBCameraDriverRaw(const USBCameraDriverRaw&) = delete;
284  void operator=(const USBCameraDriverRaw&) = delete;
285 
286 public:
288  ~USBCameraDriverRaw() override;
289 
298 
303  int height() const override;
304 
309  int width() const override;
310 };
311 
312 #endif // YARP_DEVICE_USBCAMERA_COMMON_USBCAMERA_H
CameraDescriptor
Definition: FrameGrabberInterfaces.h:35
USBCameraDriver::deviceRgbVisualParam
yarp::dev::IRgbVisualParams * deviceRgbVisualParam
Definition: USBcamera.h:58
USBCameraDriver::setRgbResolution
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
Definition: USBcamera.cpp:192
USBCameraDriverRgb::USBCameraDriverRgb
USBCameraDriverRgb()
Definition: USBcamera.cpp:248
yarp::dev::IFrameGrabberImageRaw
Read a YARP-format image from a device.
Definition: FrameGrabberInterfaces.h:293
USBCameraDriverRaw::~USBCameraDriverRaw
~USBCameraDriverRaw() override
Definition: USBcamera.cpp:297
USBCameraDriverRgb::getImage
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
FrameGrabber image interface, returns the last acquired frame as an rgb image.
Definition: USBcamera.cpp:260
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
USBCameraDriver::deviceRaw
yarp::dev::IFrameGrabber * deviceRaw
Definition: USBcamera.h:55
USBCameraDriver::getRawBuffer
bool getRawBuffer(unsigned char *buffer) override
Implements FrameGrabber basic interface.
Definition: USBcamera.cpp:135
USBCameraDriverRgb::~USBCameraDriverRgb
~USBCameraDriverRgb() override
Definition: USBcamera.cpp:255
USBCameraDriver::setRgbFOV
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
Definition: USBcamera.cpp:214
USBCameraDriver
usbCamera: YARP device driver implementation for acquiring images from USB cameras.
Definition: USBcamera.h:48
IPreciselyTimed.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
yarp::dev::IFrameGrabber
Common interface to a FrameGrabber.
Definition: FrameGrabberInterfaces.h:169
USBCameraDriver::hasOnOff
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
Definition: USBcamera.cpp:376
USBCameraDriver::os_device
yarp::dev::DeviceDriver * os_device
Definition: USBcamera.h:56
USBCameraDriver::getRgbResolution
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
Definition: USBcamera.cpp:184
USBCameraDriverRgb
Definition: USBcamera.h:234
USBCameraDriver::pixelType
int pixelType
Definition: USBcamera.h:62
yarp::sig::ImageOf< yarp::sig::PixelRgb >
USBCameraDriver::getRgbFOV
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
Definition: USBcamera.cpp:206
USBCameraDriver::_width
size_t _width
Definition: USBcamera.h:60
yarp::sig::VectorOf< yarp::dev::CameraConfig >
USBCameraDriver::getMode
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
Definition: USBcamera.cpp:432
USBCameraDriver::open
bool open(yarp::os::Searchable &config) override
Open the device driver.
Definition: USBcamera.cpp:54
USBCameraDriverRgb::height
int height() const override
Return the height of each frame.
Definition: USBcamera.cpp:284
USBCameraDriver::getRgbWidth
int getRgbWidth() override
Return the width of each frame.
Definition: USBcamera.cpp:167
USBCameraDriver::getRgbSupportedConfigurations
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
Definition: USBcamera.cpp:176
USBCameraDriver::getLastInputStamp
yarp::os::Stamp getLastInputStamp() override
Implements the IPreciselyTimed interface.
Definition: USBcamera.cpp:150
yarp::dev::IFrameGrabberImage
Read a YARP-format image from a device.
Definition: FrameGrabberInterfaces.h:241
USBCameraDriver::deviceRgb
yarp::dev::IFrameGrabberRgb * deviceRgb
Definition: USBcamera.h:53
USBCameraDriverRaw::getImage
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelMono > &image) override
FrameGrabber image interface, returns the last acquired frame as an rgb image.
Definition: USBcamera.cpp:302
USBCameraDriver::deviceTimed
yarp::dev::IPreciselyTimed * deviceTimed
Definition: USBcamera.h:54
Stamp.h
USBCameraDriver::setFeature
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ...
Definition: USBcamera.cpp:344
USBCameraDriver::getActive
bool getActive(int feature, bool *isActive) override
Get the current status of the feature, on or off.
Definition: USBcamera.cpp:392
USBCameraDriver::getRgbIntrinsicParam
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
Definition: USBcamera.cpp:222
buffer
Definition: V4L_camera.h:75
USBCameraDriver::getRgbHeight
int getRgbHeight() override
Return the height of each frame.
Definition: USBcamera.cpp:159
USBCameraDriver::setOnePush
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ...
Definition: USBcamera.cpp:440
yarp::dev::IFrameGrabberControls
Control interface for frame grabber devices.
Definition: FrameGrabberInterfaces.h:365
Semaphore.h
USBCameraDriver::hasManual
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
Definition: USBcamera.cpp:408
USBCameraDriver::getRgbMirroring
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
Definition: USBcamera.cpp:230
USBCameraDriverRaw::width
int width() const override
Return the width of each frame.
Definition: USBcamera.cpp:312
FrameGrabberInterfaces.h
define common interfaces to discover remote camera capabilities
USBCameraDriver::hasAuto
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
Definition: USBcamera.cpp:400
USBCameraDriver::hasFeature
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ...
Definition: USBcamera.cpp:336
USBCameraDriver::getRawBufferSize
int getRawBufferSize() override
Implements the Frame grabber basic interface.
Definition: USBcamera.cpp:140
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
USBCameraDriver::close
bool close() override
Closes the device driver.
Definition: USBcamera.cpp:102
yarp::dev::IRgbVisualParams
An interface for retrieving intrinsic parameter from a rgb camera.
Definition: IVisualParams.h:73
USBCameraDriver::setActive
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
Definition: USBcamera.cpp:384
USBCameraDriver::hasOnePush
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
Definition: USBcamera.cpp:416
FeatureMode
FeatureMode
Definition: FrameGrabberInterfaces.h:29
USBCameraDriverRaw::height
int height() const override
Return the height of each frame.
Definition: USBcamera.cpp:317
USBCameraDriver::USBCameraDriver
USBCameraDriver()
Constructor.
Definition: USBcamera.cpp:42
USBCameraDriverRaw::USBCameraDriverRaw
USBCameraDriverRaw()
Definition: USBcamera.cpp:290
USBCameraDriver::~USBCameraDriver
~USBCameraDriver() override
Destructor.
Definition: USBcamera.cpp:48
USBCameraDriver::getFeature
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
Definition: USBcamera.cpp:352
USBCameraDriver::width
int width() const override
Implements FrameGrabber basic interface.
Definition: USBcamera.cpp:110
USBCameraDriver::height
int height() const override
Implements FrameGrabber basic interface.
Definition: USBcamera.cpp:122
USBCameraDriverRgb::width
int width() const override
Return the width of each frame.
Definition: USBcamera.cpp:279
USBCameraDriver::deviceControls
yarp::dev::IFrameGrabberControls * deviceControls
Definition: USBcamera.h:57
IVisualParams.h
USBCameraDriver::setRgbMirroring
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
Definition: USBcamera.cpp:238
USBCameraDriver::getCameraDescription
bool getCameraDescription(CameraDescriptor *camera) override
Implementation of IFrameGrabberControls2 interface.
Definition: USBcamera.cpp:328
USBCameraDriver::getRgbBuffer
bool getRgbBuffer(unsigned char *buffer) override
FrameGrabber bgr interface, returns the last acquired frame as a buffer of bgr triplets.
Definition: USBcamera.cpp:145
yarp::dev::IPreciselyTimed
Definition: IPreciselyTimed.h:21
Bottle.h
USBCameraDriver::_height
size_t _height
Definition: USBcamera.h:61
USBCameraDriver::setMode
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
Definition: USBcamera.cpp:424
yarp::dev::IFrameGrabberRgb
RGB Interface to a FrameGrabber device.
Definition: FrameGrabberInterfaces.h:210
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
USBCameraDriverRaw
usbCameraRaw: Documentation to be added
Definition: USBcamera.h:281
DeviceDriver.h