YARP
Yet Another Robot Platform
os/image_source/image_source.cpp

An example of how to create a source of images as a port.

/*
* 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/os/Time.h>
#include <yarp/os/Value.h>
#include <yarp/sig/Image.h>
int main(int argc, char* argv[])
{
Network yarp;
BufferedPort<ImageOf<PixelRgb>> port;
Property options;
options.fromCommand(argc, argv);
port.open(options.check("name", Value("/image")).asString());
size_t ct = 0;
while (true) {
ImageOf<PixelRgb>& img = port.prepare();
img.resize(100, 100);
img.zero();
PixelRgb blue{0, 0, 255};
addCircle(img, blue, ct, 50, 10);
ct = (ct + 5) % 100;
port.write();
constexpr double loop_delay = 0.25;
yarp::os::Time::delay(loop_delay);
}
return 0;
}
Network.h
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:261
ImageDraw.h
yarp::sig::ImageOf
Typed image class.
Definition: Image.h:647
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:64
Property.h
BufferedPort.h
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::sig::draw::addCircle
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
Definition: ImageDraw.h:43
Time.h
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::os::Time::delay
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:114
Value.h
ResourceFinder.h
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37