Example #1
0
    import argparse

    parser = argparse.ArgumentParser(description="Interactively experiment with HoughLinesP parameters.")
    parser.add_argument("file", help="image to threshold", type=str)
    # add a command line parameter for every slider parameter
    cvparams.addCommandLineArgs(cvparam_dict, parser)

    args = parser.parse_args()
    cvparams.setValuesFromCommandLine(cvparam_dict, args)

    from glob import glob

    for filename in glob(args.file):
        img = get_image(filename)
        h, w = img.shape[:2]
        img = cv2.GaussianBlur(img, (5, 5), 0)
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        edges = cv2.Canny(gray, 600, 600, apertureSize=5)

        cv2.imshow("results", img)  # window needs to exist before we add sliders
        cvparams.addSlidersToWindow(cvparam_dict, "results")
        updateImage()

        ch = cv2.waitKey()
        if ch == 27:
            break

    cv2.destroyAllWindows()
    cvparams.dump(cvparam_dict)
Example #2
0
        "Color Kernel Size", 150, 109, updateImage)

    import argparse
    parser = argparse.ArgumentParser(
        description="Apply bilateral (edge preserving) blur operator.")
    parser.add_argument('file', help='image to blur (wildcards ok)', type=str)
    # add a command line parameter for every slider parameter
    cvparams.addCommandLineArgs(cvparam_dict, parser)

    args = parser.parse_args()
    cvparams.setValuesFromCommandLine(cvparam_dict, args)

    from glob import glob
    for filename in glob(args.file):
        img = cv2.imread(filename)
        assert img is not None, "File " + args.file + " was not found."
        h, w = img.shape[:2]

        cv2.imshow('results',
                   img)  # window needs to exist before we add sliders
        cvparams.addSlidersToWindow(cvparam_dict, "results")
        updateImage()

        ch = cv2.waitKey()
        if ch == 27:
            break

    cv2.destroyAllWindows()

    cvparams.dump(cvparam_dict)