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 <QVApplication>
00046 #include <QVVideoReaderBlock>
00047 #include <QVDefaultGUI>
00048 #include <QVImageCanvas>
00049
00050 #include <qvipp.h>
00051
00053
00054 class MyImageCanvas : public QVImageCanvas {
00055 public:
00056 MyImageCanvas(QString name) : QVImageCanvas(name) {} ;
00057 void custom_viewer(){
00058 QVPolyline poly = getPropertyValue<QVPolyline>("poly select");
00059 getQVPainter()->setPen(Qt::yellow);
00060 getQVPainter()->setBrush(QBrush(Qt::magenta, Qt::DiagCrossPattern));
00061 for(int i=0; i<poly.size(); i++) {
00062 getQVPainter()->drawEllipse(poly[i].x()-10, poly[i].y()-10, 20, 20);
00063 getQVPainter()->drawTextUnscaled(poly[i], QString("Point %1").arg(i));
00064 }
00065 getQVPainter()->setBrush(QBrush(Qt::magenta, Qt::NoBrush));
00066 }
00067 };
00068
00069 class MyWorker: public QVProcessingBlock {
00070 public:
00071 MyWorker(QString name = QString()): QVProcessingBlock(name) {
00072 addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00073 addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00074 addProperty<QRect>("input rectangle", inputFlag);
00075 addProperty<QVPolyline>("input polyline", inputFlag);
00076 }
00077
00078 void iterate() {
00079 QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00080 QRect rect = getPropertyValue<QRect>("input rectangle");
00081 QVPolyline poly = getPropertyValue<QVPolyline>("input polyline");
00082 QVImage<uChar> dest = image;
00083
00084
00085 if (rect != QRect()) image.setROI(rect);
00086 AddC(image, 0, dest, 1, QPoint(rect.x(), rect.y()));
00087 dest.resetROI();
00088
00089
00090
00091 for (int i = 0; i < poly.size(); i++)
00092 for (int x = poly[i].x()-3; x <= poly[i].x()+3; x++)
00093 for (int y = poly[i].y()-3; y <= poly[i].y()+3; y++)
00094 if ( (x >= 0) && (x < static_cast<int>(image.getCols())) && (y >= 0) &&
00095 (y < static_cast<int>(image.getRows())) )
00096 dest(x, y) = image(x, y);
00097
00098 setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00099 };
00100 };
00101
00102 int main(int argc, char *argv[]) {
00103 QVApplication app(argc, argv, "Example program for QVision library." );
00104
00105 MyWorker myWorker("worker");
00106 QVVideoReaderBlock camera("Video");
00107 MyImageCanvas imageCanvas("Features");
00108
00109 QVDefaultGUI interface;
00110
00111 camera.linkProperty(&myWorker, "Input image");
00112
00113 myWorker.linkProperty("Output image", imageCanvas);
00114 imageCanvas.linkSelectedRectangle(myWorker, "input rectangle");
00115 imageCanvas.linkSelectedPolyline(myWorker, "input polyline");
00116
00117 return app.exec();
00118 }
00119
00121