YARP
Yet Another Robot Platform
dev/grabber_client/grabber_client.cpp

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

/*
* Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
* Copyright (C) 2006-2010 RobotCub Consortium
* All rights reserved.
*
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/
#include <yarp/sig/Image.h>
#include <cstdio>
/*
* 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", "remote_grabber"); // 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;
}
Network.h
Drivers.h
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:261
YARP_UNUSED
#define YARP_UNUSED(var)
Definition: api.h:159
yarp::sig::ImageOf
Typed image class.
Definition: Image.h:647
Property.h
yarp::dev::IFrameGrabberImage
Read a YARP-format image from a device.
Definition: FrameGrabberInterfaces.h:241
PolyDriver.h
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
FrameGrabberInterfaces.h
define common interfaces to discover remote camera capabilities
Image.h
yarp::sig::PixelRgb
Packed RGB pixel type.
Definition: Image.h:453
yarp::os::Network
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition: Network.h:786
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37