examples/test/test.cpp

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 
00040 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include <iostream>
00043 #include <QDebug>
00044 
00045 #include <QVApplication>
00046 #include <QVMPlayerCamera>
00047 #include <QVDefaultGUI>
00048 #include <QVImageCanvas>
00049 
00050 #include <QVPolyline>
00051 #include <QVMatrix>
00052 
00053 #include <qvdta/qvdta.h>
00054 #include <qvip/qvip.h>
00055 #include <qvippworkers.h>
00056 
00057 // Comment this if you don't want inpainting.
00058 //#define INPAINTING
00059 #ifndef DOXYGEN_IGNORE_THIS
00060 
00061 #define IMAEG_ROISIZE(Image)    ((IppiSize){ Image.getROI().width(), Image.getROI().height() })
00062 
00063 class TestWorker: public QVWorker
00064         {
00065         public:
00066                 TestWorker(QString name): QVWorker(name)
00067                         {
00068                         addProperty< QVImage<uChar,1> >("Input image", inputFlag);
00069                         addProperty<int>("Input value", inputFlag, 4, "", 0, 255);
00070 
00071                         addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00072                         addProperty<int>("Output value", outputFlag, 4, "", 0, 255);
00073                         }
00074 
00075                 void iterate()
00076                         {
00077                         setPropertyValue< QVImage<uChar,1> >("Output image", getPropertyValue< QVImage<uChar,1> >("Input image"));
00078                         setPropertyValue< int >("Output value", getPropertyValue< int >("Input value"));
00079                         }
00080         };
00081 
00082 int main(int argc, char *argv[])
00083         {
00084         QVApplication app(argc, argv,
00085                 "Example program for QVision library. Obtains several features from input video frames."
00086                 );
00087 
00088         qvippCopyP3C3Worker("P3C3");
00089         TestWorker      testWorker("Test Worker"), testWorker2("Test Worker 2");
00090         QVMPlayerCamera camera("Video");
00091 
00092         camera.link(&testWorker,"Input image");
00093         testWorker2.linkProperty("Output image", &testWorker, "Input image", QVWorker::SynchronousLink);
00094         testWorker2.linkProperty("Output value", &testWorker, "Input value", QVWorker::AsynchronousLink);
00095 
00096         QVDefaultGUI interface;
00097 
00098         //QVImageCanvas imageCanvas("Original");
00099         //imageCanvas.linkProperty(testWorker,"Input image");
00100 
00101         QVImageCanvas testCanvas("Alberto");
00102         testCanvas.linkProperty(testWorker,"Output image");
00103 
00104         return app.exec();
00105         }
00106 
00107 #endif