Licensed under a 2 clause BSD license, see COPYING for details ''' import sys import os.path import argparse import pr0ntools.layer.parser from PIL import Image from opencv.cv import * from PIL import Image if __name__ == "__main__": parser = argparse.ArgumentParser(description="Nuke 'em") parser.add_argument('files', metavar='files', type=str, nargs='+', help='Input training folders and files to classify') args = parser.parse_args() dirs = list() files = list() for f in args.files: if not os.path.exists(f): raise ValueError('No file %s' % f) if os.path.isdir(f): dirs.append(f) else: files.append(f) print '%d training dirs' % len(dirs) print '%d things to classify' % len(files)
gray[h][w] = im.getpixel((w,h)) else: gray[h][w] = im.getpixel((w,h))[0] return gray @staticmethod def from_file(fn): parser = pr0ntools.layer.parser.MultilayerSVGParser(fn) parser.run() if len(parser.images) != 1: raise Exception('Test vector must have exactly one image') return SVGTestVector(list(parser.images)[0], parser.layers) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Manipulate .pto files') parser.add_argument('image_in', metavar='image_in', type=str, nargs=1, help='Image to process') parser.add_argument('svg_out', metavar='svg_out', type=str, nargs=1, help='Output file') parser.add_argument('training_in', metavar='training_in', type=str, nargs='+', help='Tagged SVGs') #parser.add_argument('--allow-missing', action="store_true", dest="allow_missing", default=True, help='Allow missing images') args = parser.parse_args() image_in_fn = args.image_in[0] svg_out_fn = args.svg_out[0] training_svgs = args.training_in if svg_out_fn.find('svg') < 0: raise Exception("Output must be SVG") for f in training_svgs: if f.find('.svg') < 0: raise Exception('Training must be SVGs')
import sys import os.path import argparse import pr0ntools.layer.parser from PIL import Image from opencv.cv import * from PIL import Image if __name__ == "__main__": parser = argparse.ArgumentParser(description="Nuke 'em") parser.add_argument('files', metavar='files', type=str, nargs='+', help='Input training folders and files to classify') args = parser.parse_args() dirs = list() files = list() for f in args.files: if not os.path.exists(f): raise ValueError('No file %s' % f) if os.path.isdir(f): dirs.append(f) else: files.append(f) print '%d training dirs' % len(dirs)