00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051 #include <iostream>
00052 #include <QDebug>
00053
00054 #include <QVApplication>
00055 #include <QVVideoReaderBlock>
00056 #include <QVDefaultGUI>
00057 #include <QVImageCanvas>
00058 #include <qvipp.h>
00059
00060 #ifndef DOXYGEN_IGNORE_THIS
00061 class UserInteract: public QVProcessingBlock
00062 {
00063 public:
00064 UserInteract(QString name = QString()): QVProcessingBlock(name)
00065 {
00066 addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag);
00067 addProperty< QVImage<uChar,1> >("Output image", outputFlag);
00068 addProperty<QRect>("in rect selec", inputFlag);
00069 addProperty<QVPolyline>("in polyline", inputFlag);
00070 addProperty<int>("Radius", inputFlag, 4, "Radius of the selected pixel area", 0, 32);
00071
00072 addTrigger("Click me");
00073 }
00074
00075 void processTrigger(const QString triggerName)
00076 {
00077 std::cout << triggerName.toStdString() << ", block's iteration " << getIteration() << std::endl;
00078 }
00079
00080 void iterate()
00081 {
00082 QVImage<uChar> image = getPropertyValue< QVImage<uChar,1> >("Input image");
00083 QRect selectedRectangle = getPropertyValue<QRect>("in rect selec");
00084 const QVPolylineF selectedPoints = getPropertyValue<QVPolylineF>("in polyline");
00085 const int radius = getPropertyValue<int>("Radius");
00086 QVImage<uChar> dest = image;
00087
00088
00089 if (selectedRectangle == QRect())
00090 selectedRectangle = image.getROI();
00091
00092 image.setROI(selectedRectangle);
00093
00094 AddC(image, 10, dest, 1, QPoint(selectedRectangle.x(), selectedRectangle.y()));
00095 dest.resetROI();
00096
00097
00098 foreach(QPointF pointF, selectedPoints)
00099 {
00100 QPoint point(pointF.x(), pointF.y());
00101 const QRect restoreRegion = QRect(point - QPoint(radius,radius), QSize(1+2*radius,1+2*radius));
00102 if (selectedRectangle.contains(restoreRegion, true))
00103 {
00104 image.setROI(restoreRegion);
00105 Copy(image, dest, point - QPoint(radius,radius));
00106 dest.resetROI();
00107 }
00108 }
00109 setPropertyValue< QVImage<uChar,1> >("Output image", dest);
00110 }
00111 };
00112
00113 int main(int argc, char *argv[])
00114 {
00115 QVApplication app(argc, argv, "Example program for QVision library." );
00116
00117 QVVideoReaderBlock camera("Video");
00118 UserInteract userInteract("User interact");
00119
00120 camera.linkProperty(&userInteract, "Input image");
00121
00122 QVDefaultGUI interface;
00123
00124 QVImageCanvas imageCanvas("image");
00125 userInteract.linkProperty("Output image", imageCanvas);
00126 imageCanvas.linkSelectedRectangle(userInteract, "in rect selec");
00127 imageCanvas.linkSelectedPolyline(userInteract, "in polyline");
00128
00129 return app.exec();
00130 }
00131
00132 #endif
00133