Changeset 17943 for trunk/ippScripts/scripts/detrend_norm_apply.pl
- Timestamp:
- Jun 5, 2008, 12:09:48 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_apply.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r17671 r17943 28 28 $no_update, $no_op ); 29 29 GetOptions( 30 'det_id|d=s' => \$det_id, # Detrend ID 31 'iteration|n=s' => \$iter, # Iteration32 'class_id|i=s' => \$class_id, # Class ID33 'value|v=s' => \$value, # Value to multiple (for normalisation)34 'input_uri|u=s' => \$input_uri, # Input file35 'camera|c=s' => \$camera, # Camera36 'det_type|t=s' => \$det_type, # Detrend type30 'det_id|d=s' => \$det_id, # Detrend ID 31 'iteration|n=s' => \$iter, # Iteration 32 'class_id|i=s' => \$class_id, # Class ID 33 'value|v=s' => \$value, # Value to multiple (for normalisation) 34 'input_uri|u=s' => \$input_uri, # Input file 35 'camera|c=s' => \$camera, # Camera 36 'det_type|t=s' => \$det_type, # Detrend type 37 37 'outroot|w=s' => \$outroot, # output file base name 38 'dbname|d=s' => \$dbname, # Database name38 'dbname|d=s' => \$dbname, # Database name 39 39 'verbose' => \$verbose, # Print to stdout 40 'no-update' => \$no_update, # Don't update the database41 'no-op' => \$no_op, # Don't do any operations40 'no-update' => \$no_update, # Don't update the database 41 'no-op' => \$no_op, # Don't do any operations 42 42 ) or pod2usage( 2 ); 43 43 44 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 45 pod2usage( -msg => "Required options: --det_id --iteration --class_id --value --input_uri --camera --det_type --outroot", 46 -exitval => 3) unless 47 defined $det_id and 48 defined $iter and 49 defined $class_id and 50 defined $value and 51 defined $input_uri and 52 defined $camera and 46 -exitval => 3) unless 47 defined $det_id and 48 defined $iter and 49 defined $class_id and 50 defined $value and 51 defined $input_uri and 52 defined $camera and 53 53 defined $det_type and 54 54 defined $outroot; … … 65 65 66 66 # values to extract from output metadata and the stats to calculate 67 my $STATS = 68 [ 67 my $STATS = 68 [ 69 69 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG 70 70 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 78 78 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 79 79 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 80 if ($missing_tools) { 80 if ($missing_tools) { 81 81 warn("Can't find required tools."); 82 exit($PS_EXIT_CONFIG_ERROR); 82 exit($PS_EXIT_CONFIG_ERROR); 83 83 } 84 84 … … 100 100 my $statsName = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 101 101 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 102 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);102 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 103 103 104 104 # Run normalisation … … 112 112 $command .= ' -isdark' if lc($det_type) eq 'dark'; 113 113 $command .= " -tracedest $traceDest -log $logDest"; 114 $command .= " -dbname $dbname" if defined $dbname; 114 115 115 116 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 116 run(command => $command, verbose => $verbose);117 run(command => $command, verbose => $verbose); 117 118 unless ($success) { 118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);119 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code);119 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 120 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code); 120 121 } 121 122 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($output); … … 123 124 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b2name); 124 125 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($statsName); 125 126 126 127 # Get the statistics on the normalised image 127 128 my $statsFile; # File handle … … 132 133 133 134 # parse the statistics MDC file 134 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files135 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 135 136 my $metadata = $mdcParser->parse(join "", @contents); 136 137 unless ($metadata) { 137 &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);138 &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 138 139 } 139 140 140 141 # extract the stats from the metadata 141 142 unless ($stats->parse($metadata)) { 142 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);143 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 143 144 } 144 145 } … … 157 158 unless ($no_update) { 158 159 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $command, verbose => $verbose);160 run(command => $command, verbose => $verbose); 160 161 unless ($success) { 161 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);162 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n");163 exit($error_code);162 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 163 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n"); 164 exit($error_code); 164 165 } 165 166 } else { … … 169 170 sub my_die 170 171 { 171 my $msg = shift; # Warning message on die172 my $det_id = shift; # Detrend identifier173 my $iter = shift; # Iteration174 my $class_id = shift; # Class identifier175 my $exit_code = shift; # Exit code to add172 my $msg = shift; # Warning message on die 173 my $det_id = shift; # Detrend identifier 174 my $iter = shift; # Iteration 175 my $class_id = shift; # Class identifier 176 my $exit_code = shift; # Exit code to add 176 177 177 178 carp($msg); 178 179 if (defined $det_id and defined $iter and defined $class_id and not $no_update) { 179 my $command = "$dettool -addnormalizedimfile";180 $command .= " -det_id $det_id";181 $command .= " -iteration $iter";182 $command .= " -class_id $class_id";183 $command .= " -code $exit_code";184 $command .= " -dbname $dbname" if defined $dbname;180 my $command = "$dettool -addnormalizedimfile"; 181 $command .= " -det_id $det_id"; 182 $command .= " -iteration $iter"; 183 $command .= " -class_id $class_id"; 184 $command .= " -code $exit_code"; 185 $command .= " -dbname $dbname" if defined $dbname; 185 186 system ($command); 186 187 }
Note:
See TracChangeset
for help on using the changeset viewer.
