File Coverage

blib/lib/Image/OpenALPR.pm
Criterion Covered Total %
statement 19 26 73.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 33 78.7


line stmt bran cond sub pod time code
1             package Image::OpenALPR;
2              
3 1     1   13645 use 5.014000;
  1         2  
4 1     1   3 use strict;
  1         1  
  1         22  
5 1     1   2 use warnings;
  1         3  
  1         21  
6              
7 1     1   324 use Image::OpenALPR::PlateResult;
  1         2  
  1         4  
8 1     1   398 use JSON::MaybeXS qw/decode_json/;
  1         5456  
  1         61  
9 1     1   6 use XSLoader;
  1         2  
  1         121  
10              
11             BEGIN {
12 1     1   2 our $VERSION = '0.001';
13 1         705 XSLoader::load('Image::OpenALPR', $VERSION);
14 0           *initialise = \&initialize;
15 0           *is_loaded = \&isLoaded;
16 0           *get_version = \&getVersion;
17 0           *set_country = \&setCountry;
18 0           *set_prewarp = \&setPrewarp;
19 0           *set_default_region = \&setDefaultRegion;
20 0           *set_top_n = \&setTopN;
21             }
22              
23             sub new {
24             my $alpr = initialise (@_[1..$#_]);
25             die "Failed to load OpenALPR\n" unless $alpr->is_loaded;
26             $alpr
27             }
28              
29             sub recognise {
30             my ($alpr, $data) = @_;
31             my $json = ref $data eq 'SCALAR' ? $alpr->recognizeArray($$data) : $alpr->recognizeFile($data);
32             $json = decode_json $json;
33             my @plates = map { Image::OpenALPR::PlateResult->new($_) } @{$json->{results}};
34             wantarray ? @plates : shift @plates
35             }
36              
37             sub DESTROY { shift->dispose }
38              
39             package AlprPtr;
40             our @ISA = qw/Image::OpenALPR/;
41              
42             1;
43             __END__