00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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/qvmser.h>
00048
00050 class MyWorker: public QVWorker
00051 {
00052 public:
00053 MyWorker(QString name): QVWorker(name)
00054 {
00055 addProperty<int>("Delta", inputFlag, 1, "MSER parameter, as seen in the paper.", 1, 128);
00056 addProperty<int>("minAreaMSER", inputFlag, 10, "MSER with area lesser than this value are discarted.", 1, 100*100);
00057 addProperty<int>("maxAreaMSER", inputFlag, 1000, "MSER with area greater than this value are discarted.", 1, 100*100);
00058 addProperty<double>("diffAreaThreshold", inputFlag, 0.01, "Proportion of the difference in areas to be considered different", 0.0, 1.0);
00059 addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00060 addProperty< QVImage<uChar,3> >("MSER regions", outputFlag);
00061 }
00062
00063 void iterate()
00064 {
00066
00067 const int delta = getPropertyValue<int>("Delta"),
00068 minArea = getPropertyValue<int>("minAreaMSER"),
00069 maxArea = getPropertyValue<int>("maxAreaMSER");
00070 const double diffAreaThreshold = getPropertyValue<double>("diffAreaThreshold");
00071 const QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00072
00073 timeFlag("Read parameters");
00074
00076
00077 const uInt rows = image.getRows(), cols = image.getCols();
00078 QVImage<uChar> notImage(cols, rows);
00079 for (uInt col = 0; col < cols; col++)
00080 for (uInt row = 0; row < rows; row++)
00081 notImage(col, row) = 255 - image(col, row);
00082
00084
00085 QList<QVMSER> MSERListLow, MSERListHigh;
00086
00087 getMSER(image, MSERListLow, delta, minArea, maxArea, diffAreaThreshold);
00088 timeFlag("MSER Low");
00089
00090 getMSER(notImage, MSERListHigh, delta, minArea, maxArea, diffAreaThreshold);
00091 timeFlag("MSER High");
00092
00094
00095 QList< QVPolyline > polylineMSERList;
00096 getMSERContours(image, MSERListLow, polylineMSERList);
00097 getMSERContours(notImage, MSERListHigh, polylineMSERList);
00098
00099 QVImage<uChar,3> mserImage = image;
00100 draw(mserImage, polylineMSERList, (uChar []){ 255, 0, 0 });
00101
00103
00104 setPropertyValue< QVImage<uChar,3> >("MSER regions",mserImage);
00105 timeFlag("Publish resulting images");
00106 }
00107 };
00108
00109 int main(int argc, char *argv[])
00110 {
00111 QVApplication app(argc, argv,
00112 "Example program for QVision library. Gets component tree from images."
00113 );
00114
00115 QVMPlayerCamera camera("Video");
00116 MyWorker worker("MSER Worker");
00117 camera.link(&worker,"Input image");
00118
00119 QVGUI interface;
00120
00121 QVImageCanvas imageCanvas("MSER Regions");
00122 imageCanvas.linkProperty(worker, "MSER regions");
00123
00124 return app.exec();
00125 }
00126
00128
00129