| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Camera::Sercomm::ICamera2; |
|
2
|
2
|
|
|
2
|
|
140358
|
use strict; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
60
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
54
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use base qw{Package::New}; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1047
|
|
|
5
|
2
|
|
|
2
|
|
1942
|
use LWP::UserAgent; |
|
|
2
|
|
|
|
|
95816
|
|
|
|
2
|
|
|
|
|
78
|
|
|
6
|
2
|
|
|
2
|
|
23
|
use HTTP::Request; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
842
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
9
|
|
|
|
|
|
|
our $PACKAGE = __PACKAGE__; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Net::Camera::Sercomm::ICamera2 - Perl Interface for Sercomm ICamera2 network camera |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Net::Camera::Sercomm::ICamera2; |
|
18
|
|
|
|
|
|
|
my $camera = Net::Camera::Sercomm::ICamera2->new(hostname => 'mycamera.example.com'); |
|
19
|
|
|
|
|
|
|
my $jpeg = $camera->getSnapshot; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The Sercomm ICamera2 is a network camera that can be accessed via a web interface. |
|
24
|
|
|
|
|
|
|
This module provides methods to retrieve an image from the camera. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 PROPERTIES |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 hostname |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Required hostname or IP address |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub hostname { |
|
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
36
|
0
|
0
|
|
|
|
|
$self->{'hostname'} = shift if @_; |
|
37
|
0
|
0
|
|
|
|
|
die("Error: $PACKAGE property hostname required") unless defined $self->{'hostname'}; |
|
38
|
0
|
|
|
|
|
|
return $self->{'hostname'}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 port |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
TCP/IP port |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Default: 80 |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub port { |
|
50
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
51
|
0
|
0
|
|
|
|
|
$self->{'port'} = shift if @_; |
|
52
|
0
|
0
|
|
|
|
|
$self->{'port'} = 80 unless defined $self->{'port'};; |
|
53
|
0
|
|
|
|
|
|
return $self->{'port'}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 imageSettingsSize |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Image size setting passed on the getSnapshot URL. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
size=2 320x240 |
|
61
|
|
|
|
|
|
|
size=3 640x480 |
|
62
|
|
|
|
|
|
|
size=4 1280x720 |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Default: 4 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
All other values return 320x240 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub imageSettingsSize { |
|
71
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
72
|
0
|
0
|
|
|
|
|
$self->{'imageSettingsSize'} = shift if @_; |
|
73
|
0
|
0
|
|
|
|
|
$self->{'imageSettingsSize'} = 4 unless defined $self->{'imageSettingsSize'}; |
|
74
|
0
|
|
|
|
|
|
return $self->{'imageSettingsSize'}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 imageSettingsQuality |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Image JPEG compression quality setting passed on the getSnapshot URL. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
quality=1 JPEG quality 85 |
|
82
|
|
|
|
|
|
|
quality=2 JPEG quality 70 |
|
83
|
|
|
|
|
|
|
quality=3 JPEG quality 55 |
|
84
|
|
|
|
|
|
|
quality=4 JPEG quality 40 |
|
85
|
|
|
|
|
|
|
quality=5 JPEG quality 25 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Default: 1 |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub imageSettingsQuality { |
|
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
93
|
0
|
0
|
|
|
|
|
$self->{'imageSettingsQuality'} = shift if @_; |
|
94
|
0
|
0
|
|
|
|
|
$self->{'imageSettingsQuality'} = 1 unless defined $self->{'imageSettingsQuality'}; |
|
95
|
0
|
|
|
|
|
|
return $self->{'imageSettingsQuality'}; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 METHODS |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 getSnapshot |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns a JPEG image. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub getSnapshot { |
|
107
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
108
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/5.0 (compatible; $PACKAGE/$VERSION; See rt.cpan.org 35173)"); |
|
|
0
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $url = sprintf("http://%s:%s/img/snapshot.cgi?size=%s&quality=%s", |
|
110
|
|
|
|
|
|
|
$self->hostname, $self->port, $self->imageSettingsSize, $self->imageSettingsQuality); |
|
111
|
0
|
|
|
|
|
|
my $request = HTTP::Request->new(GET => $url); |
|
112
|
0
|
|
|
|
|
|
my $response = $ua->request($request); #isa HTTP::Response |
|
113
|
0
|
0
|
|
|
|
|
die(sprintf("HTTP Error: %s", $response->status_line)) unless $response->is_success; |
|
114
|
0
|
|
|
|
|
|
return $response->content; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
https://github.com/edent/Sercomm-API, L |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Michael R. Davis mrdvt at cpan |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
MIT License |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright (c) 2020 Michael R. Davis |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
132
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
|
133
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
|
134
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
135
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
|
136
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
|
139
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
142
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
143
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
144
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
145
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
146
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
147
|
|
|
|
|
|
|
SOFTWARE. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |