Last change
on this file since 26882 was 26882, checked in by davidb, 11 years ago |
Joshua Hollands software for operation with the diy camera built for Smoke and Mirrors 2012
|
File size:
1.5 KB
|
Line | |
---|
1 | #!/usr/bin/perl -w
|
---|
2 | use warnings;
|
---|
3 | use strict;
|
---|
4 | package detect_cameras
|
---|
5 | {
|
---|
6 | sub new
|
---|
7 | {
|
---|
8 | my $class = shift;
|
---|
9 | my $self = {};
|
---|
10 | bless($self, $class);
|
---|
11 | return $self;
|
---|
12 | }
|
---|
13 |
|
---|
14 | sub doupstart
|
---|
15 | {
|
---|
16 | return 1;
|
---|
17 | }
|
---|
18 |
|
---|
19 | sub upstart
|
---|
20 | {
|
---|
21 | print "Detecting cameras... this may take a long time...\n";
|
---|
22 | my $DIR;
|
---|
23 | undef($main::plugins{'camera'}); #Reset the camera list
|
---|
24 | my @cameras; # is the camera list.
|
---|
25 | opendir ($DIR, "/dev");
|
---|
26 | my @files = grep(m/video\d+/, readdir($DIR));
|
---|
27 | while (scalar(@files) > 0)
|
---|
28 | {
|
---|
29 | push(@cameras, shift(@files));
|
---|
30 | }
|
---|
31 | closedir($DIR);
|
---|
32 | $main::plugins{'camera'} = \@cameras;
|
---|
33 | print scalar(@cameras)," cameras found.\n";
|
---|
34 | }
|
---|
35 |
|
---|
36 | sub command
|
---|
37 | {
|
---|
38 | return "Detect Cameras";
|
---|
39 | }
|
---|
40 |
|
---|
41 | sub help
|
---|
42 | {
|
---|
43 | return "find and list all the cameras connected to this system, any cameras found will be used to take images when the command 'capture' is used.";
|
---|
44 | }
|
---|
45 |
|
---|
46 | sub do
|
---|
47 | {
|
---|
48 | my $DIR;
|
---|
49 | undef($main::plugins{'camera'}); #Reset the camera list
|
---|
50 | my @cameras; # is the camera list.
|
---|
51 | opendir ($DIR, "/dev");
|
---|
52 | my @files = grep(m/video\d+/, readdir($DIR));
|
---|
53 | while (scalar(@files) > 0)
|
---|
54 | {
|
---|
55 | push(@cameras, shift(@files));
|
---|
56 | }
|
---|
57 | closedir($DIR);
|
---|
58 | $main::plugins{'camera'} = \@cameras;
|
---|
59 | print $main::socket "{ \"count\":",scalar(@cameras)," }\n";
|
---|
60 | }
|
---|
61 | sub defaultsettings
|
---|
62 | {
|
---|
63 | return undef;
|
---|
64 | }
|
---|
65 | 1;
|
---|
66 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.