diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-09-15 15:00:56 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-09-15 15:00:56 +0200 |
commit | 490f3ddb79018d13182fc17bb92943bbe427643d (patch) | |
tree | d1efc46c88878cf5435a19bfc9519dfd098220a8 /FTNoIR_Tracker_PT/video_widget.h | |
parent | bef7aff31e5ea073f0f160ca6a2f1e56b7dd881a (diff) |
New PT from Patrick Ruoff adapted to Linux
Diffstat (limited to 'FTNoIR_Tracker_PT/video_widget.h')
-rw-r--r-- | FTNoIR_Tracker_PT/video_widget.h | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h index dd5fb642..3164dacc 100644 --- a/FTNoIR_Tracker_PT/video_widget.h +++ b/FTNoIR_Tracker_PT/video_widget.h @@ -10,12 +10,23 @@ #include "frame_observer.h"
-#include <QGLWidget>
#include <QTime>
#include <QDialog>
#include <opencv2/opencv.hpp>
-#include <boost/shared_ptr.hpp>
+#ifndef OPENTRACK_API
+# include <QGLWidget>
+# include <boost/shared_ptr.hpp>
+#else
+# include "FTNoIR_Tracker_PT/boost-compat.h"
+# if defined(_WIN32)
+# include <dshow.h>
+# endif
+#endif
+#include <QPainter>
+#include <QPaintEvent>
+#include <QTimer>
+#ifndef OPENTRACK_API
// ----------------------------------------------------------------------------
// OpenGL based widget to display an OpenCV image with some points on top
class VideoWidget : public QGLWidget, public FrameObserver
@@ -23,7 +34,7 @@ class VideoWidget : public QGLWidget, public FrameObserver Q_OBJECT
public:
- VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {}
+ VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {}
virtual void initializeGL();
virtual void resizeGL(int w, int h);
@@ -40,19 +51,45 @@ private: boost::shared_ptr< std::vector<cv::Vec2f> > points;
};
+#else
+/* Qt moc likes to skip over preprocessor directives -sh */
+class VideoWidget2 : public QWidget, public FrameObserver
+{
+ Q_OBJECT
+
+public:
+ VideoWidget2(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) {
+ connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
+ timer.start(45);
+ }
+ void update_image(const cv::Mat &frame);
+ void update_frame_and_points() {}
+protected slots:
+ void paintEvent( QPaintEvent* e ) {
+ QMutexLocker foo(&mtx);
+ QPainter painter(this);
+ painter.drawPixmap(e->rect(), pixmap, e->rect());
+ }
+private:
+ QMutex mtx;
+ QPixmap pixmap;
+ QTimer timer;
+};
+#endif
// ----------------------------------------------------------------------------
// A VideoWidget embedded in a dialog frame
class VideoWidgetDialog : public QDialog
{
+ Q_OBJECT
public:
VideoWidgetDialog(QWidget *parent, FrameProvider* provider);
virtual ~VideoWidgetDialog() {}
- VideoWidget* get_video_widget() { return video_widget; }
+ VideoWidget2* get_video_widget() { return video_widget; }
private:
- VideoWidget* video_widget;
+ VideoWidget2* video_widget;
};
#endif // VIDEOWIDGET_H
|