summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-05-02 18:50:05 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-05-02 18:55:46 +0200
commit4793e57051bf17620e93f62e2651fc5df1708935 (patch)
tree806da084534c822d4107e614f46db32c1aef9a96
parentbac58c2d5e45d838e32bc1d5cc0b12a19365c569 (diff)
tracker/{aruco,easy,pt}: bail out when camera missing
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp4
-rw-r--r--tracker-easy/tracker-easy.cpp8
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp3
3 files changed, 12 insertions, 3 deletions
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index d9cb2b96..bdb41d44 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -164,6 +164,10 @@ bool aruco_tracker::open_camera()
QMutexLocker l(&camera_mtx);
camera = video::make_camera(s.camera_name);
+
+ if (!camera)
+ return false;
+
video::impl::camera::info args {};
if (res.width)
diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp
index 0217b07f..dd96e782 100644
--- a/tracker-easy/tracker-easy.cpp
+++ b/tracker-easy/tracker-easy.cpp
@@ -729,6 +729,12 @@ namespace EasyTracker
return module_status("Error: Solver not supported use either P3P or AP3P.");
}
+ // Create our camera
+ camera = video::make_camera(iSettings.camera_name);
+
+ if (!camera)
+ return error(QStringLiteral("Can't open camera %1").arg(iSettings.camera_name));
+
//video_frame->setAttribute(Qt::WA_NativeWindow);
widget = std::make_unique<video_widget>(video_frame);
layout = std::make_unique<QHBoxLayout>(video_frame);
@@ -738,8 +744,6 @@ namespace EasyTracker
//video_widget->resize(video_frame->width(), video_frame->height());
video_frame->show();
- // Create our camera
- camera = video::make_camera(iSettings.camera_name);
// Precise timer is needed otherwise the interval is not really respected
iTicker.setTimerType(Qt::PreciseTimer);
SetFps(iSettings.cam_fps);
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index ea5346f6..194fd423 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -53,7 +53,8 @@ void Tracker_PT::run()
{
portable::set_curthread_name("tracker/pt");
- maybe_reopen_camera();
+ if (!maybe_reopen_camera())
+ return;
while(!isInterruptionRequested())
{