lib/Panotools/Script/Line/Variable.pm

filter: Statementstmt 100% 68 / 68 Branchbran 50.0% 20 / 40 Conditioncond 34.4% 10 / 29 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 65.4% 108 / 165 CC 35 SCAR 39.4
CC
35
Cov
72%
Report
81.7
Parse
4.0
Assemble
4.0
CRAP 51.2
« lib/Panotools/Script.pm ↑ Summary lib/Panotools/Script/Line/Panorama.pm »
1 package Panotools::Script::Line::Variable;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Panotools::Script::Line;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use vars qw /@ISA/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 @ISA = qw /Panotools::Script::Line/;
9  
10 =head1 NAME
11  
12 Panotools::Script::Line::Variable - Panotools optimisation variables
13  
14 =head1 SYNOPSIS
15  
16 One or more parameters for optimisation form a 'v' line
17  
18 =head1 DESCRIPTION
19  
20 Please note: the 'v'-line must come after the the 'i'-lines.
21 Optimization variables are listed together with the image number
22 starting at 0. There can be several v-lines.
23  
24 y0 Optimize yaw in image 0
25 p1 Optimize pitch in image 1
26 r2 Optimize roll in image 2
27 v0 Optimize field of view in image 0
28 a2 Optimize lens correction parameter 'a' in image 2
29 b1
30 c1
31 d1
32 e1
33 g1
34 t1
35 X1 Optimize x-coordinate of image 1, only for PTStereo
36 Y2 Optimize y-coordinate of image 2, only for PTStereo
37 Z6 Optimize z-coordinate of image 6, only for PTStereo
38 TrX3 Optimise x-coordinate of image 3, mosaic/translation mode
39 TrY2 Optimise y-coordinate of image 2, mosaic/translation mode
40 TrZ1 Optimise z-coordinate of image 1, mosaic/translation mode
41 Tpp1 Optimise pitch of picture plane of image 1, mosaic/translation mode
42 Tpy1 Optimise yaw of picture plane of image 1, mosaic/translation mode
43  
44 Additionally, photometric optimisation uses the same system. although this is a
45 secondary process and not simultaneous with geometric optimisation:
46  
47 Eev0 Optimise Exposure (Eev) for image 0
48 Er1 Optimise red multiplier for image 1
49 Eb1 Optimise blue multiplier for image 1
50  
51 Ra0 Optimise EMoR camera response for image 0
52 Rb0 note usually all EMoR parameters are optimised at the same time
53 Rc0
54 Rd0
55 Re0
56  
57 Va0 Optimise Vignetting 'Va' parameter for image 0, note usually only Vb, Vc, Vd are optimised
58 Vb0 Optimise Vignetting 'Vb' parameter for image 0
59 Vc0 Optimise Vignetting 'Vc' parameter for image 0
60 Vd0 Optimise Vignetting 'Vd' parameter for image 0
61 Vx1 Optimise Vignetting centre x-position for image 1
62 Vy1 Optimise Vignetting centre y-position for image 1
63  
64 If a image has a parameter linked to another image only need to optimize the master.
65  
66 =cut
67  
68 31 ▶sub _valid { return '^([abcdegprtvyXYZ]|Te[0123]|Tp[py]|Tr[XYZ]|Ti[XYZS]|Eev|Er|Eb|Ra|Rb|Rc|Rd|Re|Va|Vb|Vc|Vd|Vx|Vy)(.*)' }
Subroutine _valid: called CC=1 SCAR=0.0
69  
70 sub Identifier
71 32 ▶{
Subroutine Identifier: called CC=1 SCAR=0.0
Pod undocumented
72 32 my $self = shift;
73 32 return "v";
74 }
75  
76 sub Parse
77 31 ▶{
Subroutine Parse: called CC=4 SCAR=14.0
Pod undocumented
78 31 my $self = shift;
79 31 ▶ my $string = shift || return 0;
Condition50%1/2
shift() || (return 0)
l!l
310
MC/DC0%0/1
shift() || (return 0)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
80 31 my $valid = $self->_valid;
81 31 my @res = $string =~ / ([a-zA-Z]+[0-9]+)/g;
82 31 for my $token (grep { defined $_ } @res)
83 {
84 80 my ($param, $image) = $token =~ /([a-zA-Z]+)([0-9]+)/;
85 80 ▶ next unless defined $image;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $image 0 80 80
86 80 $self->{$image}->{$param} = 1;
87 }
88 31 $self->_sanitise;
89 31 return 1;
90 }
91  
92 sub Assemble
93 10 ▶{
Subroutine Assemble: called CC=4 SCAR=13.9
Pod undocumented
94 10 my $self = shift;
95 10 $self->_sanitise;
96 10 my $string = '';
97 10 for my $image (sort {$a <=> $b} (keys %{$self}))
98 {
99 22 my @tokens;
100 22 for my $param (sort keys %{$self->{$image}})
101 {
102 58 ▶ next unless $self->{$image}->{$param};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$image}{$param} 0 58 58
103 58 push @tokens, $param . $image;
104 }
105 22 $string .= (join ' ', ($self->Identifier, @tokens)) ."\n";
106 }
107 10 $string .= $self->Identifier ."\n";
108 10 return $string;
109 }
110  
111 sub _sanitise
112 41 ▶{
Subroutine _sanitise: called CC=3 SCAR=11.1
113 41 my $self = shift;
114 41 for my $image (keys %{$self})
115 {
116 126 ▶ delete $self->{$image} unless $image =~ /[0-9]+/;
Branch: 1 branch
BranchTrueFalseTotal
unless $image =~ /[0-9]+/ 0 126 126
117 }
118 }
119  
120 sub Report
121 1 ▶{
Subroutine Report: called CC=27 SCAR=44.0
Pod undocumented
122 1 my $self = shift;
123 1 my $index = shift;
124 1 my @report;
125  
126 1 my $i = $self->{$index};
127  
128 1 ▶ push @report, 'Roll' if $self->{$index}->{r};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"r"} 1 0 1
129 1 ▶ push @report, 'Pitch' if $self->{$index}->{p};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"p"} 1 0 1
130 1 ▶ push @report, 'Yaw' if $self->{$index}->{y};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"y"} 0 1 1
131 1 ▶ push @report, 'Field of View' if $self->{$index}->{v};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"v"} 1 0 1
132 1 ▶ push @report, 'a' if $self->{$index}->{a};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"a"} 0 1 1
133 1 ▶ push @report, 'b' if $self->{$index}->{b};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"b"} 0 1 1
134 1 ▶ push @report, 'c' if $self->{$index}->{c};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"c"} 0 1 1
135 1 ▶ push @report, 'd' if $self->{$index}->{d};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"d"} 0 1 1
136 1 ▶ push @report, 'e' if $self->{$index}->{e};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"e"} 0 1 1
137 1 ▶ push @report, 'g' if $self->{$index}->{g};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"g"} 0 1 1
138 1 ▶ push @report, 't' if $self->{$index}->{t};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$index}{"t"} 0 1 1
139  
140 1 ▶ push @report, 'Exposure' if $i->{Eev};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"Eev"} 0 1 1
141 1 ▶ push @report, 'Colour balance' if $i->{Er} or $i->{Eb};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"Er"} or $i->{"Eb"} 0 1 1
Condition33%1/3
$i->{"Er"} or $i->{"Eb"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$i->{"Er"} or $i->{"Eb"}
$i->{"Er"} $i->{"Eb"}
Truth table33%1/3
A or B
A= $i->{"Er"}B= $i->{"Eb"}
ABresult
1X1
011
000
142 1 ▶ push @report, 'Response curve' if $i->{Ra} or $i->{Rb} or $i->{Rc} or $i->{Rd} or $i->{Re};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"Ra"} or $i->{"Rb"} or $i->{"Rc"} or $i->{"Rd"} or $i->{"Re"} 0 1 1
Condition33%4/12
$i->{"Ra"} or $i->{"Rb"} or $i->{"Rc"} or $i->{"Rd"} or $i->{"Re"}
l!l&&r!l&&!r
001
$i->{"Ra"} or $i->{"Rb"} or $i->{"Rc"} or $i->{"Rd"}
l!l&&r!l&&!r
001
$i->{"Ra"} or $i->{"Rb"} or $i->{"Rc"}
l!l&&r!l&&!r
001
$i->{"Ra"} or $i->{"Rb"}
l!l&&r!l&&!r
001
MC/DC0%0/5
$i->{"Ra"} or $i->{"Rb"} or $i->{"Rc"} or $i->{"Rd"} or $i->{"Re"}
$i->{"Ra"} $i->{"Rb"} $i->{"Rc"} $i->{"Rd"} $i->{"Re"}
Truth table16%1/6
A or B or C or D or E
A= $i->{"Ra"}B= $i->{"Rb"}C= $i->{"Rc"}D= $i->{"Rd"}E= $i->{"Re"}
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
143 1 ▶ push @report, 'Vignetting' if $i->{Va} or $i->{Vb} or $i->{Vc} or $i->{Vd};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"Va"} or $i->{"Vb"} or $i->{"Vc"} or $i->{"Vd"} 0 1 1
Condition33%3/9
$i->{"Va"} or $i->{"Vb"} or $i->{"Vc"} or $i->{"Vd"}
l!l&&r!l&&!r
001
$i->{"Va"} or $i->{"Vb"} or $i->{"Vc"}
l!l&&r!l&&!r
001
$i->{"Va"} or $i->{"Vb"}
l!l&&r!l&&!r
001
MC/DC0%0/4
$i->{"Va"} or $i->{"Vb"} or $i->{"Vc"} or $i->{"Vd"}
$i->{"Va"} $i->{"Vb"} $i->{"Vc"} $i->{"Vd"}
Truth table20%1/5
A or B or C or D
A= $i->{"Va"}B= $i->{"Vb"}C= $i->{"Vc"}D= $i->{"Vd"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
144 1 ▶ push @report, 'Vignetting centre' if $i->{Vx} or $i->{Vy};
Branch: 1 branch
BranchTrueFalseTotal
if $i->{"Vx"} or $i->{"Vy"} 0 1 1
Condition33%1/3
$i->{"Vx"} or $i->{"Vy"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$i->{"Vx"} or $i->{"Vy"}
$i->{"Vx"} $i->{"Vy"}
Truth table33%1/3
A or B
A= $i->{"Vx"}B= $i->{"Vy"}
ABresult
1X1
011
000
145  
146 1 ▶ @report = ('NONE') if scalar @report == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @report == 0 0 1 1
147 1 [[('Optimise parameters', (join ',', @report))]];
148 }
149  
150 11 1;
« lib/Panotools/Script.pm ↑ Summary lib/Panotools/Script/Line/Panorama.pm »