00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00051 #include <QVApplication>
00052 #include <QVDefaultGUI>
00053 #include <QVImageCanvas>
00054 #include <QVVideoReaderBlock>
00055 #include <qvip.h>
00056
00057
00058 #ifndef DOXYGEN_IGNORE_THIS
00059 class PlayerBlock: public QVProcessingBlock
00060 {
00061 int frameNumber;
00062 QVImage<uChar, 3> actualImage;
00063 public:
00064 PlayerBlock(QString name): QVProcessingBlock(name),
00065 frameNumber(0)
00066 {
00067 addProperty< QVImage<uChar,3> >("RGB image", inputFlag|outputFlag);
00068 addProperty< QVImage<uChar> >("Y image", inputFlag|outputFlag);
00069 addProperty< QVImage<uChar> >("U image", inputFlag|outputFlag);
00070 addProperty< QVImage<uChar> >("V image", inputFlag|outputFlag);
00071 addProperty< QVImage<uChar> >("R image", inputFlag|outputFlag);
00072 addProperty< QVImage<uChar> >("G image", inputFlag|outputFlag);
00073 addProperty< QVImage<uChar> >("B image", inputFlag|outputFlag);
00074 addProperty<int>("ColorRGBYUV", inputFlag|guiInvisible, 1,
00075 "Show Color (1), RGB separated (2) or YUV separated (3)",1,3);
00076
00077 addTrigger("Store frame");
00078 }
00079
00080 void processTrigger(const QString triggerName)
00081 {
00082 const QString fileName = QString("frame_") + QString::number(frameNumber++).rightJustified(6, '0') + QString(".png");
00083 std::cout << "Storing frame in file " << qPrintable(fileName) << std::endl;
00084 writeQVImageToFile(fileName, actualImage);
00085 }
00086
00087 void iterate()
00088 {
00089 actualImage = getPropertyValue< QVImage<uChar, 3> >("RGB image");
00090 }
00091 };
00092
00093 int main(int argc, char *argv[])
00094 {
00095 QVApplication app(argc, argv, "Example program for QVision library. Displays the contents of a video source.");
00096
00097 QVVideoReaderBlock camera("Video");
00098 PlayerBlock player("Video player");
00099 QVDefaultGUI interface;
00100
00101
00102
00103
00104 if(player.getPropertyValue<int>("ColorRGBYUV") == 1) {
00105 QVImageCanvas canvasRGB("RGB image");
00106 camera.linkProperty(&player,"RGB image");
00107 player.linkProperty("RGB image",canvasRGB);
00108 return app.exec();
00109 } else if(player.getPropertyValue<int>("ColorRGBYUV") == 2) {
00110 QVImageCanvas canvasR("R image"), canvasG("G image"), canvasB("B image");
00111 camera.linkProperty(&player,"R image","G image","B image",true);
00112 player.linkProperty("R image",canvasR);
00113 player.linkProperty("G image",canvasG);
00114 player.linkProperty("B image",canvasB);
00115 return app.exec();
00116 } else if(player.getPropertyValue<int>("ColorRGBYUV") == 3) {
00117 QVImageCanvas canvasY("Y image"), canvasU("U image"), canvasV("V image");
00118 camera.linkProperty(&player,"Y image","U image","V image");
00119 player.linkProperty("Y image",canvasY);
00120 player.linkProperty("U image",canvasU);
00121 player.linkProperty("V image",canvasV);
00122 return app.exec();
00123 } else {
00124
00125 return app.exec();
00126 }
00127 }
00128 #endif
00129