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. --- opentrack/plugin-api.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'opentrack') 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 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 (limited to 'opentrack') 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 (limited to 'opentrack') 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 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(-) (limited to 'opentrack') 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(-) (limited to 'opentrack') 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(-) (limited to 'opentrack') 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(-) (limited to 'opentrack') 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(-) (limited to 'opentrack') 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(+) (limited to 'opentrack') 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(+) (limited to 'opentrack') 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