YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameWriter_nws_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_FRAMEWRITER_NWS_YARP_H
8#define YARP_FRAMEWRITER_NWS_YARP_H
9
12#include <yarp/os/RpcServer.h>
13#include <yarp/os/Stamp.h>
14
18
20
21class Image_InputPortProcessor : public yarp::os::BufferedPort<yarp::sig::FlexImage>
22{
23 std::vector<yarp::sig::FlexImage> lastData;
24 std::mutex m_mutex;
25
26public:
28
30 void onRead(yarp::sig::FlexImage& v) override
31 {
32 std::lock_guard<std::mutex> mylock(m_mutex);
33 lastData.push_back(v);
34 };
35
36 inline void getLast(std::vector<yarp::sig::FlexImage>& img)
37 {
38 std::lock_guard<std::mutex> mylock(m_mutex);
39 img = lastData;
40 lastData.clear();
41 }
42};
43
65{
66private:
67 // Ports
68 yarp::os::RpcServer rpcPort;
69 Image_InputPortProcessor m_portProc;
70
71 // Interfaces handled
72 yarp::dev::IFrameWriterImage* iFrameWriterImage {nullptr};
73
74public:
80 ~FrameWriter_nws_yarp() override;
81
82 // DeviceDriver
83 bool close() override;
84 bool open(yarp::os::Searchable& config) override;
85
86 // IWrapper interface
87 bool attach(yarp::dev::PolyDriver* poly) override;
88 bool detach() override;
89
90 //RateThread
91 bool threadInit() override;
92 void run() override;
93};
94
95#endif // YARP_FRAMEWRITER_NWS_YARP_H
This class is the parameters parser for class FrameWriter_nws_yarp.
frameGrabber_nws_yarp: A YARP NWS for camera devices.
bool detach() override
Detach the object (you must have first called attach).
FrameWriter_nws_yarp(FrameWriter_nws_yarp &&)=delete
FrameWriter_nws_yarp(const FrameWriter_nws_yarp &)=delete
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void run() override
Loop function.
FrameWriter_nws_yarp & operator=(FrameWriter_nws_yarp &&)=delete
FrameWriter_nws_yarp & operator=(const FrameWriter_nws_yarp &)=delete
bool attach(yarp::dev::PolyDriver *poly) override
Attach to another object.
bool threadInit() override
Initialization method.
void onRead(yarp::sig::FlexImage &v) override
Callback method.
void getLast(std::vector< yarp::sig::FlexImage > &img)
Image_InputPortProcessor()=default
Interface implemented by all device drivers.
Read a YARP-format image to a device.
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
A port that is specialized as an RPC server.
Definition RpcServer.h:23
A base class for nested structures that can be searched.
Definition Searchable.h:31
Image class with user control of representation details.
Definition Image.h:363