summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_aruco/video_widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-07-27 09:07:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-07-27 09:07:42 +0200
commite4f1be83f42742a2fc9a1606695d89a442999d1c (patch)
tree61ea5d18c3a0612017beefa02b44dd6541b00833 /ftnoir_tracker_aruco/video_widget.cpp
parent7c6208d53fa7f96fb1e844b23b9ad341c22f0fc8 (diff)
Import aruco tracker
Diffstat (limited to 'ftnoir_tracker_aruco/video_widget.cpp')
-rw-r--r--ftnoir_tracker_aruco/video_widget.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/ftnoir_tracker_aruco/video_widget.cpp b/ftnoir_tracker_aruco/video_widget.cpp
new file mode 100644
index 00000000..84cba6a3
--- /dev/null
+++ b/ftnoir_tracker_aruco/video_widget.cpp
@@ -0,0 +1,30 @@
+/* Copyright (c) 2012 Patrick Ruoff
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#include "video_widget.h"
+
+#include <QDebug>
+
+using namespace std;
+
+void VideoWidget::update_image(unsigned char *frame, int width, int height)
+{
+ QMutexLocker foo(&mtx);
+ QImage qframe = QImage(width, height, QImage::Format_RGB888);
+ uchar* data = qframe.bits();
+ const int pitch = qframe.bytesPerLine();
+ for (int y = 0; y < height; y++)
+ for (int x = 0; x < width; x++)
+ {
+ const int pos = 3 * (y*width + x);
+ data[y * pitch + x * 3 + 0] = frame[pos + 2];
+ data[y * pitch + x * 3 + 1] = frame[pos + 1];
+ data[y * pitch + x * 3 + 2] = frame[pos + 0];
+ }
+ qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ pixmap = QPixmap::fromImage(qframe);
+}