PARP Research Group University of Murcia, Spain


examples/plots/plots.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 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 
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include <iostream>
00042 #include <QDebug>
00043 
00044 #include <qvipp.h>
00045 
00046 #include <QVApplication>
00047 #include <QVMPlayerCamera>
00048 #include <QVDefaultGUI>
00049 #include <QVImageCanvas>
00050 #include <QVNumericPlot>
00051 #include <QVHistogramPlot>
00052 #include <QVHistogramPlot2>
00053 
00054 #ifndef DOXYGEN_IGNORE_THIS
00055 class MyWorker: public QVWorker
00056         {
00057         public:
00058                 MyWorker(QString name): QVWorker(name)
00059                         {
00060                         addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00061                         addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00062                         addProperty<int>("Max pixel", outputFlag);
00063                         addProperty<int>("Min pixel", outputFlag);
00064                         addProperty<QList<double> >("MinMaxList", outputFlag);
00065                         addProperty<QList<double> >("FirstRow", outputFlag);
00066                         }
00067 
00068                 void iterate()
00069                         {
00070                         QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00071 
00072                         uchar min, max;
00073                         Max(image, max);
00074                         Min(image, min);
00075                         setPropertyValue<int>("Max pixel", max);
00076                         setPropertyValue<int>("Min pixel", min);
00077                         QList<double> minmaxlist;
00078                         minmaxlist << min << max;
00079                         setPropertyValue<QList<double> >("MinMaxList", minmaxlist);
00080 
00081                         QList<double> firstrow;
00082                         for (uint i = 0; i < image.getCols(); i++) firstrow << image(i, 0);
00083                         setPropertyValue<QList<double> >("FirstRow", firstrow);
00084 
00085                         QVImage<uChar> dest(image);
00086 
00087                         AddC(image, 10, dest);
00088 
00089                         setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00090                         }
00091         };
00092 
00093 int main(int argc, char *argv[])
00094         {
00095         QVApplication app(argc, argv, "Example program for QVision library." );
00096         
00097         MyWorker myWorker1("worker1");
00098         MyWorker myWorker2("worker2");
00099         MyWorker myWorker3("worker3");
00100         MyWorker myWorker4("worker4");
00101         myWorker1.pause();
00102         myWorker2.pause();
00103         myWorker3.pause();
00104         myWorker4.pause();
00105 
00106         QVMPlayerCamera camera1("Video1");
00107         QVMPlayerCamera camera2("Video2");
00108 
00109         camera1.linkProperty(&myWorker1, "Input image", QVWorker::AsynchronousLink);
00110         camera2.linkProperty(&myWorker2, "Input image", QVWorker::AsynchronousLink);
00111 
00112         myWorker1.linkProperty("Output image", myWorker2, "Input image", QVWorker::SequentialLink);
00113         myWorker3.linkProperty("Output image", myWorker4, "Input image", QVWorker::SequentialLink);
00114         myWorker2.linkProperty("Output image", myWorker3, "Input image", QVWorker::SequentialLink);
00115 
00116         QVDefaultGUI interface;
00117 
00118         QVImageCanvas imageCanvas1("image1");
00119         QVImageCanvas imageCanvas2("image2");
00120         myWorker3.linkProperty("Output image", imageCanvas1);
00121         myWorker4.linkProperty("Output image", imageCanvas2);
00122 /*
00123         QVNumericPlot numericPlot("MinMax", false);
00124         myWorker1.linkProperty("Max pixel", numericPlot);
00125         myWorker1.linkProperty("Min pixel", &numericPlot);
00126 
00127         QVHistogramPlot hist("hist");
00128         myWorker1.linkProperty("FirstRow", hist);
00129         myWorker2.linkProperty("FirstRow", hist);
00130 //      myWorker4.linkProperty("MinMaxList", hist);
00131 
00132         QVHistogramPlot2 hist2("hist2");
00133         myWorker1.linkProperty("FirstRow", hist2);
00134         myWorker2.linkProperty("FirstRow", hist2);
00135 //      myWorker3.linkProperty("MinMaxList", hist2);
00136 */
00137         return app.exec();
00138         }
00139 
00140 #endif
00141         



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