Changeset 24174 for trunk/ippScripts/scripts/magic_process.pl
- Timestamp:
- May 13, 2009, 12:37:33 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_process.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/pap_magic (added) merged: 24120,24132-24136,24145,24147-24154,24156-24164,24168-24173
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/magic_process.pl
r24166 r24174 37 37 38 38 # Parse the command-line arguments 39 my ($magic_id, $node, $camera, $dbname, $outroot, $ template_uri, $save_temps, $verbose, $no_update, $no_op, $logfile);39 my ($magic_id, $node, $camera, $dbname, $outroot, $save_temps, $verbose, $no_update, $no_op, $logfile); 40 40 41 41 GetOptions( … … 45 45 'dbname=s' => \$dbname, # Database name 46 46 'outroot=s' => \$outroot, # Output root name 47 'template_uri=s' => \$template_uri,# uri of diff template48 47 'save-temps' => \$save_temps, # Save temporary files? 49 48 'verbose' => \$verbose, # Print stuff? … … 59 58 defined $node and 60 59 defined $camera and 61 defined $outroot and 62 defined $template_uri; 60 defined $outroot; 63 61 64 62 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration … … 138 136 } 139 137 140 my $template = $ipprc->file_resolve($template_uri);141 &my_die("failed to resolve template _uri: $template_uri", $magic_id, $node, $PS_EXIT_DATA_ERROR)142 if !($template);138 my $template = resolve_template($innode); 139 &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) 140 unless defined $template; 143 141 144 142 $command .= " --detect --image $image --mask $mask --weight $weight -k $template"; … … 189 187 foreach my $innode (@$inputs) { 190 188 # root for inputs from previous stage 191 my $in_ uri = $innode->{uri};192 print $sfh "$in_ uri\n";193 194 cat_list_to_list($in_fh, $in_ uri, "input.list");189 my $in_path_base = $innode->{magic_path_base}; 190 print $sfh "$in_path_base\n"; 191 192 cat_list_to_list($in_fh, $in_path_base, "input.list"); 195 193 # build input lists by combining the lists from 196 194 # previous stages 197 cat_list_to_list($ifh, $in_ uri, "image.list");198 cat_list_to_list($mfh, $in_ uri, "mask.list");199 cat_list_to_list($wfh, $in_ uri, "weight.list");195 cat_list_to_list($ifh, $in_path_base, "image.list"); 196 cat_list_to_list($mfh, $in_path_base, "mask.list"); 197 cat_list_to_list($wfh, $in_path_base, "weight.list"); 200 198 } 201 199 close $in_fh; … … 243 241 $command .= " -magic_id $magic_id"; 244 242 $command .= " -node $node"; 245 $command .= " - uri$outroot";243 $command .= " -path_base $outroot"; 246 244 $command .= " -dbname $dbname" if defined $dbname; 247 245 … … 262 260 my $resolved = $ipprc->file_resolve($streaks_file); 263 261 264 my $fh; 265 open $fh, "<$resolved" or 266 &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 267 # the first line in the streaks file contains the number of streaks found 268 my $num_streaks = <$fh>; 269 chomp $num_streaks; 270 close $fh; 271 print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose; 262 my $num_streaks = -1; 263 unless ($no_op) { 264 my $fh; 265 open $fh, "<$resolved" or 266 &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 267 # the first line in the streaks file contains the number of streaks found 268 $num_streaks = <$fh>; 269 chomp $num_streaks; 270 close $fh; 271 print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose; 272 } 272 273 273 274 my $command = "$magictool -addmask"; … … 309 310 sub cat_list_to_list { 310 311 my $out = shift; # output file handle 311 my $ uri = shift; # urito append ...312 my $path_base = shift; # path_base to append ... 312 313 my $extension = shift; # ... the extension to 313 314 314 my $filename = "$ uri.$extension";315 my $filename = "$path_base.$extension"; 315 316 316 317 my $in; … … 321 322 } 322 323 323 sub resolve_inputs {324 324 sub resolve_inputs 325 { 325 326 my $node = shift; 326 my $input_base = $node->{path_base}; 327 328 my $image = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT", $input_base)); 329 my $mask = $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.MASK", $input_base)); 330 my $weight= $ipprc->file_resolve($ipprc->filename("PPSUB.OUTPUT.VARIANCE", $input_base)); 331 332 return ($image, $mask, $weight); 327 my $input_base = $node->{diff_path_base}; 328 329 my ($image, $mask, $variance); # Names to return 330 if ($node->{inverse}) { 331 $image = "PPSUB.INVERSE"; 332 $mask = "PPSUB.INVERSE.MASK"; 333 $variance = "PPSUB.INVERSE.VARIANCE"; 334 } else { 335 $image = "PPSUB.OUTPUT"; 336 $mask = "PPSUB.OUTPUT.MASK"; 337 $variance = "PPSUB.OUTPUT.VARIANCE"; 338 } 339 340 $image = $ipprc->file_resolve($ipprc->filename($image, $input_base)); 341 $mask = $ipprc->file_resolve($ipprc->filename($mask, $input_base)); 342 $variance= $ipprc->file_resolve($ipprc->filename($variance, $input_base)); 343 344 return ($image, $mask, $variance); 345 } 346 347 sub resolve_template 348 { 349 my $node = shift; 350 351 my $image; # Name of template to return 352 my $path_base; # Base name for name 353 if (defined $node->{warp_path_base} and $node->{warp_path_base} ne "NULL") { 354 $path_base = $node->{warp_path_base}; 355 $image = "PSWARP.OUTPUT"; 356 } elsif (defined $node->{stack_path_base} and $node->{stack_path_base} ne "NULL") { 357 $path_base = $node->{stack_path_base}; 358 $image = "PPSTACK.OUTPUT"; 359 } else { 360 return undef; 361 } 362 363 $image = $ipprc->file_resolve($ipprc->filename($image, $path_base)); 364 365 return $image 333 366 } 334 367
Note:
See TracChangeset
for help on using the changeset viewer.
