def report_block(snap_block): script = [] args = scripts.get_args(snap_block) scripts.check_args("doReport", 1, len(args)) script.append(kurt.Block("insert:at:ofList:", args[0], 1, "return stack")) script.append(kurt.Block("stopScripts", "this script")) return script
def blur_detector(img_col, thresh=10, mask=False): assert isinstance(img_col, numpy.ndarray), 'img_col must be a numpy array' assert img_col.ndim == 3, 'img_col must be a color image ({0} dimensions currently)'.format( img_col.ndim) args = scripts.gen_args() args.thresh = thresh if mask: return FocusMask.blur_mask(img) else: return evaluate(img_col=img_col, args=args) if __name__ == '__main__': args = scripts.get_args() logger = scripts.get_logger(quite=args.quite, debug=args.debug) x_okay, y_okay = [], [] x_blur, y_blur = [], [] for path in args.image_paths: for img_path in scripts.find_images(path): logger.debug('evaluating {0}'.format(img_path)) img = cv2.imread(img_path) if isinstance(img, numpy.ndarray): if args.testing: scripts.display('dialog (blurry: Y?)', img) blurry = False if cv2.waitKey(0) in map(lambda i: ord(i), ['Y', 'y']): blurry = True x_axis = [1, 3, 5, 7, 9] for x in x_axis:
dst_pts = dst_pts.reshape((-1, 1, 2)) M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0) result = combine.combine_images(frame, result, M) if args.display and not args.quiet: scripts.display('result', result) if cv2.waitKey(25) & 0xFF == ord('q'): break else: logger.warning('too few correspondence points') else: result = frame result_gry = cv2.cvtColor(result, cv2.COLOR_RGB2GRAY) else: break logger.debug('{0} is completed'.format(path)) cam.release() cv2.destroyAllWindows() if args.save: scripts.save_image(path, result) except Exception as error: logger.warning('Failed to process {0}'.format(path)) logger.debug('Error msg: {0}'.format(error)) return result if __name__ == '__main__': args = scripts.get_args() logger = scripts.get_logger(quiet=args.quiet, debug=args.debug) result = main(args) scripts.display('final result', result) cv2.waitKey(0)
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Will Brennan' # Built-in Modules import logging # Standard Modules import cv2 import numpy # Custom Modules import main import scripts if __name__ == '__main__': args = scripts.get_args(from_file=False) logger = scripts.get_logger(quite=args.quite, debug=args.debug) cam = cv2.VideoCapture(0) while True: ret, img_col = cam.read() img_msk = main.process(img_col, args=args) if not args.display: scripts.display('img_col', img_col) scripts.display('img_msk', img_msk) scripts.display('img_skn', cv2.bitwise_and(img_col, img_col, mask=img_msk)) cv2.waitKey(5)