PARP Research Group University of Murcia, Spain


examples/designer/designer.cpp

00001 /*
00002  *      Copyright (C) 2008. 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 
00021 
00022 #include <QVDesignerGUI>
00023 #include <qvipp.h>
00024 #include <QVApplication>
00025 #include <QVMPlayerCamera>
00026 #include <QVImageCanvas>
00027 #include <QVNumericPlot>
00028 #include <QVHistogramPlot>
00029 #include <qvippworkers.h>
00030 
00031 #ifndef DOXYGEN_IGNORE_THIS
00032 class MyWorker: public QVWorker
00033         {
00034         public:
00035                 MyWorker(QString name = QString()): QVWorker(name)  // el worker tiene que tener un constructor por defecto para poder registrarlo
00036                         {
00037                         addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00038                         addProperty< QVImage<uChar,1> >("Input image2", inputFlag|outputFlag);
00039                         addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00040                         addProperty<int>("Max pixel", outputFlag);
00041                         addProperty<int>("Min pixel", outputFlag);
00042                         addProperty<QList<double> >("MinMaxList", outputFlag);
00043                         addProperty<QList<double> >("FirstRow", outputFlag);
00044                         }
00045 
00046                 void iterate()
00047                         {
00048                         QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00049                         uchar min, max;
00050                         Max(image, max);
00051                         Min(image, min);
00052                         setPropertyValue<int>("Max pixel", max);
00053                         setPropertyValue<int>("Min pixel", min);
00054                         timeFlag("get min-max values");
00055 
00056                         QList<double> minmaxlist;
00057                         minmaxlist << min << max;
00058                         setPropertyValue<QList<double> >("MinMaxList", minmaxlist);
00059                         timeFlag("get min-max list");
00060 
00061                         QList<double> firstrow;
00062                         for (uint i = 0; i < image.getCols(); i++) firstrow << image(i, 0);
00063                         setPropertyValue<QList<double> >("FirstRow", firstrow);
00064                         timeFlag("get first row");
00065 
00066                         QVImage<uChar> dest(image);
00067                         AddC(image, 10, dest);
00068 
00069                         setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00070                         timeFlag("change image");
00071                         }
00072         };
00073 
00074 int main(int argc, char *argv[])
00075         {
00076         QVApplication app(argc, argv, "Example program for QVision library." );
00077         qRegisterMetaType<MyWorker>("MyWorker"); // necesario para que se puedan crear desde el designerGUI
00078         
00079         MyWorker myWorker1("worker1");
00080         MyWorker myWorker2("worker2");
00081         QVIPPCopyP3C3Worker<uChar> p3c3("p3c3");
00082         QVMPlayerCamera camera("Video");
00083         camera.linkProperty(myWorker1, "Input image");
00084         myWorker1.linkProperty("Output image", myWorker2, "Input image", QVWorker::SynchronousLink);
00085 
00086         QVImageCanvas imageCanvas("image");
00087         myWorker2.linkProperty("Output image", imageCanvas);
00088 
00089         QVNumericPlot numericPlot("MinMax", false);
00090         myWorker1.linkProperty("Max pixel", numericPlot);
00091         myWorker1.linkProperty("Min pixel", numericPlot);
00092 
00093         QVDesignerGUI interface;
00094 
00095         return app.exec();
00096         }
00097 
00098 #endif
00099         



QVision framework. PARP research group, copyright 2007, 2008.