]> iEval git - image-openalpr.git/blame - lib/Image/OpenALPR/PlateResult.pm
Bump version and update Changes
[image-openalpr.git] / lib / Image / OpenALPR / PlateResult.pm
CommitLineData
470f6420
MG
1package Image::OpenALPR::PlateResult;
2
3use 5.014000;
4use strict;
5use warnings;
6
baf65988 7use overload '""' => sub { shift->plate }, fallback => 1;
470f6420
MG
8use parent qw/Class::Accessor::Fast/;
9
4d4051da 10our $VERSION = '0.001001';
470f6420
MG
11
12__PACKAGE__->mk_ro_accessors(qw/plate confidence matches_template/);
13
14sub coordinates {
15 my $coords = shift->{coordinates};
16 return unless $coords;
17 my @result = map { [$_->{x}, $_->{y}] } @$coords;
18 wantarray ? @result : \@result
19}
20
21sub candidates {
22 my $cands = shift->{candidates};
23 return unless $cands;
24 my @result = map { __PACKAGE__->new($_) } @$cands;
25 wantarray ? @result : \@result
26}
27
281;
29__END__
30
31=encoding utf-8
32
33=head1 NAME
34
35Image::OpenALPR::PlateResult - a license plate, as identified by OpenALPR
36
37=head1 SYNOPSIS
38
39 my $plate = $alpr->recognise('t/example.jpg');
baf65988 40 say $plate; # ZP36709
470f6420
MG
41 say $plate->plate; # ZP36709
42 say $plate->confidence; # 92.373634
43 my @coords = $plate->coordinates; # [306, 351], [476, 351], [476, 384], [306, 384]
44 my @candidates = $plate->candidates;
45 say $candidates[1]->plate; # ZP367O9
46 say $candidates[1]->confidence; # 89.812302
47
48=head1 DESCRIPTION
49
6765bc35
MG
50Image::OpenALPR::PlateResult is a class representing a plate
51identified by OpenALPR. It offers the following methods:
470f6420
MG
52
53=over
54
6765bc35 55=item $plate->B<plate>
470f6420 56
6765bc35 57The plate number that has the highest confidence value (likelihood of
baf65988
MG
58being correct). An object of this class will stringify to the return
59value of this method.
470f6420 60
6765bc35 61=item $plate->B<confidence>
470f6420
MG
62
63The confidence value of the plate number returned by B<plate>.
64
6765bc35 65=item $plate->B<matches_template>
470f6420 66
6765bc35
MG
67True if the plate matches the plate pattern chosen via the
68B<set_default_region> in L<Image::OpenALPR>, false otherwise (or if no
69region was chosen).
470f6420 70
6765bc35 71=item $plate->B<coordinates>
470f6420 72
6765bc35
MG
73In list context, returns a four element list representing the vertices
74of the license plate, numbered clock-wise from top-left. Each element
75is an arrayref with two elements: the X coordinate followed by the Y
76coordinate.
470f6420 77
6765bc35
MG
78In scalar context, returns an arrayref to an array containing the list
79described above.
470f6420 80
6765bc35 81=item $plate->B<candidates>
470f6420 82
6765bc35
MG
83In list context, returns a list of candidate license numbers, in
84decreasing order of confidence. The first element coincides with the
85plate/confidence pair returned by the B<plate> and B<confidence>
86methods. Each element is a partial Image::OpenALPR::PlateResult object
87-- only the B<plate>, B<confidence> and B<matches_template> methods
88will return a meaningful value.
470f6420
MG
89
90=back
91
92=head1 AUTHOR
93
94Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
95
96=head1 COPYRIGHT AND LICENSE
97
98Copyright (C) 2016 by Marius Gavrilescu
99
100This file is part of Image-OpenALPR.
101
102Image-OpenALPR is free software: you can redistribute it and/or modify
103it under the terms of the GNU Affero General Public License as published by
104the Free Software Foundation, either version 3 of the License, or
105(at your option) any later version.
106
107Image-OpenALPR is distributed in the hope that it will be useful,
108but WITHOUT ANY WARRANTY; without even the implied warranty of
109MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110GNU Affero General Public License for more details.
111
112You should have received a copy of the GNU Affero General Public License
113along with Image-OpenALPR. If not, see <http://www.gnu.org/licenses/>
114
115
116=cut
This page took 0.040516 seconds and 4 git commands to generate.