Significantly expand testsuite
[image-openalpr.git] / t / Image-OpenALPR.t
CommitLineData
470f6420
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
2b0bab05 5use Test::More tests => 9;
470f6420
MG
6BEGIN { use_ok('Image::OpenALPR') };
7
2b0bab05
MG
8my $alpr = Image::OpenALPR->new('us');
9my $version = $alpr->getVersion;
10note "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);
13my @plates = $alpr->recognise('t/ex.jpg');
14is @plates, 1, 'Found only one plate';
15is $plates[0]->plate, 'ZP36709', 'plate number';
16cmp_ok $plates[0]->confidence, '>=', 80, 'high confidence';
17my @cands = $plates[0]->candidates;
18is @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
24my $data;
25
26{
27 open my $fh, '<t/ex.jpg';
28 local $/ = undef;
29 $data = <$fh>;
30 close $fh;
31}
32
33my $plate = $alpr->recognise(\$data);
34is $plate, 'ZP36709', 'recogniseArray + string conversion';
35my @coords = $plate->coordinates;
36is $coords[0][0], 306, 'coordinates';
37is $plate->coordinates->[0][1], 351, 'coordinates in scalar context';
38is $plate->candidates->[0], $plate, 'candidates in scalar context';
This page took 0.012321 seconds and 4 git commands to generate.