00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00040 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include <iostream>
00043 #include <QDebug>
00044
00045 #include <qvcore/qvapplication.h>
00046 #include <qvcameras/qvmplayercamera.h>
00047 #include <qvgui/qvgui.h>
00048 #include <qvgui/qvimagecanvas.h>
00049 #include <qvdta/qvpolyline.h>
00050 #include <qvdta/qvcontour.h>
00051
00053 class ContourExtractorWorker: public QVWorker
00054 {
00055 public:
00056 ContourExtractorWorker(QString name): QVWorker(name)
00057 {
00058 addProperty<int>("Threshold", inputFlag, 128, "Threshold for a point to count as pertaining to a region", 0, 256);
00059 addProperty<int>("MinAreaIPE", inputFlag, 0, "Minimal area to keep points in the IPE algorithm", 0, 50);
00060 addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00061 addProperty< QList<QVPolyline> >("Output contours", outputFlag);
00062 }
00063
00064 void iterate()
00065 {
00067
00068 QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00069 int threshold = getPropertyValue< int >("Threshold"),
00070 minAreaIPE = getPropertyValue< int >("MinAreaIPE");
00071
00072 uInt rows = image.getRows(), cols = image.getCols();
00073 timeFlag("Read input parameters");
00074
00076
00077 QList<QVPolyline> contours = getConnectedSetBorderContoursThreshold(image, threshold);
00078 timeFlag("Get contours from image");
00079
00081
00082 QList<QVPolyline> ipeContours;
00083
00084 for(uInt n = 0; n < contours.size(); n++)
00085 {
00086 QVPolyline ipePolyline;
00087 IterativePointElimination(contours.at(n), ipePolyline, minAreaIPE);
00088 if (ipePolyline.size() > 0)
00089 ipeContours.append(ipePolyline);
00090 }
00091 timeFlag("IPE filtering");
00092
00094
00095 setPropertyValue< QList<QVPolyline> >("Output contours", ipeContours);
00096 timeFlag("Computed output contours");
00097 }
00098 };
00099
00100 int main(int argc, char *argv[])
00101 {
00102 QVApplication app(argc, argv,
00103
00104 "Example program for QVision library. Applies corner detection over an input video."
00105
00106 );
00107
00108 ContourExtractorWorker worker("Contours Worker");
00109 QVMPlayerCamera camera("Video");
00110 camera.link(&worker,"Input image");
00111
00112 QVGUI interface;
00113
00114 QVImageCanvas contour_canvas("Contours");
00115 contour_canvas.linkProperty(worker, "Input image");
00116 contour_canvas.linkProperty(worker, "Output contours");
00117
00118 return app.exec();
00119 }
00120