YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
dev/grabber_client/grabber_client.cpp

How to grab images from a remote source using the yarp::dev::IFrameGrabberImage interface.

How to grab images from a remote source using the yarp::dev::IFrameGrabberImage interface.

See also
yarp::dev::IFrameGrabberImage::getImage
/*
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
* SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <yarp/sig/Image.h>
#include <cstdio>
using yarp::sig::PixelRgb;
/*
* Read an image from a remote source using the "device" view of
* camera-like sources.
*
* Remote source could be, for example:
* yarpdev --device fakeFrameGrabber --name /fakey
*/
int main(int argc, char* argv[])
{
YARP_UNUSED(argc);
YARP_UNUSED(argv);
Network yarp;
Property config;
config.put("device", "frameGrabber_nwc_yarp"); // device type
config.put("local", "/client"); // name of local port to use
config.put("remote", "/fakey"); // name of remote port to connect to
PolyDriver dd(config);
if (!dd.isValid()) {
printf("Failed to create and configure device\n");
return 1;
}
IFrameGrabberImage* grabberInterface;
if (!dd.view(grabberInterface)) {
printf("Failed to view device through IFrameGrabberImage interface\n");
return 1;
}
ImageOf<PixelRgb> img;
grabberInterface->getImage(img);
printf("Got a %zux%zu image\n", img.width(), img.height());
dd.close();
return 0;
}
A container for a device driver.
Definition PolyDriver.h:23
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
A class for storing options and configuration information.
Definition Property.h:33
Typed image class.
Definition Image.h:605
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_UNUSED(var)
Definition api.h:162