From 703e6d1d2b5c1abf334534477673ede40ecb1381 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 01:06:56 +0200 Subject: build kalman only with opencv --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a14b81f..56e035b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,7 +273,6 @@ set_target_properties(opentrack-version PROPERTIES opentrack_library(opentrack-filter-accela ftnoir_filter_accela) target_link_libraries(opentrack-filter-accela opentrack-spline-widget) -opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) opentrack_library(opentrack-filter-ewma ftnoir_filter_ewma2) opentrack_library(opentrack-proto-fgfs ftnoir_protocol_fg) @@ -368,6 +367,7 @@ if(OpenCV_FOUND) target_include_directories(opentrack-tracker-aruco SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) endif() + opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) target_include_directories(opentrack-filter-kalman SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) -- cgit v1.2.3 From 6e6a432a701e9a57fe0b03ca835a61f4206f2d5e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 17 Jul 2015 08:33:38 +0200 Subject: more obsolete #defines --- ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 1 - ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 1 - ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx | 1 - 3 files changed, 3 deletions(-) diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx index b5906675..78fa549b 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -8,7 +8,6 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; -#define OPENTRACK_COMPAT_BUNDLED #include "compat/compat.h" void create_registry_key(void); diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx index 010c4440..6f43f899 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx @@ -1,4 +1,3 @@ -#define OPENTRACK_COMPAT_BUNDLED #ifdef _WIN32 # undef _WIN32 #endif diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx index 5d19608a..6592fbe6 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx @@ -2,7 +2,6 @@ # error "bad cross" #endif -#define OPENTRACK_COMPAT_BUNDLED #define PortableLockedShm ShmWine #include "compat/compat.h" #include "compat/compat.cpp" -- cgit v1.2.3 From be0ae02edeaf8c4320c217844b2c7fd507447335 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 17 Jul 2015 09:44:50 +0200 Subject: bundles are now reloaded when settings window is closed This happens even if closed by alt+f4 or cancel button. --- CMakeLists.txt | 2 +- facetracknoir/ui.cpp | 18 ++++++++++-------- opentrack/plugin-api.hpp | 21 ++++++++++++++------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56e035b3..3a21730e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ macro(opentrack_library n dir) opentrack_module(${n} ${dir}) opentrack_qt(${n}) add_library(${n} SHARED ${${n}-all}) - target_link_libraries(${n} ${MY_QT_LIBS}) + target_link_libraries(${n} opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 88699810..86996735 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -358,12 +358,12 @@ void MainWindow::showHeadPose() } template -bool mk_dialog(mem lib, mem* orig) +bool mk_dialog(mem lib, mem& orig) { - if (*orig && (*orig)->isVisible()) + if (orig && orig->isVisible()) { - (*orig)->show(); - (*orig)->raise(); + orig->show(); + orig->raise(); return false; } @@ -373,10 +373,12 @@ bool mk_dialog(mem lib, mem* orig) dialog->setWindowFlags(Qt::Dialog); dialog->setFixedSize(dialog->size()); - *orig = dialog; + orig = dialog; dialog->show(); dialog->raise(); + QObject::connect(dialog.get(), &BaseDialog::closing, [&]() -> void { orig = nullptr; }); + return true; } @@ -385,17 +387,17 @@ bool mk_dialog(mem lib, mem* orig) void MainWindow::showTrackerSettings() { - if (mk_dialog(current_tracker(), &pTrackerDialog) && libs.pTracker) + if (mk_dialog(current_tracker(), pTrackerDialog) && libs.pTracker) pTrackerDialog->register_tracker(libs.pTracker.get()); } void MainWindow::showProtocolSettings() { - if (mk_dialog(current_protocol(), &pProtocolDialog) && libs.pProtocol) + if (mk_dialog(current_protocol(), pProtocolDialog) && libs.pProtocol) pProtocolDialog->register_protocol(libs.pProtocol.get()); } void MainWindow::showFilterSettings() { - if (mk_dialog(current_filter(), &pFilterDialog) && libs.pFilter) + if (mk_dialog(current_filter(), pFilterDialog) && libs.pFilter) pFilterDialog->register_filter(libs.pFilter.get()); } diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index 714e69d9..021f5017 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -2,6 +2,7 @@ #include "export.hpp" #include +#include #include #include @@ -9,6 +10,15 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; +class BaseDialog : public QWidget +{ + Q_OBJECT +public: + void closeEvent(QCloseEvent *) override { emit closing(); } +signals: + void closing(); +}; + #define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \ extern "C" OPENTRACK_EXPORT ctor_ret_class* GetConstructor() \ { \ @@ -24,9 +34,9 @@ enum Axis { } // implement this in all plugins +// also you must link against "opentrack-api" in CMakeList.txt to avoid vtable link errors struct Metadata { -public: // plugin name to be displayed in the interface virtual QString name() = 0; // plugin icon, you can return an empty QIcon() @@ -38,7 +48,6 @@ public: // implement this in filters struct IFilter { -public: // optional destructor virtual ~IFilter() {} // perform filtering step. @@ -46,7 +55,7 @@ public: virtual void filter(const double *input, double *output) = 0; }; -struct IFilterDialog : public QWidget +struct IFilterDialog : public BaseDialog { // optional destructor virtual ~IFilterDialog() {} @@ -63,7 +72,6 @@ struct IFilterDialog : public QWidget // implement this in protocols struct IProtocol { -public: // optional destructor virtual ~IProtocol() {} // return true if protocol was properly initialized @@ -75,7 +83,7 @@ public: virtual QString game_name() = 0; }; -struct IProtocolDialog : public QWidget +struct IProtocolDialog : public BaseDialog { // optional destructor virtual ~IProtocolDialog() {} @@ -92,7 +100,6 @@ struct IProtocolDialog : public QWidget // implement this in trackers struct ITracker { -public: // optional destructor virtual ~ITracker() {} // start tracking, and grab a frame to display webcam video in, optionally @@ -101,7 +108,7 @@ public: virtual void data(double *data) = 0; }; -struct ITrackerDialog : public QWidget +struct ITrackerDialog : public BaseDialog { // optional destructor virtual ~ITrackerDialog() {} -- cgit v1.2.3 From 1eddf33ed39627ef8584bd482b10bea42fb063f0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 17 Jul 2015 10:46:26 +0200 Subject: fix hatire icon --- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index e3c5a26b..2472428b 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -127,7 +127,7 @@ private: class TrackerDll : public Metadata { QString name() { return QString("Hatire Arduino"); } - QIcon icon() { return QIcon(":/images/hatire.png"); } + QIcon icon() { return QIcon(":/images/hat.png"); } }; #else class TrackerDll : -- cgit v1.2.3 From c17264187594d325030fac243b4bc8ed02e52358 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 17 Jul 2015 10:49:31 +0200 Subject: fix build --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a21730e..f8ce4378 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ macro(opentrack_library n dir) target_link_libraries(${n} opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES - LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" + LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden" ) else() @@ -365,6 +365,7 @@ if(OpenCV_FOUND) opentrack_library(opentrack-tracker-aruco ftnoir_tracker_aruco) target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) target_include_directories(opentrack-tracker-aruco SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) + link_with_dinput8(opentrack-tracker-aruco) endif() opentrack_library(opentrack-filter-kalman ftnoir_filter_kalman) @@ -373,9 +374,8 @@ if(OpenCV_FOUND) if(SDK_HT AND SDK_HT_FLANDMARK) opentrack_library(opentrack-tracker-ht ftnoir_tracker_ht) - target_link_libraries(opentrack-tracker-ht opentrack-compat ${SDK_HT} ${SDK_HT_FLANDMARK}) + target_link_libraries(opentrack-tracker-ht opentrack-compat ${SDK_HT} ${SDK_HT_FLANDMARK} ${OpenCV_LIBS}) link_with_dinput8(opentrack-tracker-ht) - target_link_libraries(opentrack-tracker-ht ${OpenCV_LIBS}) target_include_directories(opentrack-tracker-ht SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) endif() endif() -- cgit v1.2.3 From a0667e93d039451e80af646faa5008d27b78f85b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 01:52:51 +0200 Subject: initial version of macosx bundle script --- CMakeLists.txt | 7 +++++++ macosx/make-app-bundle.sh | 35 ++++++++++++++++++++++++++++++++ macosx/opentrack.app/Contents/Info.plist | 26 ++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 macosx/make-app-bundle.sh create mode 100644 macosx/opentrack.app/Contents/Info.plist diff --git a/CMakeLists.txt b/CMakeLists.txt index f8ce4378..1e9fd3c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,6 +352,13 @@ if(SDK_WINE_PREFIX) endif() endif() +if(APPLE) + install(SCRIPT " +execute_process(COMMAND /bin/sh \"\${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" + \"\${CMAKE_SOURCE_DIR}/macosx\" \"\${CMAKE_INSTALL_PREFIX}\" \"\${CMAKE_BUILD_DIR}\" \"${OPENTRACK__COMMIT}\") +") +endif() + opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh new file mode 100644 index 00000000..390f7af1 --- /dev/null +++ b/macosx/make-app-bundle.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +APPNAME=opentrack + +dir="$1" +test -n "$dir" || exit 1 +install="$1" +test -n "$install" || exit 1 +output_dir="$3" +test -n "$output_dir" || exit 1 +version="$4" +test -n "$version" || exit 1 + +tmp="$(mktemp -d "/tmp/$APPNAME-tmp.XXXXXXX")" +test $? -eq 0 || exit 1 + +cp -R "$dir/opentrack.app" "$tmp" || exit 1 +cp -R "$install/"* "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 +sed -i -e "s#@OPENTRACK-VERSION@#$version#g" "$tmp/$APPNAME.app/Contents/Info.plist" || exit 1 + +rm -rf "$tmp/$APPNAME.iconset" +mkdir "$tmp/$APPNAME.iconset" + +sips -z 16 16 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 +sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 +sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32.png" || exit 1 +sips -z 64 64 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_32x32@2x.png" || exit 1 +sips -z 128 128 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_128x128.png" || exit 1 + +iconutil -c icns -o "$tmp/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$APPNAME.iconset" +rm -r "$tmp/$APPNAME.iconset" + +cd "$tmp" || exit 1 +zip -9 "$output_dir/$APPNAME-$version.zip" "$APPNAME.app" || exit 1 +ls -lh "$output_dir/$APPNAME-$version.zip" \ No newline at end of file diff --git a/macosx/opentrack.app/Contents/Info.plist b/macosx/opentrack.app/Contents/Info.plist new file mode 100644 index 00000000..60791ba9 --- /dev/null +++ b/macosx/opentrack.app/Contents/Info.plist @@ -0,0 +1,26 @@ + +!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + + + CFBundleGetInfoString + @OPENTRACK-VERSION@ + CFBundleExecutable + opentrack.bin + CFBundleIdentifier + com.github.opentrack + CFBundleName + opentrack + CFBundleIconFile + opentrack.icns + CFBundleShortVersionString + 0.01 + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + IFMajorVersion + 0 + IFMinorVersion + 1 + + \ No newline at end of file -- cgit v1.2.3 From 180e6f6686c627f342ca282e75d3a9e784f16e52 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 01:53:00 +0200 Subject: octopus 127x128 -> 128x128 --- facetracknoir/images/facetracknoir.png | Bin 26466 -> 29485 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/facetracknoir/images/facetracknoir.png b/facetracknoir/images/facetracknoir.png index 41b54524..85c06df6 100644 Binary files a/facetracknoir/images/facetracknoir.png and b/facetracknoir/images/facetracknoir.png differ -- cgit v1.2.3 From 8a880f36939c28adaf3835565d194174032dc577 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 02:00:50 +0200 Subject: typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e9fd3c8..a99bd148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,7 +353,7 @@ if(SDK_WINE_PREFIX) endif() if(APPLE) - install(SCRIPT " + install(CODE " execute_process(COMMAND /bin/sh \"\${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" \"\${CMAKE_SOURCE_DIR}/macosx\" \"\${CMAKE_INSTALL_PREFIX}\" \"\${CMAKE_BUILD_DIR}\" \"${OPENTRACK__COMMIT}\") ") -- cgit v1.2.3 From f8df8356e01259da4dd4082cfeec08fb49f940f9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 02:02:34 +0200 Subject: oops #2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a99bd148..ece3165b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,7 +355,7 @@ endif() if(APPLE) install(CODE " execute_process(COMMAND /bin/sh \"\${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" - \"\${CMAKE_SOURCE_DIR}/macosx\" \"\${CMAKE_INSTALL_PREFIX}\" \"\${CMAKE_BUILD_DIR}\" \"${OPENTRACK__COMMIT}\") + \"\${CMAKE_SOURCE_DIR}/macosx\" \"\${CMAKE_INSTALL_PREFIX}\" \"\${CMAKE_BUILD_DIR}\" \"\${OPENTRACK__COMMIT}\") ") endif() -- cgit v1.2.3 From be325aa56c745720a6a5e8bbc966b0b79c591a9b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jul 2015 02:15:39 +0200 Subject: reduce Accela max slider value no one needs that much. --- ftnoir_filter_accela/ftnoir_filter_accela.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 766bc69e..177e5866 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -12,11 +12,11 @@ using namespace options; struct settings_accela : opts { value rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone; - static constexpr double mult_rot = 10. / 100.; - static constexpr double mult_trans = 5. / 100.; + static constexpr double mult_rot = 4. / 100.; + static constexpr double mult_trans = 4. / 100.; static constexpr double mult_rot_dz = 2. / 100.; - static constexpr double mult_trans_dz = 1. / 100.; - static constexpr double mult_ewma = 2.; + static constexpr double mult_trans_dz = 2. / 100.; + static constexpr double mult_ewma = 1.25; settings_accela() : opts("Accela"), rot_threshold(b, "rotation-threshold", 30), -- cgit v1.2.3 From 64a6892e8713c69e1f5ade929ec8035146de3f56 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 00:53:39 +0200 Subject: don't set thread affinity for anything Fixes #174 --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 3 -- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 3 -- opentrack/thread.hpp | 45 --------------------------- opentrack/tracker.cpp | 3 -- 4 files changed, 54 deletions(-) delete mode 100644 opentrack/thread.hpp diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index f7e283f3..c0ce1f22 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -17,7 +17,6 @@ #include #include #include "opentrack/camera-names.hpp" -#include "opentrack/thread.hpp" #include "opentrack/opencv-calibration.hpp" typedef struct { @@ -76,8 +75,6 @@ void Tracker::getRT(cv::Matx33d& r_, cv::Vec3d& t_) void Tracker::run() { - Affinity thr; - int rint = s.resolution; if (rint < 0 || rint >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) rint = 0; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 85ce0ad2..8ccfe2c4 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -11,7 +11,6 @@ #include #include #include -#include "opentrack/thread.hpp" #include "opentrack/camera-names.hpp" using namespace std; @@ -70,8 +69,6 @@ void Tracker_PT::run() QTextStream log_stream(&log_file); #endif - Affinity thr; - while((commands & ABORT) == 0) { const double dt = time.elapsed() * 1e-9; diff --git a/opentrack/thread.hpp b/opentrack/thread.hpp deleted file mode 100644 index 946f2972..00000000 --- a/opentrack/thread.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2014-2015, Stanislaw Halik - - * 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 - -enum { - CORE_WORK = 1, - CORE_IPC = 0, -}; - -#ifdef _WIN32 -#include - -class Affinity { -public: - Affinity(int core = CORE_WORK) - { - DWORD_PTR ret = SetThreadAffinityMask(GetCurrentThread(), 1 << core); - if (ret == 0) - qDebug() << "SetThreadAffinityMask" << GetLastError(); - last = ret; - } - ~Affinity() - { - if (last) - (void) SetThreadAffinityMask(GetCurrentThread(), last); - } -private: - DWORD_PTR last; -}; - -#else -class Affinity { -public: - Affinity(int core = CORE_WORK) {} - ~Affinity() {} -}; -#endif diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index fae0e8a2..1ab350d5 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -14,7 +14,6 @@ #include "tracker.h" -#include "opentrack/thread.hpp" #include #include @@ -181,8 +180,6 @@ void Tracker::logic() void Tracker::run() { const int sleep_ms = 3; - Affinity thr(CORE_IPC); - #if defined(_WIN32) (void) timeBeginPeriod(1); #endif -- cgit v1.2.3 From 84044ec3f6fe9ea90f3601b880d96be989fb7d79 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 11:11:13 +0200 Subject: fix osx, app bundle now builds --- CMakeLists.txt | 24 ++++++++++----------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 6 ++++++ ftnoir_filter_kalman/kalman.cpp | 2 ++ .../opentrack-wrapper-wine-main.cxx | 4 ++++ ftnoir_protocol_wine/wine-shm.h | 5 +++++ install-fail-tool | 19 ---------------- macosx/install-fail-tool | 25 ++++++++++++++++++++++ macosx/make-app-bundle.sh | 22 ++++++++++++------- macosx/opentrack.app/Contents/Info.plist | 20 ++++++++--------- macosx/opentrack.app/Contents/PkgInfo | 1 + macosx/qt.conf | 2 ++ opentrack/simple-mat.hpp | 4 ++-- pose-widget/glwidget.cpp | 4 ++-- qfunctionconfigurator/functionconfig.cpp | 3 ++- 14 files changed, 86 insertions(+), 55 deletions(-) delete mode 100755 install-fail-tool create mode 100755 macosx/install-fail-tool create mode 100644 macosx/opentrack.app/Contents/PkgInfo create mode 100644 macosx/qt.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index ece3165b..b74ec7f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,11 +61,13 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) endif() if(APPLE) + set(CMAKE_MACOSX_RPATH OFF) set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") + #set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}") endif() if(CMAKE_COMPILER_IS_GNUCXX OR APPLE) @@ -340,11 +342,9 @@ if(SDK_WINE_PREFIX) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS ${wine-deps} - COMMAND ${SDK_WINE_PREFIX}/bin/wineg++ -g -O2 -m32 -std=c++11 -o + COMMAND ${SDK_WINE_PREFIX}/bin/wineg++ -g -DNOMINMAX -O2 -m32 -std=c++11 -o opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" - ${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 + ${wine-deps} ${my-rt}) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) add_dependencies(opentrack-proto-wine wine-wrapper) @@ -352,13 +352,6 @@ if(SDK_WINE_PREFIX) endif() endif() -if(APPLE) - install(CODE " -execute_process(COMMAND /bin/sh \"\${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" - \"\${CMAKE_SOURCE_DIR}/macosx\" \"\${CMAKE_INSTALL_PREFIX}\" \"\${CMAKE_BUILD_DIR}\" \"\${OPENTRACK__COMMIT}\") -") -endif() - opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) @@ -552,7 +545,12 @@ endif() install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/camera" DESTINATION .) if(APPLE) + install(FILES "${CMAKE_SOURCE_DIR}/macosx/qt.conf" DESTINATION .) install(CODE " - execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/install-fail-tool\" \"${CMAKE_INSTALL_PREFIX}\") + execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" + \"${CMAKE_SOURCE_DIR}/macosx\" + \"${CMAKE_INSTALL_PREFIX}\" + \"${CMAKE_BINARY_DIR}\" + \"${OPENTRACK__COMMIT}\") ") endif() diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index c4b329e1..f8bd2ab1 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -37,6 +37,12 @@ static constexpr double trans_gains[][2] = { { -1, 0 } }; +constexpr double settings_accela::mult_rot; +constexpr double settings_accela::mult_trans; +constexpr double settings_accela::mult_rot_dz; +constexpr double settings_accela::mult_trans_dz; +constexpr double settings_accela::mult_ewma; + FTNoIR_Filter::FTNoIR_Filter() : first_run(true) { rot.setMaxInput(rot_gains[0][0]); diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index f0b9e261..39a08703 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -9,6 +9,8 @@ #include #include +constexpr double settings::mult_noise_stddev; + FTNoIR_Filter::FTNoIR_Filter() { reset(); prev_slider_pos = s.noise_stddev_slider; diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx index 78fa549b..026135f0 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -1,4 +1,8 @@ #include +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif #include #include "freetrackclient/fttypes.h" #include "ftnoir_protocol_wine/wine-shm.h" diff --git a/ftnoir_protocol_wine/wine-shm.h b/ftnoir_protocol_wine/wine-shm.h index c0f29cd3..c7e29abb 100644 --- a/ftnoir_protocol_wine/wine-shm.h +++ b/ftnoir_protocol_wine/wine-shm.h @@ -3,6 +3,11 @@ #define WINE_SHM_NAME "facetracknoir-wine-shm" #define WINE_MTX_NAME "facetracknoir-wine-mtx" +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif + #include template using ptr = std::shared_ptr; diff --git a/install-fail-tool b/install-fail-tool deleted file mode 100755 index 99f8fbdf..00000000 --- a/install-fail-tool +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -test -n "$1" || exit 1 - -dir="$1" - -for i in "$dir"/* "$dir"/*/*; do - { test -x "$i" && test -f "$i"; } || continue - echo ---- $i ---- - install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" - - otool -L "$i" | awk '{ print $1 }' | - while read l; do - j="$(basename -- "$l")" - if test -e "$dir/$j"; then - install_name_tool -change "$l" "@executable_path/$j" "$i" - fi - done -done diff --git a/macosx/install-fail-tool b/macosx/install-fail-tool new file mode 100755 index 00000000..0f34c3a1 --- /dev/null +++ b/macosx/install-fail-tool @@ -0,0 +1,25 @@ +#!/bin/sh + +test -n "$1" || exit 1 + +dir="$1" + +for i in "$dir"/* "$dir"/*/*; do + { test -x "$i" && test -f "$i"; } || continue + case "$i" in + *.dll|*.exe) continue ;; + *) : ;; + esac + case "$i" in + *.dylib|*.bin) strip -x "$i" ;; esac + echo ---- $i ---- + install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" + + otool -L "$i" | awk '{ print $1 }' | + while read l; do + j="$(basename -- "$l")" + if test -e "$dir/$j"; then + install_name_tool -change "$l" "@executable_path/$j" "$i" + fi + done +done diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh index 390f7af1..7e79d6db 100644 --- a/macosx/make-app-bundle.sh +++ b/macosx/make-app-bundle.sh @@ -4,7 +4,7 @@ APPNAME=opentrack dir="$1" test -n "$dir" || exit 1 -install="$1" +install="$2" test -n "$install" || exit 1 output_dir="$3" test -n "$output_dir" || exit 1 @@ -14,12 +14,16 @@ test -n "$version" || exit 1 tmp="$(mktemp -d "/tmp/$APPNAME-tmp.XXXXXXX")" test $? -eq 0 || exit 1 -cp -R "$dir/opentrack.app" "$tmp" || exit 1 -cp -R "$install/"* "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 -sed -i -e "s#@OPENTRACK-VERSION@#$version#g" "$tmp/$APPNAME.app/Contents/Info.plist" || exit 1 +"$dir/install-fail-tool" "$install" -rm -rf "$tmp/$APPNAME.iconset" -mkdir "$tmp/$APPNAME.iconset" +cp -R "$dir/opentrack.app" "$tmp/" || exit 1 +cp -R "$install" "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 +sed -i '' -e "s#@OPENTRACK-VERSION@#$version#g" "$tmp/$APPNAME.app/Contents/Info.plist" || exit 1 + +#cp "$dir/qt.conf" "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 + +mkdir "$tmp/$APPNAME.iconset" || exit 1 +mkdir "$tmp/$APPNAME.app/Contents/Resources" || exit 1 sips -z 16 16 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 @@ -31,5 +35,7 @@ iconutil -c icns -o "$tmp/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$ rm -r "$tmp/$APPNAME.iconset" cd "$tmp" || exit 1 -zip -9 "$output_dir/$APPNAME-$version.zip" "$APPNAME.app" || exit 1 -ls -lh "$output_dir/$APPNAME-$version.zip" \ No newline at end of file +rm -f "$output_dir/$APPNAME-$version.zip" +zip -9r "$output_dir/$APPNAME-$version.zip" "$APPNAME.app" || exit 1 +rm -rf "$tmp" +ls -lh "$output_dir/$APPNAME-$version.zip" diff --git a/macosx/opentrack.app/Contents/Info.plist b/macosx/opentrack.app/Contents/Info.plist index 60791ba9..ed4b0b05 100644 --- a/macosx/opentrack.app/Contents/Info.plist +++ b/macosx/opentrack.app/Contents/Info.plist @@ -1,9 +1,9 @@ -!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> + - CFBundleGetInfoString - @OPENTRACK-VERSION@ + CFBundleDevelopmentRegion + en CFBundleExecutable opentrack.bin CFBundleIdentifier @@ -12,15 +12,15 @@ opentrack CFBundleIconFile opentrack.icns - CFBundleShortVersionString - 0.01 + CFBundleVersion + @OPENTRACK-VERSION@ CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType APPL - IFMajorVersion - 0 - IFMinorVersion - 1 + CFBundleDisplayName + opentrack + CFBundleSignature + ???? - \ No newline at end of file + diff --git a/macosx/opentrack.app/Contents/PkgInfo b/macosx/opentrack.app/Contents/PkgInfo new file mode 100644 index 00000000..b18f8c6c --- /dev/null +++ b/macosx/opentrack.app/Contents/PkgInfo @@ -0,0 +1 @@ +APPLopentrack diff --git a/macosx/qt.conf b/macosx/qt.conf new file mode 100644 index 00000000..e69f24eb --- /dev/null +++ b/macosx/qt.conf @@ -0,0 +1,2 @@ +[Paths] +Plugins = . diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index e111305a..7432e665 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -107,7 +107,7 @@ struct Mat { Mat ret; for (int j = 0; j < h_; j++) - for (int i = 0; i < w; i++) + for (int i = 0; i < w_; i++) ret(j, i) = this->operator ()(j, i) + other(j, i); return ret; } @@ -125,7 +125,7 @@ struct Mat { Mat ret; for (int j = 0; j < h_; j++) - for (int i = 0; i < w; i++) + for (int i = 0; i < w_; i++) ret(j, i) = this->operator ()(j, i) + other; return ret; } diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 66527a57..ed4560af 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -193,10 +193,10 @@ vec2 GLWidget::project(const vec3 &point) double z = std::max(.75, 1. + translation.z()/-60.); int w = width(), h = height(); double x = w * translation.x() / 2. / -40.; - if (abs(x) > w/2) + if (std::abs(x) > w/2) x = x > 0 ? w/2 : w/-2; double y = h * translation.y() / 2. / -40.; - if (abs(y) > h/2) + if (std::abs(y) > h/2) y = y > 0 ? h/2 : h/-2; return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; } diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 7edbe0ef..264097ab 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -8,6 +8,7 @@ #include #include #include +#include void Map::setTrackingActive(bool blnActive) { @@ -43,7 +44,7 @@ bool Map::getLastPoint(QPointF& point ) { float Map::getValueInternal(int x) { float sign = x < 0 ? -1 : 1; - x = std::abs(x); + x = abs(x); float ret; int sz = cur.data.size(); if (sz == 0) -- cgit v1.2.3 From 3ad67aaa96be824dbcd2c9334dc709d7d4dec08e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 11:11:40 +0200 Subject: resize UI, looks better on OSX probably --- facetracknoir/main.ui | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui index 77a3ef3a..2328be40 100644 --- a/facetracknoir/main.ui +++ b/facetracknoir/main.ui @@ -964,6 +964,9 @@ 4 + + 3 + 2 @@ -1007,6 +1010,9 @@ 4 + + 3 + 2 @@ -1050,6 +1056,9 @@ 4 + + 3 + 2 @@ -1074,6 +1083,12 @@ + + + 0 + 0 + + Profile @@ -1099,7 +1114,7 @@ - + 0 0 @@ -1112,7 +1127,7 @@ - + 0 0 @@ -1144,7 +1159,7 @@ true - + 0 0 -- cgit v1.2.3 From 71d8892c19b6a1dbfac7d40a3bb6717316e872b9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 12:26:58 +0200 Subject: app bundle finally works --- CMakeLists.txt | 1 - macosx/install-fail-tool | 4 ++-- macosx/make-app-bundle.sh | 5 ++--- macosx/opentrack.app/Contents/Info.plist | 2 +- macosx/opentrack.sh | 4 ++++ macosx/qt.conf | 2 -- 6 files changed, 9 insertions(+), 9 deletions(-) mode change 100755 => 100644 macosx/install-fail-tool create mode 100755 macosx/opentrack.sh delete mode 100644 macosx/qt.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index b74ec7f4..3363f14e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,7 +545,6 @@ endif() install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/camera" DESTINATION .) if(APPLE) - install(FILES "${CMAKE_SOURCE_DIR}/macosx/qt.conf" DESTINATION .) install(CODE " execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" \"${CMAKE_SOURCE_DIR}/macosx\" diff --git a/macosx/install-fail-tool b/macosx/install-fail-tool old mode 100755 new mode 100644 index 0f34c3a1..a5464c18 --- a/macosx/install-fail-tool +++ b/macosx/install-fail-tool @@ -4,7 +4,7 @@ test -n "$1" || exit 1 dir="$1" -for i in "$dir"/* "$dir"/*/*; do +for i in "$dir"/* "$dir"/*/* "$dir"/*/*/*; do { test -x "$i" && test -f "$i"; } || continue case "$i" in *.dll|*.exe) continue ;; @@ -13,7 +13,7 @@ for i in "$dir"/* "$dir"/*/*; do case "$i" in *.dylib|*.bin) strip -x "$i" ;; esac echo ---- $i ---- - install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" + install_name_tool -id "@executable_path/$(echo "$i" | sed -e "s,^$dir/,,")" "$i" otool -L "$i" | awk '{ print $1 }' | while read l; do diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh index 7e79d6db..d0588ae2 100644 --- a/macosx/make-app-bundle.sh +++ b/macosx/make-app-bundle.sh @@ -14,16 +14,15 @@ test -n "$version" || exit 1 tmp="$(mktemp -d "/tmp/$APPNAME-tmp.XXXXXXX")" test $? -eq 0 || exit 1 -"$dir/install-fail-tool" "$install" +sh "$dir/install-fail-tool" "$install" cp -R "$dir/opentrack.app" "$tmp/" || exit 1 cp -R "$install" "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 sed -i '' -e "s#@OPENTRACK-VERSION@#$version#g" "$tmp/$APPNAME.app/Contents/Info.plist" || exit 1 -#cp "$dir/qt.conf" "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 - mkdir "$tmp/$APPNAME.iconset" || exit 1 mkdir "$tmp/$APPNAME.app/Contents/Resources" || exit 1 +cp "$dir"/opentrack.sh "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 sips -z 16 16 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 sips -z 32 32 "$dir/../facetracknoir/images/facetracknoir.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 diff --git a/macosx/opentrack.app/Contents/Info.plist b/macosx/opentrack.app/Contents/Info.plist index ed4b0b05..41ca402a 100644 --- a/macosx/opentrack.app/Contents/Info.plist +++ b/macosx/opentrack.app/Contents/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion en CFBundleExecutable - opentrack.bin + opentrack.sh CFBundleIdentifier com.github.opentrack CFBundleName diff --git a/macosx/opentrack.sh b/macosx/opentrack.sh new file mode 100755 index 00000000..62ad01a5 --- /dev/null +++ b/macosx/opentrack.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +dir="$(dirname -- "$0")" +exec "$dir"/opentrack.bin -platformpluginpath "$dir" "$@" diff --git a/macosx/qt.conf b/macosx/qt.conf deleted file mode 100644 index e69f24eb..00000000 --- a/macosx/qt.conf +++ /dev/null @@ -1,2 +0,0 @@ -[Paths] -Plugins = . -- cgit v1.2.3 From 13b76c2363e3fd11df30869f48f9b9ee517129cc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 12:53:11 +0200 Subject: grab Linux camera names --- opentrack/camera-names.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 6f82ba34..77945171 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -13,6 +13,12 @@ # include #endif +#ifdef __linux +#include +#include +#include +#endif + template QList get_camera_names() { QList ret; @@ -69,12 +75,23 @@ QList get_camera_names() { qDebug() << "failed CLSID_VideoInputDeviceCategory" << hr; pSysDevEnum->Release(); -#else +#endif +#ifdef __linux for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); if (access(buf, R_OK | W_OK) == 0) { - ret.append(buf); + int fd = open(buf, O_RDONLY); + if (fd == -1) + continue; + struct video_capability video_cap; + if(ioctl(fd, VIDIOCGCAP, &video_cap) == -1) + { + close(fd); + continue; + } + ret.append(video_cap.name); + close(fd); } else { continue; } -- cgit v1.2.3 From 9457c8c2c7e7bc6bf057cbb2e17b2e0f207db572 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 12:58:15 +0200 Subject: ensure camera name indices match We can't make spaces in indices or else wrong camera gets opened. --- opentrack/camera-names.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 77945171..d769a24f 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -80,6 +80,11 @@ QList get_camera_names() { for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); + if (access(buf, F_OK) == 0) + ret.append(""); + else + continue; + if (access(buf, R_OK | W_OK) == 0) { int fd = open(buf, O_RDONLY); if (fd == -1) @@ -90,7 +95,7 @@ QList get_camera_names() { close(fd); continue; } - ret.append(video_cap.name); + ret[ret.size()-1] = video_cap.name; close(fd); } else { continue; -- cgit v1.2.3 From 82b32622408090dd1c3716b58e292ec706e4fc57 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 13:11:31 +0200 Subject: append more useful name than empty string --- opentrack/camera-names.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index d769a24f..6e5bc8e7 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -81,7 +81,7 @@ QList get_camera_names() { char buf[128]; sprintf(buf, "/dev/video%d", i); if (access(buf, F_OK) == 0) - ret.append(""); + ret.append(buf); else continue; -- cgit v1.2.3 From 8339eb029f68840de30dfc6772848784781ff2f5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 13:11:51 +0200 Subject: cleanup flow --- opentrack/camera-names.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 6e5bc8e7..ee6d8ceb 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -97,8 +97,6 @@ QList get_camera_names() { } ret[ret.size()-1] = video_cap.name; close(fd); - } else { - continue; } } #endif -- cgit v1.2.3 From 04a72110203d70338849e47a24b12d6b13fdfed6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 13:31:22 +0200 Subject: camera names on linux work, finally --- opentrack/camera-names.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index ee6d8ceb..fd869e6b 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -16,7 +16,8 @@ #ifdef __linux #include #include -#include +#include +#include #endif template @@ -89,13 +90,14 @@ QList get_camera_names() { int fd = open(buf, O_RDONLY); if (fd == -1) continue; - struct video_capability video_cap; - if(ioctl(fd, VIDIOCGCAP, &video_cap) == -1) + struct v4l2_capability video_cap; + if(ioctl(fd, VIDIOC_QUERYCAP, &video_cap) == -1) { + qDebug() << "VIDIOC_QUERYCAP" << errno; close(fd); continue; } - ret[ret.size()-1] = video_cap.name; + ret[ret.size()-1] = reinterpret_cast(video_cap.card); close(fd); } } -- cgit v1.2.3 From f9e80bddaf66de5abf56a2e29c5ef4c6c5004c4c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 13:57:17 +0200 Subject: try to launch qv4l2 on Linux --- opentrack/opencv-camera-dialog.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp index 6218f125..6cfab0ab 100644 --- a/opentrack/opencv-camera-dialog.hpp +++ b/opentrack/opencv-camera-dialog.hpp @@ -6,9 +6,20 @@ #include #include "opentrack/camera-names.hpp" +#ifdef __linux +#include +#endif + template class camera_dialog { +#ifdef __linux + void open_camera_settings(cv::VideoCapture *, const QString &camera_name, QMutex *) + { + int idx = camera_name_to_index(camera_name); + QProcess::startDetached("qv4l2", QStringList() << "-d" << ("/dev/video" + QString::number(idx))); + } +#else cv::VideoCapture fake_capture; QTimer t; @@ -47,5 +58,6 @@ public: // HACK: we're not notified when it's safe to close the capture t.start(); } +#endif }; -- cgit v1.2.3 From 4332d0314165db508e1a5158350cdb34b688fef9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 14:01:32 +0200 Subject: fix build error --- opentrack/opencv-camera-dialog.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp index 6cfab0ab..cd3d38e7 100644 --- a/opentrack/opencv-camera-dialog.hpp +++ b/opentrack/opencv-camera-dialog.hpp @@ -14,6 +14,7 @@ template class camera_dialog { #ifdef __linux +public: void open_camera_settings(cv::VideoCapture *, const QString &camera_name, QMutex *) { int idx = camera_name_to_index(camera_name); -- cgit v1.2.3 From ffefa511b474ed594a6a5bf5589aeae028f0bed2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 15:52:48 +0200 Subject: ui: prevent clobbering current profile Previously "open" always took to the topmost profile. Fixes #194 --- facetracknoir/ui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 86996735..ac58cce8 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -111,8 +111,8 @@ void MainWindow::open() { dir_path, tr("Settings file (*.ini);;All Files (*)")); set_working_directory(); - - if (! fileName.isEmpty() ) { + + if (!fileName.isEmpty()) { { QSettings settings(OPENTRACK_ORG); settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); @@ -186,10 +186,10 @@ void MainWindow::fill_profile_combobox() { QStringList ini_list = group::ini_list(); set_title(); + QString current = QFileInfo(group::ini_pathname()).fileName(); ui.iconcomboProfile->clear(); for (auto x : ini_list) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); - QString current = QFileInfo(group::ini_pathname()).fileName(); ui.iconcomboProfile->setCurrentText(current); } -- cgit v1.2.3 From a8165591d993a23ae71ea4e5bb7df7596688ef7b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 16:38:43 +0200 Subject: reduce diff to trackhat --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3363f14e..1f0685ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,13 +104,17 @@ function(opentrack_compat target) endfunction() macro(opentrack_library n dir) - cmake_parse_arguments(foolib "" "LINK;COMPILE;GNU-LINK;GNU-COMPILE" "" ${ARGN}) + cmake_parse_arguments(foolib "" "LINK;COMPILE;GNU-LINK;GNU-COMPILE;STATIC" "" ${ARGN}) if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") message(FATAL_ERROR "opentrack_library bad formals") endif() opentrack_module(${n} ${dir}) opentrack_qt(${n}) - add_library(${n} SHARED ${${n}-all}) + set(link-mode SHARED) + if (foolib_STATIC) + set(link-mode STATIC) + endif() + add_library(${n} ${link-mode} ${${n}-all}) target_link_libraries(${n} opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES -- cgit v1.2.3