YARP
Yet Another Robot Platform
FakeFrameGrabber.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_FAKEFRAMEGRABBER_FAKEFRAMEGRABBER_H
11 #define YARP_FAKEFRAMEGRABBER_FAKEFRAMEGRABBER_H
12 
13 #include <cstdio>
14 
15 #include <yarp/sig/ImageFile.h>
16 #include <yarp/dev/DeviceDriver.h>
20 #include <yarp/os/Searchable.h>
21 #include <yarp/os/Time.h>
22 #include <yarp/os/Vocab.h>
23 #include <yarp/os/Log.h>
24 #include <yarp/os/Value.h>
25 #include <yarp/dev/IVisualParams.h>
26 
28 
45 {
46 private:
47  size_t ct;
48  size_t bx, by;
49  size_t w, h;
50  unsigned long rnd;
51  double freq;
52  double period;
53  double first;
54  double horizontalFov,verticalFov;
55  double prev;
56  int mode;
57  bool use_bayer;
58  bool use_mono;
59  bool mirror;
60  yarp::os::Property intrinsic;
62 
63 public:
68 
69  bool close() override;
70 
87  bool open(yarp::os::Searchable& config) override;
88 
89  void timing();
90 
91  int height() const override;
92 
93  int width() const override;
94  //IRgbVisualParams
95  int getRgbHeight() override;
96 
97  int getRgbWidth() override;
98 
100 
101  bool getRgbResolution(int& width, int& height) override;
102 
103  bool setRgbResolution(int width, int height) override;
104 
105  bool getRgbFOV(double& horizontalFov, double& verticalFov) override;
106 
107  bool setRgbFOV(double horizontalFov, double verticalFov) override;
108 
109  bool getRgbIntrinsicParam(yarp::os::Property& intrinsic) override;
110 
111  bool getRgbMirroring(bool& mirror) override;
112 
113  bool setRgbMirroring(bool mirror) override;
114  //
116 
118 
120 
121  bool hasAudio() override;
122 
123  bool hasVideo() override;
124 
125  bool hasRawVideo() override;
126 
127  bool getCameraDescription(CameraDescriptor *camera) override;
128 
129  bool hasFeature(int feature, bool *hasFeature) override;
130 
131  bool setFeature(int feature, double value) override;
132 
133  bool getFeature(int feature, double *value) override;
134 
135  bool setFeature(int feature, double value1, double value2) override;
136 
137  bool getFeature(int feature, double *value1, double *value2) override;
138 
139  bool hasOnOff(int feature, bool *HasOnOff) override;
140 
141  bool setActive(int feature, bool onoff) override;
142 
143  bool getActive(int feature, bool *isActive) override;
144 
145  bool hasAuto(int feature, bool *hasAuto) override;
146 
147  bool hasManual(int feature, bool *hasManual) override;
148 
149  bool hasOnePush(int feature, bool *hasOnePush) override;
150 
151  bool setMode(int feature, FeatureMode mode) override;
152 
153  bool getMode(int feature, FeatureMode *mode) override;
154 
155  bool setOnePush(int feature) override;
156 
157 private:
158  yarp::sig::ImageOf<yarp::sig::PixelRgb> background, rgb_image;
159  yarp::os::Stamp stamp;
160  void createTestImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image);
161 
162  bool makeSimpleBayer(yarp::sig::ImageOf<yarp::sig::PixelRgb>& src,
164 
165  void printTime(unsigned char* pixbuf, int pixbuf_w, int pixbuf_h, int x, int y, char* s, int size);
166  struct txtnum_type
167  {
168  char data[16];
169  };
170  txtnum_type num[12];
171  double start_time;
172 };
173 
174 
176 {
177 public:
178  bool open(yarp::os::Searchable& config) override;
179 };
180 
181 #endif // YARP_FAKEFRAMEGRABBER_FAKEFRAMEGRABBER_H
CameraDescriptor
Definition: FrameGrabberInterfaces.h:35
FakeFrameGrabber::setRgbFOV
bool setRgbFOV(double horizontalFov, double verticalFov) override
Set the field of view (FOV) of the rgb camera.
Definition: FakeFrameGrabber.cpp:216
FakeFrameGrabber::hasAuto
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
Definition: FakeFrameGrabber.cpp:276
yarp::dev::IFrameGrabberImageRaw
Read a YARP-format image from a device.
Definition: FrameGrabberInterfaces.h:293
FakeFrameGrabber::height
int height() const override
Return the height of each frame.
Definition: FakeFrameGrabber.cpp:177
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
FakeFrameGrabber::hasOnOff
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
Definition: FakeFrameGrabber.cpp:273
FakeFrameGrabber::getRgbWidth
int getRgbWidth() override
Return the width of each frame.
Definition: FakeFrameGrabber.cpp:189
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
FakeFrameGrabber::setRgbMirroring
bool setRgbMirroring(bool mirror) override
Set the mirroring setting of the sensor.
Definition: FakeFrameGrabber.cpp:231
FakeFrameGrabber::setFeature
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ...
Definition: FakeFrameGrabber.cpp:269
FakeFrameGrabber::hasOnePush
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
Definition: FakeFrameGrabber.cpp:278
IPreciselyTimed.h
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
FakeFrameGrabber::getImage
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
Get an rgb image from the frame grabber, if required demosaicking/color reconstruction is applied.
Definition: FakeFrameGrabber.cpp:236
FakeFrameGrabber::hasFeature
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ...
Definition: FakeFrameGrabber.cpp:268
TestFrameGrabber::open
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
Definition: FakeFrameGrabber.cpp:578
FakeFrameGrabber::FakeFrameGrabber
FakeFrameGrabber()
Constructor.
Definition: FakeFrameGrabber.cpp:34
Searchable.h
yarp::sig::ImageOf< yarp::sig::PixelRgb >
yarp::sig::VectorOf< yarp::dev::CameraConfig >
Log.h
AudioVisualInterfaces.h
FakeFrameGrabber::setActive
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
Definition: FakeFrameGrabber.cpp:274
TestFrameGrabber
Definition: FakeFrameGrabber.h:176
FakeFrameGrabber::hasManual
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
Definition: FakeFrameGrabber.cpp:277
yarp::dev::IFrameGrabberImage
Read a YARP-format image from a device.
Definition: FrameGrabberInterfaces.h:241
FakeFrameGrabber::getCameraDescription
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
Definition: FakeFrameGrabber.cpp:267
FakeFrameGrabber::open
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
Definition: FakeFrameGrabber.cpp:73
FakeFrameGrabber::getRgbResolution
bool getRgbResolution(int &width, int &height) override
Get the resolution of the rgb image from the camera.
Definition: FakeFrameGrabber.cpp:198
FakeFrameGrabber::close
bool close() override
Close the DeviceDriver.
Definition: FakeFrameGrabber.cpp:69
FakeFrameGrabber::getRgbIntrinsicParam
bool getRgbIntrinsicParam(yarp::os::Property &intrinsic) override
Get the intrinsic parameters of the rgb camera.
Definition: FakeFrameGrabber.cpp:222
FakeFrameGrabber::getLastInputStamp
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
Definition: FakeFrameGrabber.cpp:255
yarp::dev::IFrameGrabberControls
Control interface for frame grabber devices.
Definition: FrameGrabberInterfaces.h:365
FakeFrameGrabber::setOnePush
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ...
Definition: FakeFrameGrabber.cpp:281
FrameGrabberInterfaces.h
define common interfaces to discover remote camera capabilities
ImageFile.h
FakeFrameGrabber
fakeFrameGrabber: A fake camera for testing.
Definition: FakeFrameGrabber.h:45
yarp::dev::IAudioVisualStream
Definition: IAudioVisualStream.h:27
FakeFrameGrabber::hasRawVideo
bool hasRawVideo() override
Definition: FakeFrameGrabber.cpp:263
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
FakeFrameGrabber::getActive
bool getActive(int feature, bool *isActive) override
Get the current status of the feature, on or off.
Definition: FakeFrameGrabber.cpp:275
yarp::dev::IRgbVisualParams
An interface for retrieving intrinsic parameter from a rgb camera.
Definition: IVisualParams.h:73
FakeFrameGrabber::hasAudio
bool hasAudio() override
Definition: FakeFrameGrabber.cpp:259
FeatureMode
FeatureMode
Definition: FrameGrabberInterfaces.h:29
FakeFrameGrabber::setMode
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.
Definition: FakeFrameGrabber.cpp:279
FakeFrameGrabber::getRgbSupportedConfigurations
bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations) override
Get the possible configurations of the camera.
Definition: FakeFrameGrabber.cpp:193
yarp::conf::vocab32_t
std::int32_t vocab32_t
Definition: numeric.h:52
FakeFrameGrabber::getFeature
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
Definition: FakeFrameGrabber.cpp:270
FakeFrameGrabber::getRgbHeight
int getRgbHeight() override
Return the height of each frame.
Definition: FakeFrameGrabber.cpp:185
Vocab.h
FakeFrameGrabber::width
int width() const override
Return the width of each frame.
Definition: FakeFrameGrabber.cpp:181
FakeFrameGrabber::hasVideo
bool hasVideo() override
Definition: FakeFrameGrabber.cpp:261
FakeFrameGrabber::getRgbMirroring
bool getRgbMirroring(bool &mirror) override
Get the mirroring setting of the sensor.
Definition: FakeFrameGrabber.cpp:227
FakeFrameGrabber::getRgbFOV
bool getRgbFOV(double &horizontalFov, double &verticalFov) override
Get the field of view (FOV) of the rgb camera.
Definition: FakeFrameGrabber.cpp:210
Time.h
FakeFrameGrabber::setRgbResolution
bool setRgbResolution(int width, int height) override
Set the resolution of the rgb image from the camera.
Definition: FakeFrameGrabber.cpp:204
FakeFrameGrabber::getMode
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
Definition: FakeFrameGrabber.cpp:280
IVisualParams.h
FakeFrameGrabber::timing
void timing()
Definition: FakeFrameGrabber.cpp:159
yarp::dev::IPreciselyTimed
Definition: IPreciselyTimed.h:21
Value.h
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
VOCAB_LINE
constexpr yarp::conf::vocab32_t VOCAB_LINE
Definition: FakeFrameGrabber.h:27
DeviceDriver.h