Improve POD formatting
[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
6765bc35
MG
48Image::OpenALPR::PlateResult is a class representing a plate
49identified by OpenALPR. It offers the following methods:
470f6420
MG
50
51=over
52
6765bc35 53=item $plate->B<plate>
470f6420 54
6765bc35
MG
55The plate number that has the highest confidence value (likelihood of
56being correct).
470f6420 57
6765bc35 58=item $plate->B<confidence>
470f6420
MG
59
60The confidence value of the plate number returned by B<plate>.
61
6765bc35 62=item $plate->B<matches_template>
470f6420 63
6765bc35
MG
64True if the plate matches the plate pattern chosen via the
65B<set_default_region> in L<Image::OpenALPR>, false otherwise (or if no
66region was chosen).
470f6420 67
6765bc35 68=item $plate->B<coordinates>
470f6420 69
6765bc35
MG
70In list context, returns a four element list representing the vertices
71of the license plate, numbered clock-wise from top-left. Each element
72is an arrayref with two elements: the X coordinate followed by the Y
73coordinate.
470f6420 74
6765bc35
MG
75In scalar context, returns an arrayref to an array containing the list
76described above.
470f6420 77
6765bc35 78=item $plate->B<candidates>
470f6420 79
6765bc35
MG
80In list context, returns a list of candidate license numbers, in
81decreasing order of confidence. The first element coincides with the
82plate/confidence pair returned by the B<plate> and B<confidence>
83methods. Each element is a partial Image::OpenALPR::PlateResult object
84-- only the B<plate>, B<confidence> and B<matches_template> methods
85will return a meaningful value.
470f6420
MG
86
87=back
88
89=head1 AUTHOR
90
91Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
92
93=head1 COPYRIGHT AND LICENSE
94
95Copyright (C) 2016 by Marius Gavrilescu
96
97This file is part of Image-OpenALPR.
98
99Image-OpenALPR is free software: you can redistribute it and/or modify
100it under the terms of the GNU Affero General Public License as published by
101the Free Software Foundation, either version 3 of the License, or
102(at your option) any later version.
103
104Image-OpenALPR is distributed in the hope that it will be useful,
105but WITHOUT ANY WARRANTY; without even the implied warranty of
106MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107GNU Affero General Public License for more details.
108
109You should have received a copy of the GNU Affero General Public License
110along with Image-OpenALPR. If not, see <http://www.gnu.org/licenses/>
111
112
113=cut
This page took 0.015453 seconds and 4 git commands to generate.