summaryrefslogtreecommitdiffhomepage
path: root/opentrack
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-19 12:58:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-19 12:58:15 +0200
commit9457c8c2c7e7bc6bf057cbb2e17b2e0f207db572 (patch)
tree1d1d1956ccd46e7ed61a86e67a7ab0e8d7e60e46 /opentrack
parent13b76c2363e3fd11df30869f48f9b9ee517129cc (diff)
ensure camera name indices match
We can't make spaces in indices or else wrong camera gets opened.
Diffstat (limited to 'opentrack')
-rw-r--r--opentrack/camera-names.hpp7
1 files changed, 6 insertions, 1 deletions
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<QString> 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<QString> get_camera_names() {
close(fd);
continue;
}
- ret.append(video_cap.name);
+ ret[ret.size()-1] = video_cap.name;
close(fd);
} else {
continue;