summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_ht
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-27 16:54:54 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-27 16:54:54 +0200
commit9cc964b09e2b6076ad759485022dfdc48a22d9e1 (patch)
tree7f631eb6ec56ca0cfb560a8de9a09439f89f05c1 /ftnoir_tracker_ht
parentc6f2c4c1f6fce0d91ec975ea19b25b52d9bd13d4 (diff)
Avoid crashes in video frame
Diffstat (limited to 'ftnoir_tracker_ht')
-rw-r--r--ftnoir_tracker_ht/ftnoir_tracker_ht.cpp2
-rw-r--r--ftnoir_tracker_ht/video_widget.cpp17
-rw-r--r--ftnoir_tracker_ht/video_widget.h1
3 files changed, 15 insertions, 5 deletions
diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
index d88699a9..c1755862 100644
--- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
+++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
@@ -207,7 +207,7 @@ void Tracker::StartTracker(QFrame* videoframe)
#else
subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir");
#endif
- connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget()), Qt::QueuedConnection);
+ connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget()));
timer.start(40);
}
diff --git a/ftnoir_tracker_ht/video_widget.cpp b/ftnoir_tracker_ht/video_widget.cpp
index 1504822d..2fa272bd 100644
--- a/ftnoir_tracker_ht/video_widget.cpp
+++ b/ftnoir_tracker_ht/video_widget.cpp
@@ -14,9 +14,20 @@ using namespace std;
void VideoWidget::update_image(unsigned char *frame, int width, int height)
{
QMutexLocker((QMutex*)&mtx);
- QImage qframe = QImage(frame, width, height, 3 * width, QImage::Format_RGB888).rgbSwapped();
- if (qframe.size() == size() || (qframe.width() <= this->width() && qframe.height() <= this->height()))
- qframe = qframe;
+ QImage qframe = QImage(width, height, QImage::Format_RGB888);
+ uchar* data = qframe.bits();
+ const int pitch = qframe.bytesPerLine();
+ const int cn = 3;
+ 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];
+ }
+ if (qframe.size() == size() || (qframe.width() <= this->width() && qframe.height() <= this->height())) {
+ }
else
qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
pixmap = QPixmap::fromImage(qframe);
diff --git a/ftnoir_tracker_ht/video_widget.h b/ftnoir_tracker_ht/video_widget.h
index 9d8ab489..7cccc9fb 100644
--- a/ftnoir_tracker_ht/video_widget.h
+++ b/ftnoir_tracker_ht/video_widget.h
@@ -9,7 +9,6 @@
#define VIDEOWIDGET_H
#include <QTime>
-#include <memory>
#include <QWidget>
#include <QMutex>
#include <QMutexLocker>