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

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