YARP
Yet Another Robot Platform
os/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/all.h>
#include <yarp/sig/all.h>
using namespace yarp::os;
using namespace yarp::sig;
using namespace yarp::sig::draw;
int main(int argc, char *argv[]) {
Property options;
options.fromCommand(argc,argv);
port.open(options.check("name",Value("/image")).asString());
int 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();
Time::delay(0.25);
}
return 0;
}
all.h
yarp::sig
Signal processing.
Definition: Image.h:25
all.h
main
int main(int argc, char *argv[])
Definition: yarpros.cpp:259
yarp::sig::ImageOf< PixelRgb >
yarp::os::BufferedPort::prepare
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
Definition: BufferedPort-inl.h:114
yarp::os::BufferedPort
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:63
yarp::os::Property::fromCommand
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
Definition: Property.cpp:1057
yarp::os::BufferedPort::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: BufferedPort-inl.h:41
yarp::os::Property::check
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Property.cpp:1024
yarp::sig::draw
Definition: ImageDraw.h:26
yarp::os::BufferedPort::write
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
Definition: BufferedPort-inl.h:126
yarp::os
Definition: AbstractCarrier.h:17
yarp::sig::PixelRgb
Packed RGB pixel type.
Definition: Image.h:452
yarp::os::Network
Definition: Network.h:781
yarp
Definition: numeric.h:47
yarp::sig::draw::addCircle
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
Definition: ImageDraw.h:43
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:46
yarp::os::Time::delay
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:114
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:34