File: check_needles.pl

package info (click to toggle)
os-autoinst 4.5.1527308405.8b586d5-4.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 22,688 kB
  • sloc: perl: 10,424; cpp: 1,527; python: 217; makefile: 211; sh: 71; xml: 11
file content (39 lines) | stat: -rwxr-xr-x 897 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use strict;

use File::Basename;

use needle;
use cv;

cv::init();
require tinycv;

my ($res, $needle, $img);

my $ndir = $ARGV[0] || ".";

my @jsons = glob "${ndir}/*.json";
my @pngs  = glob "${ndir}/*.png";

foreach my $json (@jsons) {
    my $bnjson = basename($json, ".json");
    $needle = needle->new($json);
    foreach my $png (@pngs) {
        my $bnpng = basename($png, ".png");
        $img = tinycv::read($png);
        $res = $img->search($needle);
        if ($res) {
            if ($bnjson ne $bnpng) {
                print "Needle ambiguity: [Needle] " . $bnjson . " - [Image] " . $bnpng . " [" . $res->{similarity} . "]\n";
            }
        }
        else {
            if ($bnjson eq $bnpng) {
                print "Needle do not match himself: [Needle] " . $bnjson . " - [Image] " . $bnpng . "\n";
            }
        }
    }
}
# vim: set sw=4 et: