if len(argv) < 2: print('You must specify a name argument.') else: config = Config().get() capture = Capture(config) trans = Transform(config) display = Display() detect = Detect() label = Label() with capture, display: key = '' while key != 'q': success = False image = capture.frame() disk = trans.image_copy(image) disk = trans.image_color_flip(disk) small = trans.scale_image(image) locs = detect.locations(small) if len(locs) == 1: success = True loc = trans.scale_location(locs[0]) label.set_image(image).set_location(loc) image = label.outline().header(argv[1]).get_image() display.show(image) key = display.key() if key == 'c' and success == True: print('Capturing {}...'.format(argv[1])) Save().image(disk, argv[1])
from src.label import Label from src.transform import Transform config = Config().get() capture = Capture(config) encode = Encode(config) trans = Transform(config) detect = Detect() display = Display() label = Label() refs, ref_map = encode.images() with capture, display: while display.key() != 'q': image = capture.frame() label.set_image(image) small = trans.scale_image(image) locs, encs = detect.all(small) for i in range(len(encs)): lbl = False enc = encs[i] loc = locs[i] cmps = detect.compare(refs, enc) for j in range(len(cmps)): if cmps[j]: lbl = ref_map[j] if lbl: loc = trans.scale_location(loc) label.set_location(loc).outline().header(lbl)