38template <
typename ImageType>
41 std::lock_guard<std::mutex> lock(m_mutex);
47 }
else if (reader.
check()) {
48 ret = image.copy(*(reader.
read(
true)));
50 m_lastHeight = image.height();
51 m_lastWidth = image.width();
60 const std::string& remote,
61 const std::string& carrier)
63 std::lock_guard<std::mutex> lock(m_mutex);
66 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to open " << local <<
"port.";
69 if (!remote.empty()) {
70 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"Connecting" << port.
getName() <<
"to" << remote;
72 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to connect" << local <<
"to" << remote;
76 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"No remote specified. Waiting for connection";
86 std::lock_guard<std::mutex> lock(m_mutex);
88 m_lastStamp = {0, 0.0};
104template <
typename ImageType,
108 yarp::proto::framegrabber::FrameGrabberOf_Forwarder<ImageType, IfVocab, ImgVocab>(rpcPort)
112template <
typename ImageType,
117 std::lock_guard<std::mutex> lock(m_mutex);
118 if (!m_streamReceiver) {
122 return m_streamReceiver->lastHeight();
125template <
typename ImageType,
130 std::lock_guard<std::mutex> lock(m_mutex);
131 if (!m_streamReceiver) {
135 return m_streamReceiver->lastWidth();
138template <
typename ImageType,
143 std::lock_guard<std::mutex> lock(m_mutex);
144 if (!m_streamReceiver) {
148 return m_streamReceiver->lastImage(image);
151template <
typename ImageType,
158 std::lock_guard<std::mutex> lock(m_mutex);
159 if(!m_streamReceiver) {
169template <
typename ImageType,
174 std::lock_guard<std::mutex> lock(m_mutex);
175 m_streamReceiver = streamReceiver;
187 yarp::proto::framegrabber::FrameGrabberControls_Forwarder(rpcPort),
188 yarp::proto::framegrabber::FrameGrabberControlsDC1394_Forwarder(rpcPort),
189 yarp::proto::framegrabber::RgbVisualParams_Forwarder(rpcPort)
196 std::string remote = config.
check(
"remote",
yarp::os::Value(
""),
"port name of real grabber").asString();
197 std::string local = config.
check(
"local",
yarp::os::Value(
"..."),
"port name to use locally").asString();
198 std::string carrier = config.
check(
"stream",
yarp::os::Value(
"tcp"),
"carrier to use for streaming").asString();
199 bool no_stream = config.
check(
"no_stream");
202 if (!streamReceiver.
open(local, remote, carrier)) {
207 std::string rpc_local = local +
"/rpc_client";
208 std::string rpc_remote = remote +
"/rpc";
209 if (!rpcPort.
open(rpc_local)) {
210 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to open " << rpc_local <<
"port.";
213 if (!remote.empty()) {
214 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"Connecting" << rpcPort.
getName() <<
"to" << rpc_remote;
216 yCError(FRAMEGRABBER_NWC_YARP) <<
"Failed to connect" << rpcPort.
getName() <<
"to" << rpc_remote;
220 yCInfo(FRAMEGRABBER_NWC_YARP) <<
"No remote specified. Waiting for connection";
231 streamReceiver.
close();
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGERAW
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)
bool getImage(ImageType &image) override
Get an image from the frame grabber.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
bool lastImage(ImageType &image)
yarp::os::Stamp lastStamp() const
bool open(const std::string &local, const std::string &remote, const std::string &carrier)
virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, ImageType &image)
Get a crop of the image from the frame grabber.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
T * read(bool shouldWait=true) override
Read an available object from the port.
virtual bool getEnvelope(PortReader &envelope)
bool check()
Check if data is available.
void attach(Port &port)
Attach this buffer to a particular port.
T * lastRead() override
Get the last data returned by read()
A mini-server for network communication.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
bool isOpen() const
Check if the port has been opened.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
A single value (typically within a Bottle).
int height() const override
Return the height of each frame.
int width() const override
Return the width of each frame.
bool getImage(ImageType &image) override
Get an image from the frame grabber.
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.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
unsigned char PixelMono
Monochrome pixel type.
float PixelFloat
Floating point pixel type.
The main, catch-all namespace for YARP.