def main(command_line_parameters=None):
"""Preprocesses the given image with the given preprocessor."""
args = command_line_arguments(command_line_parameters)
logger.debug("Loading preprocessor")
preprocessor = bob.bio.base.load_resource(' '.join(args.preprocessor), "preprocessor")
logger.debug("Loading input data from file '%s'%s", args.input_file, " and '%s'" % args.annotation_file if args.annotation_file is not None else "")
data = preprocessor.read_original_data(BioFile(1, args.input_file, 2), "", "")
annotations = bob.db.base.annotations.read_annotation_file(args.annotation_file, 'named') if args.annotation_file is not None else None
logger.info("Preprocessing data")
preprocessed = preprocessor(data, annotations)
preprocessor.write_data(preprocessed, args.output_file)
logger.info("Wrote preprocessed data to file '%s'", args.output_file)
if args.convert_as_image is not None:
converted = bob.core.convert(preprocessed, 'uint8', dest_range=(0,255), source_range=(numpy.min(preprocessed), numpy.max(preprocessed)))
bob.io.base.save(converted, args.convert_as_image)
logger.info("Wrote preprocessed data to image file '%s'", args.convert_as_image)
评论列表
文章目录