YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameGrabber_nwc_yarp.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_FRAMEGRABBER_NWC_YARP_H
8#define YARP_FRAMEGRABBER_NWC_YARP_H
9
11#include <yarp/os/Port.h>
14
19
20#include <mutex>
22
24{
25public:
26 int lastHeight() const;
27 int lastWidth() const;
29
30 template <typename ImageType>
31 bool lastImage(ImageType& image);
32
33 bool open(const std::string& local,
34 const std::string& remote,
35 const std::string& carrier);
36 bool close();
37
38private:
40 yarp::os::Port port;
41
42 std::mutex m_mutex;
43 yarp::os::Stamp m_lastStamp {0, 0.0};
44 int m_lastHeight {0};
45 int m_lastWidth {0};
46};
47
48
49template <typename ImageType,
53 public yarp::proto::framegrabber::FrameGrabberOf_Forwarder<ImageType, IfVocab, ImgVocab>
54{
55public:
58
59 // Re-implement the IFrameGrabberOf methods, to use the image received from
60 // the streaming port when enabled, instead of calling the requesting them
61 // using RPC calls
62 int height() const override;
63 int width() const override;
64 bool getImage(ImageType& image) override;
65 bool getImageCrop(cropType_id_t cropType,
66 yarp::sig::VectorOf<std::pair<int, int>> vertices,
67 ImageType& image) override;
68
69 void setStreamReceiver(StreamReceiver* m_streamReceiver);
70
71private:
72 mutable std::mutex m_mutex;
73 StreamReceiver* m_streamReceiver {nullptr};
74};
75
76
88 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelRgb>>,
89 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelMono>, VOCAB_FRAMEGRABBER_IMAGERAW>,
90 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelFloat>>,
91 public FrameGrabberOf_ForwarderWithStream<yarp::sig::FlexImage>,
97{
98public:
104 ~FrameGrabber_nwc_yarp() override = default;
105
106 // yarp::dev::DeviceDriver
107 bool open(yarp::os::Searchable& config) override;
108 bool close() override;
109
110 // yarp::dev::IPreciselyTimed
112
113private:
114 StreamReceiver streamReceiver;
115 yarp::os::Port rpcPort;
116};
117
118#endif // YARP_FRAMEGRABBER_NWC_YARP_H
constexpr yarp::conf::vocab32_t VOCAB_RGB_IMAGE
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGE
cropType_id_t
yarp::sig::ImageOf< yarp::sig::PixelRgb > ImageType
Definition ImageType.h:24
int width() const override
Return the width of each frame.
bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, ImageType &image) override
Get a crop of the image from the frame grabber.
int height() const override
Return the height of each frame.
void setStreamReceiver(StreamReceiver *m_streamReceiver)
~FrameGrabberOf_ForwarderWithStream() override=default
bool getImage(ImageType &image) override
Get an image from the frame grabber.
This class is the parameters parser for class FrameGrabber_nwc_yarp.
frameGrabber_nwc_yarp: The client of a frameGrabber_nws_yarp.
FrameGrabber_nwc_yarp(const FrameGrabber_nwc_yarp &)=delete
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
FrameGrabber_nwc_yarp & operator=(FrameGrabber_nwc_yarp &&)=delete
FrameGrabber_nwc_yarp & operator=(const FrameGrabber_nwc_yarp &)=delete
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
~FrameGrabber_nwc_yarp() override=default
FrameGrabber_nwc_yarp(FrameGrabber_nwc_yarp &&)=delete
bool lastImage(ImageType &image)
yarp::os::Stamp lastStamp() const
bool open(const std::string &local, const std::string &remote, const std::string &carrier)
Interface implemented by all device drivers.
A mini-server for performing network communication in the background.
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
This classes implement a sender / parser for IFrameGrabberControls interface messages.
This classes implement a sender / parser for IFrameGrabberOf interface messages.
std::int32_t vocab32_t
Definition numeric.h:78