summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_ht
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-27 11:54:48 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-27 11:54:48 +0200
commitc7c3bfc9a1558864b06319918900090c7564c6d2 (patch)
treeaa53e2e9395c0197d2ab46585a15293a2423cfd8 /ftnoir_tracker_ht
parentbf45260ce8f235e593a22cdbdf9bcd98d508ae7f (diff)
Get rid of last remnants of QOpenGL
Diffstat (limited to 'ftnoir_tracker_ht')
-rw-r--r--ftnoir_tracker_ht/ftnoir_tracker_ht.cpp2
-rw-r--r--ftnoir_tracker_ht/video_widget.cpp63
-rw-r--r--ftnoir_tracker_ht/video_widget.h30
3 files changed, 24 insertions, 71 deletions
diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
index b13e605d..d88699a9 100644
--- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
+++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
@@ -226,7 +226,7 @@ bool Tracker::GiveHeadPoseData(double *data)
shm->timer = 0;
if (shm->frame.width > 0)
{
- videoWidget->updateImage(shm->frame.frame, shm->frame.width, shm->frame.height);
+ videoWidget->update_image(shm->frame.frame, shm->frame.width, shm->frame.height);
//memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3);
fresh = true;
shm->frame.width = 0;
diff --git a/ftnoir_tracker_ht/video_widget.cpp b/ftnoir_tracker_ht/video_widget.cpp
index 51d92967..01f2516a 100644
--- a/ftnoir_tracker_ht/video_widget.cpp
+++ b/ftnoir_tracker_ht/video_widget.cpp
@@ -11,59 +11,16 @@
using namespace std;
-// ----------------------------------------------------------------------------
-void VideoWidget::initializeGL()
+void VideoWidget::update_image(unsigned char *frame, int width, int height)
{
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-void VideoWidget::resizeGL(int w, int h)
-{
- // setup 1 to 1 projection
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, w, 0, h, -1, 1);
- resize_frame(resized_qframe);
- glDisable(GL_DEPTH_TEST);
- glBegin(GL_QUADS);
- glVertex2f(0,0);
- glVertex2f(1,0);
- glVertex2f(1,1);
- glVertex2f(0,1);
- glEnd();
-}
-
-void VideoWidget::paintGL()
-{
- QMutexLocker lck(&mtx);
- if (resized_qframe.size() == size() || (resized_qframe.width() <= width() && resized_qframe.height() <= height()))
- {
- glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGB, GL_UNSIGNED_BYTE, resized_qframe.bits());
- }
- else
- glClear(GL_DEPTH_BUFFER_BIT);
- glFlush();
-}
-
-void VideoWidget::resize_frame(QImage& qframe)
-{
- QMutexLocker lck(&mtx);
- if (qframe.size() == size() || (qframe.width() <= width() && qframe.height() <= height()))
- resized_qframe = qframe.copy();
+ QMutexLocker((QMutex*)&mtx);
+ QImage qframe = QImage(frame, width, height, 3 * width, QImage::Format_RGB888).rgbSwapped().mirrored();
+ if (qframe.size() == size() || (qframe.width() <= this->width() && qframe.height() <= this->height()))
+ qframe = qframe.mirrored();
else
- resized_qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation).copy();
-}
-
-
-void VideoWidget::updateImage(unsigned char *frame, int width, int height)
-{
- QImage foo = QImage(frame, width, height, 3 * width, QImage::Format_RGB888).rgbSwapped().mirrored();
- resize_frame(foo);
-}
-
-void VideoWidget::update() {
- updateGL();
+ qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation).mirrored();
+ QPainter painter(&qframe);
+ painter.setPen(Qt::blue);
+ painter.setBrush(Qt::blue);
+ pixmap = QPixmap::fromImage(qframe);
}
diff --git a/ftnoir_tracker_ht/video_widget.h b/ftnoir_tracker_ht/video_widget.h
index adc57335..51acc35e 100644
--- a/ftnoir_tracker_ht/video_widget.h
+++ b/ftnoir_tracker_ht/video_widget.h
@@ -8,35 +8,31 @@
#ifndef VIDEOWIDGET_H
#define VIDEOWIDGET_H
-#include <QGLWidget>
#include <QTime>
-#include <QFrame>
-#include <QImage>
+#include <memory>
#include <QWidget>
#include <QMutex>
#include <QMutexLocker>
+#include <QLabel>
+#include <QPainter>
+
// ----------------------------------------------------------------------------
-class VideoWidget : public QGLWidget
+class VideoWidget : public QLabel
{
Q_OBJECT
public:
- VideoWidget(QWidget *parent) : QGLWidget(parent) {
-#if !defined(_WIN32)
- setAttribute(Qt::WA_NativeWindow, true);
-#endif
+ VideoWidget(QWidget *parent) : QLabel(parent), mtx() {
}
-
- void initializeGL();
- void resizeGL(int w, int h);
- void paintGL();
-
- void updateImage(unsigned char* frame, int width, int height);
- void update();
+ void update_image(unsigned char* frame, int width, int height);
+protected slots:
+ void paintEvent( QPaintEvent* e ) {
+ setPixmap(pixmap);
+ QLabel::paintEvent(e);
+ }
private:
- void resize_frame(QImage& qframe);
- QImage resized_qframe;
QMutex mtx;
+ QPixmap pixmap;
};
#endif // VIDEOWIDGET_H