Example #1
0
                            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)
Example #2
0
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:
                        img_mod = cv2.GaussianBlur(img, (x, x), 0)
Example #3
0

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:
                        img_mod = cv2.GaussianBlur(img, (x, x), 0)