blib/lib/Image/libsiftfast.pm

filter: Statementstmt 26.9% 14 / 52 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 26.0% 18 / 69 CC 6 SCAR 19.9
CC
6
Cov
24%
convert_to_pnm
12.0
extract_features
12.0
new
6.0
CRAP 7.3
↑ Summary
1 package Image::libsiftfast;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Imager;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.01_01';
8  
9 sub new {
10 0 ▶ my $class = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
11 0 my $self = bless {@_}, $class;
12 0 ▶ $self->{siftfast_path} ||= 'siftfast';
Condition0%0/2
$self->{"siftfast_path"} ||= "siftfast"
l!l
00
MC/DC0%0/1
$self->{"siftfast_path"} ||= "siftfast"
$self->{"siftfast_path"}
Truth table0%0/2
A
A= $self->{"siftfast_path"}
Aresult
11
00
13 0 $self->{imager} = Imager->new;
14 0 return $self;
15 }
16  
17 sub convert_to_pnm {
18 0 ▶ my $self = shift;
Subroutine convert_to_pnm: not called CC=3 SCAR=24.8
Pod undocumented
19 0 my $file = shift;
20  
21 0 my $imager = $self->{imager};
22 0 ▶ $imager->read( file => $file ) or die $imager->errstr;
Branch: 1 branch
BranchTrueFalseTotal
$imager->read("file", $file) or die $imager->errstr 0 0 0
23 0 my $new = $imager->convert( preset => 'grey' );
24 0 $file =~ s/jpg/pnm/;
25 0 ▶ $new->write( file => $file, type => "pnm", pnm_write_wide_data => 1 )
Branch: 1 branch
BranchTrueFalseTotal
$new->write("file", $file, "type", "pnm", "pnm_write_wide_data", 1) or die $! 0 0 0
26 or die($!);
27 0 return $file;
28 }
29  
30 sub extract_features {
31 0 ▶ my $self = shift;
Subroutine extract_features: not called CC=3 SCAR=24.8
Pod undocumented
32 0 my $pnm_file = shift;
33  
34 0 my $siftfast_path = $self->{siftfast_path};
35 0 my @stdout = `$siftfast_path < $pnm_file 2>&1`;
36  
37 0 my $stderr_message = shift @stdout;
38 0 $stderr_message .= shift @stdout;
39  
40 0 my @array = map { chomp $_; $_ } @stdout;
41 0 shift @array; # remove first line;
42 0 my $return_string = join( "\n", @array );
43  
44 0 my @feature_vectors;
45 0 for ( split "\n\n", $return_string ) {
46 0 my @rec = split "\n", $_;
47 0 my @array;
48 0 for (@rec) {
49 0 my @f = split " ", $_;
50 0 push @array, @f;
51 }
52 0 my $X = shift @array;
53 0 my $Y = shift @array;
54 0 my $scale = shift @array;
55 0 my $orientation = shift @array;
56 0 my $vector = \@array;
57  
58 0 push @feature_vectors,
59 {
60 frames => {
61 X => $X,
62 Y => $Y,
63 scale => $scale,
64 orientation => $orientation,
65 },
66 vector => $vector,
67 };
68 }
69 0 return \@feature_vectors;
70  
71 }
72  
73 1 1;
74 __END__
↑ Summary