examples/corners/corners.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 
00038 #include <stdio.h>
00039 #include <stdlib.h>
00040 #include <iostream>
00041 #include <QDebug>
00042 
00043 #include <qvcore/qvapplication.h>
00044 #include <qvcameras/qvmplayercamera.h>
00045 #include <qvgui/qvgui.h>
00046 
00047 #include <qvdta/qvpolyline.h>
00048 #include <qvdta/qvdta.h>
00049 
00051 class MyWorker: public QVWorker
00052         {
00053         public:
00054                 MyWorker(QString name): QVWorker(name)
00055                         {
00056                         addProperty("Window size", inputFlag, 10, "window size ", 1, 100);
00057                         addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00058                         addProperty< QVImage<uChar,1> >("Corner response image", outputFlag);
00059                         addProperty< QVImage<uChar,3> >("Corners", outputFlag);
00060                         }
00061 
00062                 void iterate()
00063                         {
00064                         int sizeMax = getPropertyValue<int>("Window size");
00065                 
00066                         QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00067                         uInt rows = image.getRows(), cols = image.getCols();
00068                         timeFlag("grab Frame");
00069                 
00071                         // Harris corner response image
00072                         QVImage<sFloat> eigval(cols, rows);
00073                         HarrisCornerResponseImage(image, eigval);
00074                         timeFlag("Corner response image");
00075 
00076                         QVImage<uChar,1> eigvalUChar = eigval, equalizedEigval(cols, rows);
00077                         equalizeHistogram(eigvalUChar, equalizedEigval);
00078                 
00079                         setPropertyValue< QVImage<uChar,1> >("Corner response image", equalizedEigval);
00080                         timeFlag("Show corner response");
00081                 
00083                         // Local maximal filter
00084                         QVImage<uChar> hotpoints(cols, rows);
00085                         FilterLocalMax(eigval, hotpoints, sizeMax, sizeMax);
00086                         //setPropertyValue< QVImage<uChar,3> >("Corners", hotpoints);
00087                         
00088                         QList<QPoint> hotPoints;
00089                         QVIMAGE_INIT_READ(uChar,hotpoints);
00090                         for(uInt row = 0; row < hotpoints.getRows(); row++)
00091                                 for(uInt col = 0; col < hotpoints.getCols(); col++)
00092                                         if (QVIMAGE_PIXEL(hotpoints, col, row,0))
00093                                                 hotPoints.append(QPoint(col, row));
00094                         timeFlag("Local maximal filter");
00095 
00097                         QVImage<uChar,3> destino = image;
00098                         drawPoints(hotPoints, destino);
00099                         setPropertyValue< QVImage<uChar,3> >("Corners", destino);
00100                         timeFlag("Draw corners");
00101                 
00103                         /*QVImage<uChar> buffer;
00104                         QList<QPoint> pointList;
00105                         FindPeaks3x3GetBufferSize(eigval, buffer);              
00106                         FindPeaks3x3(eigval, buffer, pointList, 0.0, ippiNormInf, 1, hotPoints.size());
00107                         timeFlag("Find Peaks");
00108 
00110                         QVImage<uChar,3> destino = image;
00111                         drawPoints(pointList, destino);
00112                         setPropertyValue< QVImage<uChar,3> >("Corners", destino);
00113                         timeFlag("Draw corners");
00114                         */
00115                         }
00116         };
00117 
00118 int main(int argc, char *argv[])
00119         {
00120         QVApplication app(argc, argv,
00121                 
00122                 "Example program for QVision library. Applies corner detection over an input video."
00123 
00124                 );
00125 
00126         QVMPlayerCamera camera("Video");
00127         MyWorker worker("Corners Worker");
00128         camera.link(&worker,"Input image");
00129 
00130         QVGUI interface;
00131 
00132         QVImageCanvas imageCanvas("Corners");
00133         imageCanvas.linkProperty(worker, "Corners");
00134 
00135         return app.exec();
00136         }
00137 

Generated on Fri Feb 22 18:26:55 2008 for QVision by  doxygen 1.5.3