From 6468223986ede1b1b64581dd37fed11724788a2b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jul 2015 18:54:59 +0200 Subject: libs: validate protocol first before starting tracker --- opentrack/selected-libraries.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'opentrack') diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp index 8cb226c8..7617ce90 100644 --- a/opentrack/selected-libraries.cpp +++ b/opentrack/selected-libraries.cpp @@ -20,19 +20,27 @@ SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dyli pProtocol(nullptr), correct(false) { - pTracker = make_instance(t); pProtocol = make_instance(p); - pFilter = make_instance(f); - if (!pTracker || !pProtocol) + if (!pProtocol) { - qDebug() << "dylib load failure"; + qDebug() << "protocol dylib load failure"; return; } if(!pProtocol->correct()) { qDebug() << "protocol load failure"; + pProtocol = nullptr; + return; + } + + pTracker = make_instance(t); + pFilter = make_instance(f); + + if (!pTracker) + { + qDebug() << "tracker dylib load failure"; return; } -- cgit v1.2.3 From 6b1e8a3c434e9692257f21801c332a30dc2d5d48 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jul 2015 10:01:01 +0200 Subject: prevent redefinition error by qt moc --- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 3 +-- opentrack/camera-names.hpp | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'opentrack') diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index e96e7171..4d55a422 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -12,6 +12,7 @@ #include #include #include "opentrack/thread.hpp" +#include "opentrack/camera-names.hpp" using namespace std; using namespace cv; @@ -129,8 +130,6 @@ void Tracker_PT::run() qDebug()<<"Tracker:: Thread stopping"; } -int camera_name_to_index(const QString &name); - void Tracker_PT::apply_settings() { qDebug()<<"Tracker:: Applying settings"; diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 3d3948fa..6f82ba34 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -13,6 +13,7 @@ # include #endif +template QList get_camera_names() { QList ret; #if defined(_WIN32) @@ -82,6 +83,7 @@ QList get_camera_names() { return ret; } +template int camera_name_to_index(const QString &name) { auto list = get_camera_names(); -- cgit v1.2.3 From 81d2ffa8b95f0dce0a89784d08fe3ba9501cca1e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jul 2015 10:01:13 +0200 Subject: initial camera-settings class --- opentrack/opencv-camera-dialog.hpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 opentrack/opencv-camera-dialog.hpp (limited to 'opentrack') diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp new file mode 100644 index 00000000..3b700a70 --- /dev/null +++ b/opentrack/opencv-camera-dialog.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include "opentrack/camera-names.hpp" + +template +class camera_dialog +{ + cv::VideoCapture fake_capture; +public: + void open_camera_settings(cv::VideoCapture* cap, const QString& camera_name, QMutex* camera_mtx) + { + if (cap) + { + QMutexLocker l(camera_mtx); + + if (cap->isOpened()) + { + cap->set(cv::CAP_PROP_SETTINGS, 1); + return; + } + } + + fake_capture = cv::VideoCapture(camera_name_to_index(camera_name)); + fake_capture.set(cv::CAP_PROP_SETTINGS, 1); + // don't hog the camera capture + fake_capture.open(""); + } +}; + -- cgit v1.2.3