summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-10-01 16:41:20 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-10-01 16:41:20 +0200
commit29406db336d00a223fec9035044a5ca46ade1d3f (patch)
tree2193fab5bf301e5106d05ef86c225f419c5bd6f7
parentf3d16459b19098ec4c1269a527867270c19c9e98 (diff)
camera settings: disable for all A4 TECH cameras
We've had two reported crashes. Issue: #468
-rw-r--r--cv/video-property-page.cpp29
-rw-r--r--cv/video-property-page.hpp4
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp9
-rw-r--r--tracker-pt/ftnoir_tracker_pt_dialog.cpp9
4 files changed, 33 insertions, 18 deletions
diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp
index 08ac00d0..e5f1a9f0 100644
--- a/cv/video-property-page.cpp
+++ b/cv/video-property-page.cpp
@@ -10,7 +10,7 @@
#ifdef _WIN32
#include <cstring>
-#include <QString>
+#include <QRegularExpression>
#include <QDebug>
#define CHECK(expr) if (FAILED(hr = (expr))) { qDebug() << QStringLiteral(#expr) << hr; goto done; }
@@ -22,6 +22,24 @@ bool video_property_page::show_from_capture(cv::VideoCapture& cap, int)
return true;
}
+bool video_property_page::should_show_dialog(const QString& camera_name)
+{
+ using re = QRegularExpression;
+ static const re regexen[] =
+ {
+ re("^PS3Eye Camera$"),
+ re("^A4 TECH "),
+ };
+ bool avail = true;
+ for (const re& r : regexen)
+ {
+ avail &= !r.match(camera_name).hasMatch();
+ if (!avail)
+ break;
+ }
+ return avail;
+}
+
bool video_property_page::show(int id)
{
IBaseFilter* filter = NULL;
@@ -135,6 +153,11 @@ done:
# include <QProcess>
# include "compat/camera-names.hpp"
+bool video_property_page::should_show_dialog(const QString& camera_name)
+{
+ return true;
+}
+
bool video_property_page::show(int idx)
{
const QList<QString> camera_names(get_camera_names());
@@ -152,4 +175,8 @@ bool video_property_page::show_from_capture(cv::VideoCapture&, int idx)
#else
bool video_property_page::show(int) { return false; }
bool video_property_page::show_from_capture(cv::VideoCapture&, int) { return false; }
+bool video_property_page::should_show_dialog(const QString& camera_name)
+{
+ return false;
+}
#endif
diff --git a/cv/video-property-page.hpp b/cv/video-property-page.hpp
index 7c51f111..4e53e2ab 100644
--- a/cv/video-property-page.hpp
+++ b/cv/video-property-page.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <QString>
+
#ifdef _WIN32
# include <windows.h>
# include <dshow.h>
@@ -12,7 +14,7 @@ struct video_property_page final
video_property_page() = delete;
static bool show(int id);
static bool show_from_capture(cv::VideoCapture& cap, int idx);
-
+ static bool should_show_dialog(const QString& camera_name);
private:
#ifdef _WIN32
static HRESULT ShowFilterPropertyPages(IBaseFilter* filter);
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index 18e6a9bf..24923ede 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -435,15 +435,8 @@ TrackerControls::TrackerControls()
void TrackerControls::set_camera_settings_available(const QString& camera_name)
{
-#ifdef _WIN32
- const bool avail = camera_name != QStringLiteral("PS3Eye Camera");
+ const bool avail = video_property_page::should_show_dialog(camera_name);
ui.camera_settings->setEnabled(avail);
-#elif defined(__linux)
- (void)camera_name;
-#else
- (void)camera_name;
- ui.camera_settings->setEnabled(false);
-#endif
}
void TrackerControls::show_camera_settings()
diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
index c722e9a7..d3d68efc 100644
--- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp
+++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp
@@ -151,15 +151,8 @@ void TrackerDialog_PT::poll_tracker_info()
void TrackerDialog_PT::set_camera_settings_available(const QString& camera_name)
{
-#ifdef _WIN32
- const bool avail = camera_name != QStringLiteral("PS3Eye Camera");
+ const bool avail = video_property_page::should_show_dialog(camera_name);
ui.camera_settings->setEnabled(avail);
-#elif defined(__linux)
- (void)camera_name;
-#else
- (void)camera_name;
- ui.camera_settings->setEnabled(false);
-#endif
}
void TrackerDialog_PT::show_camera_settings()