YARP  2.3.70.2
Yet Another Robot Platform
dev/grabber_client.cpp

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

/*
* Copyright: (C) 2010 RobotCub Consortium
* Author: Paul Fitzpatrick
* CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
*/
#include <stdio.h>
#include <stdlib.h>
#include <yarp/os/all.h>
#include <yarp/sig/all.h>
using namespace yarp::os;
using namespace yarp::sig;
using namespace yarp::dev;
/*
* Read an image from a remote source using the "device" view of
* camera-like sources.
*
* Remote source could be, for example:
* yarpdev --device test_grabber --name /fakey
*
*/
int main() {
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;
}
grabberInterface->getImage(img);
printf("Got a %dx%d image\n", img.width(), img.height());
dd.close();
return 0;
}