From ec1c2b16379d657db92c90e25b9e01393267b596 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:51:32 +0200 Subject: Clean up preprocessor mingw-isms No functional changes. --- compat/compat.cpp | 2 +- compat/compat.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 8eedc8456..d8aac9bce 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -7,7 +7,7 @@ #define IN_FTNOIR_COMPAT #include "compat.h" -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) PortableLockedShm::PortableLockedShm(const char* shmName, const char* mutexName, int mapSize) { diff --git a/compat/compat.h b/compat/compat.h index 7692b38a5..6a95f1673 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -6,7 +6,7 @@ */ #pragma once -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) #include #else #include @@ -19,7 +19,7 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && (defined(_WIN32) || defined(__WIN32)) +#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) #else # define COMPAT_EXPORT @@ -33,7 +33,7 @@ public: void unlock(); void* mem; private: -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) HANDLE hMutex, hMapFile; #else int fd, size; -- cgit v1.2.3 From 74240d04b14cffc93693b0033b65907655fcf218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:46:28 +0200 Subject: Use __declspec(dllimport) --- compat/compat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'compat') diff --git a/compat/compat.h b/compat/compat.h index 6a95f1673..c34add10f 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -21,8 +21,10 @@ #if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) +#elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) #else -# define COMPAT_EXPORT +# define COMPAT_EXPORT #endif class COMPAT_EXPORT PortableLockedShm { -- cgit v1.2.3 From f159fc2b84d2c7139c348d167c7491fb43fb7e5e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:24:25 +0200 Subject: proto-wine: fix warnings, dependencies, reformat --- CMakeLists.txt | 4 ++++ compat/compat.h | 12 ++++++++---- ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 7 +++++-- ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx | 4 ++++ 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'compat') diff --git a/CMakeLists.txt b/CMakeLists.txt index bc734e43e..6385f04df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,6 +416,9 @@ endif() if(NOT SDK_WINE_NO_WRAPPER) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so + DEPENDS "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" + "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx" + "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" COMMAND "${SDK_WINE_PREFIX}/bin/wineg++" -g -O2 -m32 -o opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -423,6 +426,7 @@ endif() "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" -lrt) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) + add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() endif() diff --git a/compat/compat.h b/compat/compat.h index c34add10f..3d54ae1db 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -19,10 +19,14 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllexport) -#elif defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllimport) +#if !defined(OPENTRACK_COMPAT_BUNDLED) +# if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllexport) +# elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) +# else +# define COMPAT_EXPORT +# endif #else # define COMPAT_EXPORT #endif diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx index c88dd332a..42d39ff28 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx @@ -1,9 +1,12 @@ +#define OPENTRACK_COMPAT_BUNDLED #ifdef _WIN32 -#undef _WIN32 +# undef _WIN32 #endif + #ifdef __WIN32 -#undef __WIN32 +# undef __WIN32 #endif + #define PortableLockedShm ShmPosix #include "compat/compat.h" #include "compat/compat.cpp" diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx index 6d5484a99..e71026005 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx @@ -1,7 +1,11 @@ +#define OPENTRACK_COMPAT_BUNDLED + #ifndef __WIN32 #define __WIN32 #endif + #define PortableLockedShm ShmWine + #include "ftnoir_protocol_ft/fttypes.h" #include "compat/compat.h" #include "compat/compat.cpp" -- cgit v1.2.3 From af71f2534fc1e99ed7d483190e99d4dc674bcd76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:20:30 +0200 Subject: compat: new API, check for success --- compat/compat.cpp | 9 +++++++++ compat/compat.h | 1 + 2 files changed, 10 insertions(+) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index d8aac9bce..f62617381 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,6 +61,15 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } +PortableLockedShm::success() +{ +#ifndef _WIN32 + return (void*) mem != (void*) -1 +#else + return (void*) mem != NULL; +#endif +} + PortableLockedShm::~PortableLockedShm() { //(void) shm_unlink(shm_filename); diff --git a/compat/compat.h b/compat/compat.h index 3d54ae1db..8c307b149 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -37,6 +37,7 @@ public: ~PortableLockedShm(); void lock(); void unlock(); + bool success(); void* mem; private: #if defined(_WIN32) -- cgit v1.2.3 From a65e9de1d016dcf958753233113560008b629aff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:40:38 +0200 Subject: compat: fix build --- compat/compat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index f62617381..7d9f93579 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,10 +61,10 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } -PortableLockedShm::success() +bool PortableLockedShm::success() { #ifndef _WIN32 - return (void*) mem != (void*) -1 + return (void*) mem != (void*) -1; #else return (void*) mem != NULL; #endif -- cgit v1.2.3 From 017a906cde67e246655de5f95e7f4f27f0d8169f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:41:31 +0200 Subject: compat: fix win32 build --- compat/compat.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 7d9f93579..6d9298bb6 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,15 +61,6 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } -bool PortableLockedShm::success() -{ -#ifndef _WIN32 - return (void*) mem != (void*) -1; -#else - return (void*) mem != NULL; -#endif -} - PortableLockedShm::~PortableLockedShm() { //(void) shm_unlink(shm_filename); @@ -88,6 +79,13 @@ void PortableLockedShm::unlock() flock(fd, LOCK_UN); } +#endif - +bool PortableLockedShm::success() +{ +#ifndef _WIN32 + return (void*) mem != (void*) -1; +#else + return (void*) mem != NULL; #endif +} \ No newline at end of file -- cgit v1.2.3 From 73f1fd6553b9839473e034a402ee9b34737b2af7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 15:58:40 +0200 Subject: compat: pass -Wextra --- compat/compat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 6d9298bb6..808a8645e 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -44,7 +44,7 @@ void PortableLockedShm::unlock() } #else -PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, int mapSize) : size(mapSize) +PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { char shm_filename[NAME_MAX]; shm_filename[0] = '/'; -- cgit v1.2.3 From 864910a1fb753629d2852a91ffae4ebba374358c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:52:25 +0200 Subject: fix trackers for qt5 Assorted changes: - make filenames unique, since automoc made a boo-boo - adjust include paths, "QtGui" -> "" - use std::shared_ptr in c++11 mode (thanks Patrick!) - make class names unique, automoc sucks, but saves typing - add a dummy class in one file since moronic automoc thinks every target contains Q_OBJECTS!!! --- FTNoIR_Tracker_PT/boost-compat.h | 3 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 6 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 9 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 2 +- FTNoIR_Tracker_PT/pt_video_widget.cpp | 52 ++++++++ FTNoIR_Tracker_PT/pt_video_widget.h | 64 ++++++++++ FTNoIR_Tracker_PT/video_widget.cpp | 145 ----------------------- FTNoIR_Tracker_PT/video_widget.h | 95 --------------- compat/qt-bug-appeasement.cpp | 1 + facetracknoir/qt-moc.h | 10 ++ ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 1 + ftnoir_tracker_aruco/ar_video_widget.cpp | 30 +++++ ftnoir_tracker_aruco/ar_video_widget.h | 39 ++++++ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 5 +- ftnoir_tracker_aruco/video_widget.cpp | 30 ----- ftnoir_tracker_aruco/video_widget.h | 39 ------ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 4 +- ftnoir_tracker_ht/ht_video_widget.cpp | 30 +++++ ftnoir_tracker_ht/ht_video_widget.h | 39 ++++++ ftnoir_tracker_ht/video_widget.cpp | 30 ----- ftnoir_tracker_ht/video_widget.h | 39 ------ 23 files changed, 280 insertions(+), 397 deletions(-) create mode 100644 FTNoIR_Tracker_PT/pt_video_widget.cpp create mode 100644 FTNoIR_Tracker_PT/pt_video_widget.h delete mode 100644 FTNoIR_Tracker_PT/video_widget.cpp delete mode 100644 FTNoIR_Tracker_PT/video_widget.h create mode 100644 compat/qt-bug-appeasement.cpp create mode 100644 facetracknoir/qt-moc.h create mode 100644 ftnoir_tracker_aruco/ar_video_widget.cpp create mode 100644 ftnoir_tracker_aruco/ar_video_widget.h delete mode 100644 ftnoir_tracker_aruco/video_widget.cpp delete mode 100644 ftnoir_tracker_aruco/video_widget.h create mode 100644 ftnoir_tracker_ht/ht_video_widget.cpp create mode 100644 ftnoir_tracker_ht/ht_video_widget.h delete mode 100644 ftnoir_tracker_ht/video_widget.cpp delete mode 100644 ftnoir_tracker_ht/video_widget.h (limited to 'compat') diff --git a/FTNoIR_Tracker_PT/boost-compat.h b/FTNoIR_Tracker_PT/boost-compat.h index aea5e1a28..b5be237ab 100644 --- a/FTNoIR_Tracker_PT/boost-compat.h +++ b/FTNoIR_Tracker_PT/boost-compat.h @@ -1,6 +1,5 @@ #pragma once #include -#define shared_ptr auto_ptr namespace boost { - using std::auto_ptr; + using std::shared_ptr; }; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index d47411012..745d98e92 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -12,10 +12,6 @@ #include #include -#ifdef OPENTRACK_API -# define VideoWidget VideoWidget2 -#endif - using namespace std; using namespace cv; using namespace boost; @@ -192,7 +188,7 @@ void Tracker::update_show_video_widget() { const int VIDEO_FRAME_WIDTH = 252; const int VIDEO_FRAME_HEIGHT = 189; - video_widget = new VideoWidget(video_frame, this); + video_widget = new PTVideoWidget(video_frame, this); QHBoxLayout* video_layout = new QHBoxLayout(); video_layout->setContentsMargins(0, 0, 0, 0); video_layout->addWidget(video_widget); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 7dcfc8bb3..2430f5f05 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -11,15 +11,13 @@ #ifdef OPENTRACK_API # include "ftnoir_tracker_base/ftnoir_tracker_base.h" # include "facetracknoir/global-settings.h" -#else -# include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" #endif #include "ftnoir_tracker_pt_settings.h" #include "frame_observer.h" #include "camera.h" #include "point_extractor.h" #include "point_tracker.h" -#include "video_widget.h" +#include "pt_video_widget.h" #include "timer.h" #include @@ -82,7 +80,6 @@ protected: // --- tracking chain --- #ifdef OPENTRACK_API -#define VideoWidget VideoWidget2 CVCamera camera; #else VICamera camera; @@ -101,7 +98,9 @@ protected: void update_show_video_widget(); bool show_video_widget; - VideoWidget* video_widget; +#ifdef OPENTRACK_API + PTVideoWidget* video_widget; +#endif QFrame* video_frame; // --- misc --- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index 14df7ede7..3e1af50a3 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -16,7 +16,7 @@ #include "ftnoir_tracker_pt_settings.h" #include "ftnoir_tracker_pt.h" #include "trans_calib.h" -#include "video_widget.h" +#include "pt_video_widget.h" #include "ui_FTNoIR_PT_Controls.h" #include diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp new file mode 100644 index 000000000..03c42fc77 --- /dev/null +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -0,0 +1,52 @@ +/* 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. + * + * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. + */ + +#include "pt_video_widget.h" + +#include +#include + +using namespace cv; +using namespace std; + +void PTVideoWidget::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); +} + +// ---------------------------------------------------------------------------- +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 PTVideoWidget(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); +} diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h new file mode 100644 index 000000000..e67e6d57c --- /dev/null +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -0,0 +1,64 @@ +/* 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. + */ + +#pragma once + +#include "frame_observer.h" +#include +#include +#include +#include +#ifndef OPENTRACK_API +# include +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +# if defined(_WIN32) +# include +# endif +#endif +#include +#include +#include + +class PTVideoWidget : public QWidget, public FrameObserver +{ + Q_OBJECT + +public: + PTVideoWidget(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; +}; + +// ---------------------------------------------------------------------------- +// A VideoWidget embedded in a dialog frame +class VideoWidgetDialog : public QDialog +{ + Q_OBJECT +public: + VideoWidgetDialog(QWidget *parent, FrameProvider* provider); + virtual ~VideoWidgetDialog() {} + + PTVideoWidget* get_video_widget() { return video_widget; } + +private: + PTVideoWidget* video_widget; +}; diff --git a/FTNoIR_Tracker_PT/video_widget.cpp b/FTNoIR_Tracker_PT/video_widget.cpp deleted file mode 100644 index 0d31620f6..000000000 --- a/FTNoIR_Tracker_PT/video_widget.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* 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. - * - * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. - */ - -#include "video_widget.h" - -#include -#include - -using namespace cv; -using namespace std; -#ifndef OPENTRACK_API -using namespace boost; -#endif -#ifndef OPENTRACK_API -// ---------------------------------------------------------------------------- -void VideoWidget::initializeGL() -{ - 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(); - glDisable(GL_DEPTH_TEST); - glBegin(GL_QUADS); - glVertex2f(0,0); - glVertex2f(1,0); - glVertex2f(1,1); - glVertex2f(0,1); - glEnd(); -} - -void VideoWidget::paintGL() -{ - glClear(GL_COLOR_BUFFER_BIT); - if (!resized_qframe.isNull()) - { - glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGBA, GL_UNSIGNED_BYTE, resized_qframe.bits()); - - const int crosshair_radius = 10; - const int crosshair_thickness = 1; - - if (points) - { - glColor3f(1.0, 0.0, 0.0); - glLineWidth(crosshair_thickness); - int x,y; - for (vector::iterator iter = points->begin(); - iter != points->end(); - ++iter) - { - x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5; - y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5; - - glBegin(GL_LINES); - glVertex2i(x-crosshair_radius, y); - glVertex2i(x+crosshair_radius, y); - glEnd(); - glBegin(GL_LINES); - glVertex2i(x, y-crosshair_radius); - glVertex2i(x, y+crosshair_radius); - glEnd(); - } - } - } - glFlush(); -} - - -void VideoWidget::resize_frame() -{ - if (!qframe.isNull()) - resized_qframe = qframe.scaled(this->size(), Qt::KeepAspectRatio); -} - - -void VideoWidget::update_frame_and_points() -{ - if (!get_frame_and_points(frame, points)) return; - - // convert to QImage - if (frame.channels() == 3) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped(); - else if (frame.channels() == 1) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_Indexed8); - qframe = QGLWidget::convertToGLFormat(qframe); - - resize_frame(); - 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) -{ - 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); -} diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h deleted file mode 100644 index 3164dacc0..000000000 --- a/FTNoIR_Tracker_PT/video_widget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* 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. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include "frame_observer.h" - -#include -#include -#include -#ifndef OPENTRACK_API -# include -# include -#else -# include "FTNoIR_Tracker_PT/boost-compat.h" -# if defined(_WIN32) -# include -# endif -#endif -#include -#include -#include - -#ifndef OPENTRACK_API -// ---------------------------------------------------------------------------- -// OpenGL based widget to display an OpenCV image with some points on top -class VideoWidget : public QGLWidget, public FrameObserver -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {} - - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - - void update_frame_and_points(); - -private: - void resize_frame(); - - cv::Mat frame; - QImage qframe; - QImage resized_qframe; - - boost::shared_ptr< std::vector > 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() {} - - VideoWidget2* get_video_widget() { return video_widget; } - -private: - VideoWidget2* video_widget; -}; - -#endif // VIDEOWIDGET_H diff --git a/compat/qt-bug-appeasement.cpp b/compat/qt-bug-appeasement.cpp new file mode 100644 index 000000000..9a86ac0a2 --- /dev/null +++ b/compat/qt-bug-appeasement.cpp @@ -0,0 +1 @@ +#include "facetracknoir/qt-moc.h" diff --git a/facetracknoir/qt-moc.h b/facetracknoir/qt-moc.h new file mode 100644 index 000000000..467370f96 --- /dev/null +++ b/facetracknoir/qt-moc.h @@ -0,0 +1,10 @@ +#include + +// this file exists only such that cmake qt automoc is appeased + +class AutomocMe { + Q_OBJECT +private: + virtual void foo() = 0; + AutomocMe() = delete; +}; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index f479ce76f..cefc9bf8e 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -26,6 +26,7 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #include "ftnoir_protocol_fg.h" +#include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp new file mode 100644 index 000000000..6a4572a01 --- /dev/null +++ b/ftnoir_tracker_aruco/ar_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 "ar_video_widget.h" + +#include + +using namespace std; + +void ArucoVideoWidget::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); +} diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h new file mode 100644 index 000000000..dd0c16ac3 --- /dev/null +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -0,0 +1,39 @@ +/* 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. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class ArucoVideoWidget : public QWidget +{ + Q_OBJECT + +public: + ArucoVideoWidget(QWidget *parent) : QWidget(parent), mtx() { + } + void update_image(unsigned char* frame, int width, int height); +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 8025e9568..c735b479e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -148,7 +148,7 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { videoframe->show(); - videoWidget = new VideoWidget(videoframe); + videoWidget = new ArucoVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(videoWidget); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 98aba2cfe..ddbdd179a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -10,12 +10,13 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_aruco-trackercontrols.h" -#include "video_widget.h" +#include "ar_video_widget.h" #include #include #include #include #include +#include #include class Tracker : public QThread, public ITracker @@ -31,7 +32,7 @@ public: private: QMutex mtx; QTimer timer; - VideoWidget* videoWidget; + ArucoVideoWidget* videoWidget; QHBoxLayout* layout; volatile bool fresh, stop; float fov; diff --git a/ftnoir_tracker_aruco/video_widget.cpp b/ftnoir_tracker_aruco/video_widget.cpp deleted file mode 100644 index 84cba6a38..000000000 --- a/ftnoir_tracker_aruco/video_widget.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 - -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); -} diff --git a/ftnoir_tracker_aruco/video_widget.h b/ftnoir_tracker_aruco/video_widget.h deleted file mode 100644 index 87b6278a6..000000000 --- a/ftnoir_tracker_aruco/video_widget.h +++ /dev/null @@ -1,39 +0,0 @@ -/* 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. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } - void update_image(unsigned char* frame, int width, int height); -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } -private: - QMutex mtx; - QPixmap pixmap; -}; - -#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 27817a0ca..b4fd03f6f 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -165,7 +165,7 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { videoframe->show(); - videoWidget = new VideoWidget(videoframe); + videoWidget = new HTVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(videoWidget); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 5b8eb5088..966074113 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -12,7 +12,7 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "headtracker-ftnoir.h" #include "ui_ht-trackercontrols.h" -#include "video_widget.h" +#include "ht_video_widget.h" #include "compat/compat.h" #include #include @@ -31,7 +31,7 @@ private: QTimer timer; PortableLockedShm lck_shm; QProcess subprocess; - VideoWidget* videoWidget; + HTVideoWidget* videoWidget; QHBoxLayout* layout; volatile bool fresh; private slots: diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp new file mode 100644 index 000000000..4d7d66a28 --- /dev/null +++ b/ftnoir_tracker_ht/ht_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 "ht_video_widget.h" + +#include + +using namespace std; + +void HTVideoWidget::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); +} diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h new file mode 100644 index 000000000..b1182d8b3 --- /dev/null +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -0,0 +1,39 @@ +/* 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. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class HTVideoWidget : public QWidget +{ + Q_OBJECT + +public: + HTVideoWidget(QWidget *parent) : QWidget(parent), mtx() { + } + void update_image(unsigned char* frame, int width, int height); +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_ht/video_widget.cpp b/ftnoir_tracker_ht/video_widget.cpp deleted file mode 100644 index 84cba6a38..000000000 --- a/ftnoir_tracker_ht/video_widget.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* 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 - -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); -} diff --git a/ftnoir_tracker_ht/video_widget.h b/ftnoir_tracker_ht/video_widget.h deleted file mode 100644 index 87b6278a6..000000000 --- a/ftnoir_tracker_ht/video_widget.h +++ /dev/null @@ -1,39 +0,0 @@ -/* 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. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } - void update_image(unsigned char* frame, int width, int height); -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } -private: - QMutex mtx; - QPixmap pixmap; -}; - -#endif // VIDEOWIDGET_H -- cgit v1.2.3 From 1284ea867254229e008d2b7bfea37194334036f5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:20:20 +0100 Subject: compat: specify MAP_ANON Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 808a8645e..1b5308901 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -56,7 +56,7 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexNam fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); if (ftruncate(fd, mapSize) == 0) - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); else mem = (void*) -1; } @@ -88,4 +88,4 @@ bool PortableLockedShm::success() #else return (void*) mem != NULL; #endif -} \ No newline at end of file +} -- cgit v1.2.3 From 7e06aaff52974d2dc8035bfb986c42bc8ee9cfa2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:25:06 +0100 Subject: fix compat on macosx Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 1b5308901..8ac872d1a 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -6,6 +6,8 @@ */ #define IN_FTNOIR_COMPAT #include "compat.h" +#include +#include #if defined(_WIN32) @@ -46,19 +48,18 @@ void PortableLockedShm::unlock() #else PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - char shm_filename[NAME_MAX]; - shm_filename[0] = '/'; - strncpy(shm_filename+1, shmName, NAME_MAX-2); - sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); - shm_filename[NAME_MAX-1] = '\0'; - + std::string filename; + filename.append("/"); + filename.append(shmName); //(void) shm_unlink(shm_filename); - fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); - if (ftruncate(fd, mapSize) == 0) - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); - else - mem = (void*) -1; + fd = shm_open(filename.c_str(), O_RDWR | O_CREAT, 0600); + if (ftruncate(fd, mapSize) == 0) { ;; } + else { + fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); + //mem = (void*) -1; + } + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); } PortableLockedShm::~PortableLockedShm() -- cgit v1.2.3 From 76aa43c9c4b9339fafae1b987da29d21d846a7e1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:31:17 +0100 Subject: really fix mac this time Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compat') diff --git a/compat/compat.cpp b/compat/compat.cpp index 8ac872d1a..bcdbd17fa 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -59,7 +59,7 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexNam fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); //mem = (void*) -1; } - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); } PortableLockedShm::~PortableLockedShm() -- cgit v1.2.3 From bbaefce3a90b3c45f23e494f76ed15fa9a00d5e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 21:34:49 +0100 Subject: fix apple build --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- compat/compat.cpp | 19 ++++++------------- compat/compat.h | 3 ++- facetracknoir/main.cpp | 6 ++++++ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 18 +++++++++--------- 5 files changed, 45 insertions(+), 32 deletions(-) (limited to 'compat') diff --git a/CMakeLists.txt b/CMakeLists.txt index d17279c24..242d200d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if(GIT_FOUND) endif() SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") @@ -23,8 +23,12 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_definitions(-std=c++11) +if(NOT APPLE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-std=c++11) + endif() +else() + set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS}") endif() if(CMAKE_COMPILER_IS_GNUCXX) @@ -92,7 +96,7 @@ endif() find_package(OpenCV REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) - cmake_policy(SET CMP0020 NEW) + cmake_policy(SET CMP0020 NEW) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) @@ -328,9 +332,9 @@ if(SDK_XPLANE) PREFIX "" SUFFIX "") endif() if(APPLE) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin - COMPILE_FLAGS "-DAPL -DXPLM210 -framework XPLM -framework XPWidgets" - LINK_FLAGS "-framework XPLM -framework XPWidgets") + SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES + COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM210 -framework XPLM -framework XPWidgets" + LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") endif() if(UNIX AND NOT APPLE) target_link_libraries(opentrack-xplane-plugin rt) @@ -360,7 +364,12 @@ if(WIN32) set(my-qt-deps ws2_32) endif() -SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +if(APPLE) + link_directories(${CMAKE_INSTALL_PREFIX}) + set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${my-qt-deps}) +else() + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -470,6 +479,10 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() if(NOT SDK_WINE_NO_WRAPPER) + set(my-rt -lrt) + if(APPLE) + set(my-rt) + endif() add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -480,7 +493,7 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" - -lrt) + ${my-rt}) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() diff --git a/compat/compat.cpp b/compat/compat.cpp index bcdbd17fa..7b695617c 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -6,8 +6,7 @@ */ #define IN_FTNOIR_COMPAT #include "compat.h" -#include -#include +#include #if defined(_WIN32) @@ -48,17 +47,11 @@ void PortableLockedShm::unlock() #else PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - std::string filename; - filename.append("/"); - filename.append(shmName); - //(void) shm_unlink(shm_filename); - - fd = shm_open(filename.c_str(), O_RDWR | O_CREAT, 0600); - if (ftruncate(fd, mapSize) == 0) { ;; } - else { - fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); - //mem = (void*) -1; - } + char filename[512] = {0}; + strcpy(filename, "/"); + strcat(filename, shmName); + fd = shm_open(filename, O_RDWR | O_CREAT, 0600); + (void) ftruncate(fd, mapSize); mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); } diff --git a/compat/compat.h b/compat/compat.h index 8c307b149..60395830c 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,7 +7,8 @@ #pragma once #if defined(_WIN32) -#include +#include +#include #else #include #include diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index e643bcd35..23703ef34 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #if defined(_WIN32) && defined(_MSC_VER) # include @@ -59,6 +61,10 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); +#ifdef __APPLE__ + QDir dir(QCoreApplication::applicationDirPath()); + QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); +#endif FaceTrackNoIR w; QDesktopWidget desktop; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index db0ef6d63..77eede52b 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -62,7 +62,7 @@ static QList get_camera_names(void) { pEnumCat->Release(); } pSysDevEnum->Release(); -#else +#elsif !defined(__APPLE__) for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); @@ -281,15 +281,15 @@ TrackerControls::TrackerControls() { ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); - connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraName, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFPS, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ry, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ty, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); -- cgit v1.2.3 From 4630c59e40361ccb500d1384c1c611648462f93c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 18:19:05 +0100 Subject: fix mingw-w64 build --- compat/compat.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'compat') diff --git a/compat/compat.h b/compat/compat.h index 60395830c..8c307b149 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,8 +7,7 @@ #pragma once #if defined(_WIN32) -#include -#include +#include #else #include #include -- cgit v1.2.3 From 693e922e82914f6ea5e2184c5487af1e1b4881b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:38:53 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- compat/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compat') diff --git a/compat/compat.h b/compat/compat.h index 8c307b149..0e4887525 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -25,7 +25,7 @@ # elif defined(_WIN32) # define COMPAT_EXPORT __declspec(dllimport) # else -# define COMPAT_EXPORT +# define COMPAT_EXPORT __attribute__ ((visibility ("default"))) # endif #else # define COMPAT_EXPORT -- cgit v1.2.3