Go to the documentation of this file.00001
00004
00005
00006
00007
00008 #ifndef qglv_opencv_DEMOS_SIGNAL404_HPP_
00009 #define qglv_opencv_DEMOS_SIGNAL404_HPP_
00010
00011
00012
00013
00014
00015 #include <QApplication>
00016 #include <QObject>
00017 #include <QThread>
00018 #include <QTime>
00019 #include <iostream>
00020 #include <opencv2/core/core.hpp>
00021 #include <opencv2/highgui/highgui.hpp>
00022
00023
00024
00025
00026
00027 class Signal404 : public QThread {
00028 Q_OBJECT
00029
00030 public:
00031 Signal404(const std::string& filename) : filename(filename) {}
00032 virtual ~Signal404() {}
00033
00034 signals:
00035 void triggerImage(cv::Mat);
00036 void trigger404Image();
00037
00038 protected:
00039 void run() {
00040 for ( unsigned int i = 5; i > 0; --i) {
00041 std::cout << "Looping " << i << std::endl;
00042 QTime dieTime = QTime::currentTime().addSecs( 1 );
00043 while( QTime::currentTime() < dieTime )
00044 {
00045 QCoreApplication::processEvents( QEventLoop::AllEvents, 100 );
00046 }
00047 }
00048 if (!filename.empty() ) {
00049 cv::Mat image;
00050 image = cv::imread(filename, CV_LOAD_IMAGE_COLOR);
00051 emit triggerImage(image);
00052 } else {
00053 emit trigger404Image();
00054 }
00055 }
00056 const std::string& filename;
00057 };
00058
00059 #endif