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