YARP
Yet Another Robot Platform
ServerFrameGrabber.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef YARP_DEV_SERVERFRAMEGRABBER_H
8 #define YARP_DEV_SERVERFRAMEGRABBER_H
9 
10 #include <cstdio>
11 
16 #include <yarp/dev/PolyDriver.h>
17 #include <yarp/os/BufferedPort.h>
18 #include <yarp/os/Time.h>
19 #include <yarp/os/Network.h>
20 #include <yarp/os/Vocab.h>
21 #include <yarp/os/Bottle.h>
22 
23 // #define YARP_INCLUDING_DEPRECATED_HEADER_YARP_OS_RATETHREAD_H_ON_PURPOSE
24 #define YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
25 #include <yarp/os/RateThread.h>
26 #undef YARP_INCLUDING_DEPRECATED_HEADER_ON_PURPOSE
27 // #undef YARP_INCLUDING_DEPRECATED_HEADER_YARP_OS_RATETHREAD_H_ON_PURPOSE
28 
29 #define YARP_INCLUDING_DEPRECATED_HEADER_YARP_DEV_DATASOURCE_H_ON_PURPOSE
30 #include <yarp/dev/DataSource.h>
31 #undef YARP_INCLUDING_DEPRECATED_HEADER_YARP_DEV_DATASOURCE_H_ON_PURPOSE
32 
35 
38 
87  public yarp::dev::IService,
88  public yarp::dev::DataSource<yarp::sig::ImageOf<yarp::sig::PixelRgb>>,
89  public yarp::dev::DataSource<yarp::sig::ImageOf<yarp::sig::PixelMono>>,
90  public yarp::dev::DataSource<yarp::dev::ImageRgbSound>,
91  public yarp::dev::DataSource2<yarp::sig::ImageOf<yarp::sig::PixelRgb>,yarp::sig::Sound>
92 {
93 private:
95  yarp::dev::IRgbVisualParams* rgbVis_p{nullptr};
97  yarp::os::Port *p2{nullptr};
103  yarp::dev::IFrameGrabberImage *fgImage{nullptr};
104  yarp::dev::IFrameGrabberImageRaw *fgImageRaw{nullptr};
105  yarp::dev::IAudioGrabberSound *fgSound{nullptr};
106  yarp::dev::IAudioVisualGrabber *fgAv{nullptr};
107  yarp::dev::IFrameGrabberControls *fgCtrl{nullptr};
108  yarp::dev::IPreciselyTimed *fgTimed{nullptr};
109  bool spoke{false}; // location of this variable tickles bug on Solaris/gcc3.2
110  bool canDrop{false};
111  bool addStamp{false};
112  bool active{false};
113  bool singleThreaded{false};
114 
116 
117 public:
118  ServerFrameGrabber() = default;
123  ~ServerFrameGrabber() override = default;
124 
125  bool close() override;
136  bool open(yarp::os::Searchable& config) override;
137 
138  //bool read(ConnectionReader& connection) override;
139 
140  virtual bool respond(const yarp::os::Bottle& command,
141  yarp::os::Bottle& reply) override;
142 
144 
146 
147  bool getDatum(yarp::dev::ImageRgbSound& imageSound) override;
148 
150  yarp::sig::Sound& sound) override;
151 
153 
155 
157  yarp::sig::Sound& sound) override;
158 
159  int height() const override;
160 
161  int width() const override;
162 
163  bool startService() override;
164 
165  bool stopService() override;
166 
167  bool updateService() override;
168 };
169 
171 
172 #endif // YARP_DEV_SERVERFRAMEGRABBER_H
grabber: Export a frame grabber to the network.
ServerFrameGrabber & operator=(ServerFrameGrabber &&)=delete
bool close() override
Close the DeviceDriver.
virtual bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply) override
Respond to a message.
ServerFrameGrabber(ServerFrameGrabber &&)=delete
int width() const override
Return the width of each frame.
bool getDatum(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
bool stopService() override
Shut down the service, whatever it is.
ServerFrameGrabber & operator=(const ServerFrameGrabber &)=delete
bool startService() override
Initiate the service, whatever it is.
ServerFrameGrabber(const ServerFrameGrabber &)=delete
~ServerFrameGrabber() override=default
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image) override
bool open(yarp::os::Searchable &config) override
Configure with a set of options.
int height() const override
Return the height of each frame.
virtual bool getAudioVisual(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image, yarp::sig::Sound &sound) override
Get an image and sound.
bool updateService() override
Give the service the chance to run for a while.
ServerFrameGrabber()=default
Interface implemented by deprecated device drivers.
Definition: DeviceDriver.h:116
A cheap and cheerful framework for human readable/writable forms of messages to devices.
Definition: DeviceDriver.h:131
Read a YARP-format sound block from a device.
Read a YARP-format image and sound from a device.
Control interface for frame grabber devices.
An interface for retrieving intrinsic parameter from a rgb camera.
Common interface for devices that act like services (by which we mean they do something for remote us...
A container for a device driver.
Definition: PolyDriver.h:24
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
A mini-server for network communication.
Definition: Port.h:47
Group a pair of objects to be sent and received together.
Definition: PortablePair.h:48
This class takes a Runnable instance and wraps a thread around it.
Definition: RateThread.h:241
A base class for nested structures that can be searched.
Definition: Searchable.h:66
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition: Sound.h:26
#define YARP_WARNING_POP
Ends a temporary alteration of the enabled warnings.
Definition: system.h:332
#define YARP_WARNING_PUSH
Starts a temporary alteration of the enabled warnings.
Definition: system.h:331
#define YARP_DISABLE_DEPRECATED_WARNING
Disable deprecated warnings in the following code.
Definition: system.h:333