YARP
Yet Another Robot Platform
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>
21
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
86 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelRgb>>,
87 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelMono>, VOCAB_FRAMEGRABBER_IMAGERAW>,
88 public FrameGrabberOf_ForwarderWithStream<yarp::sig::ImageOf<yarp::sig::PixelFloat>>,
89 public FrameGrabberOf_ForwarderWithStream<yarp::sig::FlexImage>,
94{
95public:
101 ~FrameGrabber_nwc_yarp() override = default;
102
103 // yarp::dev::DeviceDriver
104 bool open(yarp::os::Searchable& config) override;
105 bool close() override;
106
107 // yarp::dev::IPreciselyTimed
109
110private:
111 StreamReceiver streamReceiver;
112 yarp::os::Port rpcPort;
113};
114
115#endif // YARP_FRAMEGRABBER_NWC_YARP_H
constexpr yarp::conf::vocab32_t VOCAB_RGB_IMAGE
Definition: CameraVocabs.h:116
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGE
Definition: CameraVocabs.h:16
cropType_id_t
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.
FrameGrabberOf_ForwarderWithStream(yarp::os::Port &rpcPort)
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.
frameGrabber_nws_yarp: Connect to 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.
Definition: DeviceDriver.h:30
A mini-server for network communication.
Definition: Port.h:46
A base class for nested structures that can be searched.
Definition: Searchable.h:63
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.
Provides:
Definition: Vector.h:117
std::int32_t vocab32_t
Definition: numeric.h:78