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(-) 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