]>
Commit | Line | Data |
---|---|---|
470f6420 MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
2b0bab05 | 5 | use Test::More tests => 9; |
470f6420 MG |
6 | BEGIN { use_ok('Image::OpenALPR') }; |
7 | ||
2b0bab05 MG |
8 | my $alpr = Image::OpenALPR->new('us'); |
9 | my $version = $alpr->getVersion; | |
10 | note "OpenALPR version is $version, this module was designed for 2.2.4" unless $version =~ /^2\.2/; | |
11 | $alpr->setCountry('eu'); | |
470f6420 MG |
12 | $alpr->set_top_n(3); |
13 | my @plates = $alpr->recognise('t/ex.jpg'); | |
14 | is @plates, 1, 'Found only one plate'; | |
15 | is $plates[0]->plate, 'ZP36709', 'plate number'; | |
16 | cmp_ok $plates[0]->confidence, '>=', 80, 'high confidence'; | |
17 | my @cands = $plates[0]->candidates; | |
18 | is @cands, 3, 'number of candidates matches top_n'; | |
2b0bab05 MG |
19 | |
20 | # These two methods should not die (nor do anything useful) | |
21 | $cands[0]->coordinates; | |
22 | $cands[0]->candidates; | |
23 | ||
24 | my $data; | |
25 | ||
26 | { | |
27 | open my $fh, '<t/ex.jpg'; | |
28 | local $/ = undef; | |
29 | $data = <$fh>; | |
30 | close $fh; | |
31 | } | |
32 | ||
33 | my $plate = $alpr->recognise(\$data); | |
34 | is $plate, 'ZP36709', 'recogniseArray + string conversion'; | |
35 | my @coords = $plate->coordinates; | |
36 | is $coords[0][0], 306, 'coordinates'; | |
37 | is $plate->coordinates->[0][1], 351, 'coordinates in scalar context'; | |
38 | is $plate->candidates->[0], $plate, 'candidates in scalar context'; |