examples/canvasInteract/canvasInteract.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <iostream>
00031 #include <QDebug>
00032 
00033 #include <QVApplication>
00034 #include <QVMPlayerCamera>
00035 #include <QVGUI>
00036 #include <QVImageCanvas>
00037 #include <QVIPP>
00038 
00039 #define RADIUS 1
00040 
00041 #ifndef DOXYGEN_IGNORE_THIS
00042 class MyWorker: public QVWorker
00043         {
00044         public:
00045                 MyWorker(QString name): QVWorker(name)
00046                         {
00047                         addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00048                         addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00049                         addProperty<QRect>("in rect selec", inputFlag);
00050                         addProperty<QVPolyline>("in polyline", inputFlag);
00051                         }
00052 
00053                 void iterate()
00054                         {
00055                         QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00056                         QRect rect = getPropertyValue<QRect>("in rect selec");
00057                         QVPolyline poly = getPropertyValue<QVPolyline>("in polyline");
00058                         QVImage<uChar> dest(image);
00059 
00060                         // get dark in the ROI area
00061                         if (rect != QRect()) image.setROI(rect);
00062                         AddC(image, dest, 10);
00063                         dest.resetROI();
00064 
00065                         // undo it near the polyline's points
00066                         for (int i = 0; i < poly.size(); i++)
00067                                 {
00068                                 int x = poly[i].x(), y = poly[i].y();
00069 //                              for (int x = poly[i].x() - RADIUS; x <= poly[i].x() + RADIUS; x++)
00070 //                                      for (int y = poly[i].y() - RADIUS; y <= poly[i].y() + RADIUS; y++)
00071                                                 if ( (x >= 0) && (x < image.getCols()) && (y >= 0) && (y < image.getRows()) )
00072                                                         dest(x, y) = image(x, y);
00073                                 }
00074 
00075                         setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00076                         }
00077         };
00078 
00079 int main(int argc, char *argv[])
00080         {
00081         QVApplication app(argc, argv, "Example program for QVision library." );
00082         
00083         MyWorker myWorker("worker");
00084         QVMPlayerCamera camera("Video");
00085         camera.link(&myWorker, "Input image");
00086 
00087         QVGUI interface;
00088 
00089         QVImageCanvas imageCanvas("image");
00090         imageCanvas.linkProperty(myWorker, "Output image");
00091         imageCanvas.linkROI(&myWorker, "in rect selec");
00092         imageCanvas.linkPolyline(&myWorker, "in polyline");
00093 
00094         return app.exec();
00095         }
00096 
00097 #endif
00098         

Generated on Thu Jul 17 17:23:27 2008 for QVision by  doxygen 1.5.3