image_process.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2010 by Dejan Pangercic <dejan.pangercic@cs.tum.edu>
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018  
00019 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
00020 #include <ace/config.h>
00021 
00022 #include <yarp/os/all.h>
00023 #include <yarp/sig/all.h>
00024 
00025 using namespace yarp::os;
00026 using namespace yarp::sig;
00027 using namespace yarp::sig::draw;
00028 
00029 /*
00030   This example adds a moving circle to an image stream.
00031 
00032   Suppose we have an image source on port /source such as:
00033     yarpdev --device test_grabber --name /source --mode line --framerate 10
00034 
00035   And suppose we have an image viewer on port /view:
00036     yarpview --name /view
00037 
00038   Then we can hook this program up in between as follows:
00039     ./image_process --name /worker
00040     yarp connect /source /worker
00041     yarp connect /worker /view
00042 
00043   You should see the normal scrolling line of test_grabber, with a moving
00044   circle overlaid.
00045 
00046  */
00047 
00048 int main(int argc, char *argv[]) {
00049 
00050     // Initialize network
00051     Network yarp;
00052 
00053     // Make a port for reading and writing images
00054     BufferedPort<ImageOf<PixelRgb> > port;
00055 
00056     // Get command line options
00057     Property options;
00058     options.fromCommand(argc,argv);
00059 
00060     // Set the name of the port (use "/worker" if there is no --name option)
00061     ConstString portName = options.check("name",Value("/worker")).asString();
00062     port.open(portName);
00063   
00064     int ct = 0;
00065     while (true) {
00066         // read an image from the port
00067         ImageOf<PixelRgb> *img = port.read();
00068         if (img==NULL) continue;
00069 
00070         // add a blue circle
00071         PixelRgb blue(0,0,255);
00072         addCircle(*img,blue,ct,50,10);
00073         ct = (ct+5)%img->width();
00074 
00075         // output the image
00076         port.prepare() = *img;
00077         port.write();
00078     }
00079   
00080     return 0;
00081 }


yarp_to_ros_image
Author(s): Dejan Pangercic, Alexis Maldonado
autogenerated on Mon Oct 6 2014 09:34:19