diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-19 16:50:41 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-19 16:50:41 +0200 |
commit | 4da0c0619cbf052eb87a618aba4c8de79f0d4325 (patch) | |
tree | e075b2a2601d6d2f26a8a70fb83cb682cdfb23df | |
parent | f9b5b72cbcf9f121e0184f9a907bbffd7e1e16a9 (diff) | |
parent | a8165591d993a23ae71ea4e5bb7df7596688ef7b (diff) |
Merge branch 'unstable' into trackhat-ui
27 files changed, 193 insertions, 108 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6719f3b0..b19cdd1c 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) @@ -113,15 +115,15 @@ macro(opentrack_library n dir) set(link-mode STATIC) endif() add_library(${n} ${link-mode} ${${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(visibility "-fvisibility=hidden -fvisibility-inlines-hidden") if (foolib_STATIC) set(visibility) endif() SET_TARGET_PROPERTIES(${n} PROPERTIES - LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" - COMPILE_FLAGS "${foolib_COMPILE} ${foolib_GNU-COMPILE} ${visibility}" + 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() set(link-flags) @@ -350,11 +352,9 @@ if(SDK_WINE_PREFIX AND FALSE) 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) @@ -387,6 +387,7 @@ if(OpenCV_FOUND) #target_link_libraries(opentrack-tracker-ht ${OpenCV_LIBS}) #target_include_directories(opentrack-tracker-ht SYSTEM PUBLIC ${OpenCV_INCLUDE_DIRS}) #endif() + endif() #opentrack_library(opentrack-tracker-ht ftnoir_tracker_ht) @@ -563,6 +564,10 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/camera" DESTINATION .) if(APPLE) 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/facetracknoir/images/facetracknoir.png b/facetracknoir/images/facetracknoir.png Binary files differindex 41b54524..85c06df6 100644 --- a/facetracknoir/images/facetracknoir.png +++ b/facetracknoir/images/facetracknoir.png diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 4d74aa07..1d9f3702 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -101,8 +101,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)); @@ -176,10 +176,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); } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 9e1b2415..31534ad3 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_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 0116faea..d962d82f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -11,11 +11,11 @@ using namespace options; struct settings_accela : opts { value<int> 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), 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 <QDebug> #include <cmath> +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 b5906675..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 <cerrno> +// OSX sdk 10.8 build error otherwise +#ifdef _LIBCPP_MSVCRT +# undef _LIBCPP_MSVCRT +#endif #include <cstdio> #include "freetrackclient/fttypes.h" #include "ftnoir_protocol_wine/wine-shm.h" @@ -8,7 +12,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" 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 <memory> template<typename t> using ptr = std::shared_ptr<t>; 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 <opencv2/highgui/highgui.hpp> #include <opencv2/videoio.hpp> #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_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 : diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index a77d206a..474123d0 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -11,7 +11,6 @@ #include <QDebug> #include <QFile> #include <QCoreApplication> -#include "opentrack/thread.hpp" #include "opentrack/camera-names.hpp" using namespace std; @@ -83,8 +82,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/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 100644 index 00000000..a5464c18 --- /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"/*/* "$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/$(echo "$i" | sed -e "s,^$dir/,,")" "$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 new file mode 100644 index 00000000..f851fe77 --- /dev/null +++ b/macosx/make-app-bundle.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +APPNAME=trackhat-opentrack + +dir="$1" +test -n "$dir" || exit 1 +install="$2" +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 + +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 + +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 +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 +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 new file mode 100644 index 00000000..17e17735 --- /dev/null +++ b/macosx/opentrack.app/Contents/Info.plist @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>opentrack.sh</string> + <key>CFBundleIdentifier</key> + <string>com.github.opentrack.trackhat</string> + <key>CFBundleName</key> + <string>trackhat-opentrack</string> + <key>CFBundleIconFile</key> + <string>opentrack.icns</string> + <key>CFBundleVersion</key> + <string>@OPENTRACK-VERSION@</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleDisplayName</key> + <string>trackhat-opentrack</string> + <key>CFBundleSignature</key> + <string>????</string> +</dict> +</plist> 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/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/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 6f82ba34..fd869e6b 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -13,6 +13,13 @@ # include <unistd.h> #endif +#ifdef __linux +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/videodev2.h> +#include <cerrno> +#endif + template<typename = void> QList<QString> get_camera_names() { QList<QString> ret; @@ -69,14 +76,29 @@ QList<QString> 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) { + if (access(buf, F_OK) == 0) ret.append(buf); - } else { + else continue; + + if (access(buf, R_OK | W_OK) == 0) { + int fd = open(buf, O_RDONLY); + if (fd == -1) + continue; + struct v4l2_capability video_cap; + if(ioctl(fd, VIDIOC_QUERYCAP, &video_cap) == -1) + { + qDebug() << "VIDIOC_QUERYCAP" << errno; + close(fd); + continue; + } + ret[ret.size()-1] = reinterpret_cast<const char*>(video_cap.card); + close(fd); } } #endif diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp index 6218f125..cd3d38e7 100644 --- a/opentrack/opencv-camera-dialog.hpp +++ b/opentrack/opencv-camera-dialog.hpp @@ -6,9 +6,21 @@ #include <opencv2/videoio.hpp> #include "opentrack/camera-names.hpp" +#ifdef __linux +#include <QProcess> +#endif + template<typename tracker> 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); + QProcess::startDetached("qv4l2", QStringList() << "-d" << ("/dev/video" + QString::number(idx))); + } +#else cv::VideoCapture fake_capture; QTimer t; @@ -47,5 +59,6 @@ public: // HACK: we're not notified when it's safe to close the capture t.start(); } +#endif }; 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 <QString> +#include <QWidget> #include <QFrame> #include <QIcon> @@ -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() {} 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<num, h_, w_> 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<num, h_, w_> 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/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 <sthalik@misaki.pl> - - * 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 <QDebug> - -enum { - CORE_WORK = 1, - CORE_IPC = 0, -}; - -#ifdef _WIN32 -#include <windows.h> - -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 502f7a96..ce23afad 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -14,7 +14,6 @@ #include "tracker.h" -#include "opentrack/thread.hpp" #include <cmath> #include <algorithm> @@ -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 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 <QSettings> #include <QPixmap> #include <algorithm> +#include <cmath> 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) |