forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-test_ocr.t
executable file
·48 lines (36 loc) · 931 Bytes
/
02-test_ocr.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Test::Warnings;
use File::Which 'which';
use File::Basename;
BEGIN {
unshift @INC, '..';
$bmwqemu::vars{DISTRI} = "unicorn";
$bmwqemu::vars{CASEDIR} = "/var/lib/empty";
}
use needle;
use cv;
use ocr;
cv::init();
require tinycv;
unless (which('tesseract')) {
plan skip_all => 'No tesseract installed';
exit(0);
}
my ($res, $needle, $img1);
my $data_dir = dirname(__FILE__) . '/data/';
$bmwqemu::vars{PRJDIR} = $data_dir;
$img1 = tinycv::read($data_dir . "bootmenu.test.png");
$needle = needle->new($data_dir . "bootmenu-ocr.ref.json");
$res = $img1->search($needle);
ok(defined $res, "ocr match 1");
my $ocr;
for my $area (@{$res->{needle}->{area}}) {
next unless $area->{type} eq 'ocr';
$ocr .= ocr::tesseract($img1, $area);
}
ok($ocr =~ /Memory Test.*Video Mode/s, "multiple OCR regions");
done_testing;
# vim: set sw=4 et: