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 
00053 #ifndef DOXYGEN_IGNORE_THIS
00054 class MyWorker: public QVWorker
00055         {
00056         public:
00057                 MyWorker(QString name): QVWorker(name)
00058                         {
00059                         addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00060                         addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00061                         addProperty<int>("Max pixel", outputFlag);
00062                         addProperty<int>("Min pixel", outputFlag);
00063                         addProperty<QList<double> >("MinMaxList", outputFlag);
00064                         addProperty<QList<double> >("FirstRow", outputFlag);
00065                         }
00066 
00067                 void iterate()
00068                         {
00069                         QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00070 
00071                         uchar min, max;
00072                         Max(image, max);
00073                         Min(image, min);
00074                         setPropertyValue<int>("Max pixel", max);
00075                         setPropertyValue<int>("Min pixel", min);
00076                         QList<double> minmaxlist;
00077                         minmaxlist << min << max;
00078                         setPropertyValue<QList<double> >("MinMaxList", minmaxlist);
00079 
00080                         QList<double> firstrow;
00081                         for (uint i = 0; i < image.getCols(); i++) firstrow << image(i, 0);
00082                         setPropertyValue<QList<double> >("FirstRow", firstrow);
00083 
00084                         QVImage<uChar> dest(image);
00085 
00086                         AddC(image, 10, dest);
00087 
00088                         setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00089                         }
00090         };
00091 
00092 int main(int argc, char *argv[])
00093         {
00094         QVApplication app(argc, argv, "Example program for QVision library." );
00095         
00096         MyWorker myWorker1("worker1");
00097         MyWorker myWorker2("worker2");
00098         QVMPlayerCamera camera("Video");
00099         camera.link(&myWorker1, "Input image");
00100         myWorker1.linkProperty("Output image", &myWorker2, "Input image", QVWorker::SynchronousLink);
00101 
00102         QVDefaultGUI interface;
00103 
00104         QVImageCanvas imageCanvas("image");
00105         imageCanvas.linkProperty(myWorker2, "Output image");
00106 
00107         QVNumericPlot numericPlot("MinMax", false);
00108         numericPlot.linkProperty(myWorker1, "Max pixel");
00109         numericPlot.linkProperty(myWorker1, "Min pixel");
00110         numericPlot.linkProperty(myWorker2);
00111 
00112         QVHistogramPlot histPlot1("histMinMax", false, 10, 300);
00113         histPlot1.linkProperty(myWorker1, "MinMaxList");
00114         histPlot1.linkProperty(myWorker2, "MinMaxList");
00115 
00116         QVHistogramPlot histPlot2("histFirstRow", false, 10, 300);
00117         histPlot2.linkProperty(myWorker1, "FirstRow");
00118 
00119         return app.exec();
00120         }
00121 
00122 #endif
00123