summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT/video_widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-09-15 15:00:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-09-15 15:00:56 +0200
commit490f3ddb79018d13182fc17bb92943bbe427643d (patch)
treed1efc46c88878cf5435a19bfc9519dfd098220a8 /FTNoIR_Tracker_PT/video_widget.cpp
parentbef7aff31e5ea073f0f160ca6a2f1e56b7dd881a (diff)
New PT from Patrick Ruoff adapted to Linux
Diffstat (limited to 'FTNoIR_Tracker_PT/video_widget.cpp')
-rw-r--r--FTNoIR_Tracker_PT/video_widget.cpp58
1 files changed, 42 insertions, 16 deletions
diff --git a/FTNoIR_Tracker_PT/video_widget.cpp b/FTNoIR_Tracker_PT/video_widget.cpp
index 236faaf7..0d31620f 100644
--- a/FTNoIR_Tracker_PT/video_widget.cpp
+++ b/FTNoIR_Tracker_PT/video_widget.cpp
@@ -14,8 +14,10 @@
using namespace cv;
using namespace std;
+#ifndef OPENTRACK_API
using namespace boost;
-
+#endif
+#ifndef OPENTRACK_API
// ----------------------------------------------------------------------------
void VideoWidget::initializeGL()
{
@@ -100,20 +102,44 @@ void VideoWidget::update_frame_and_points()
updateGL();
}
+#else
+void VideoWidget2::update_image(const cv::Mat& frame)
+{
+ QMutexLocker foo(&mtx);
+ QImage qframe = QImage(frame.cols, frame.rows, QImage::Format_RGB888);
+ uchar* data = qframe.bits();
+ const int pitch = qframe.bytesPerLine();
+ for (int y = 0; y < frame.rows; y++)
+ for (int x = 0; x < frame.cols; x++)
+ {
+ const int pos = 3 * (y*frame.cols + x);
+ data[y * pitch + x * 3 + 0] = frame.data[pos + 2];
+ data[y * pitch + x * 3 + 1] = frame.data[pos + 1];
+ data[y * pitch + x * 3 + 2] = frame.data[pos + 0];
+ }
+ qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ pixmap = QPixmap::fromImage(qframe);
+}
+#endif
+
// ----------------------------------------------------------------------------
-VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider)
- : QDialog(parent),
- video_widget(NULL)
+VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider)
+ : QDialog(parent),
+ video_widget(NULL)
{
- const int VIDEO_FRAME_WIDTH = 640;
- const int VIDEO_FRAME_HEIGHT = 480;
-
- video_widget = new VideoWidget(this, provider);
-
- QHBoxLayout* layout = new QHBoxLayout();
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(video_widget);
- if (this->layout()) delete this->layout();
- setLayout(layout);
- resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT);
-} \ No newline at end of file
+ const int VIDEO_FRAME_WIDTH = 640;
+ const int VIDEO_FRAME_HEIGHT = 480;
+
+#ifdef OPENTRACK_API
+ video_widget = new VideoWidget2(this, provider);
+#else
+ video_widget = new VideoWidget(this, provider);
+#endif
+
+ QHBoxLayout* layout = new QHBoxLayout();
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(video_widget);
+ if (this->layout()) delete this->layout();
+ setLayout(layout);
+ resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT);
+}