コード例 #1
0
ファイル: lines_hough.py プロジェクト: sricci23/yard-vision
    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)
コード例 #2
0
    parser = argparse.ArgumentParser(
        description=
        "Interactively experiment with morphology gradient parameters.")
    parser.add_argument('file', help='image to threshold', type=str)
    # add a command line parameter for every slider parameter
    cvparam.addCommandLineArgs(cvparam_dict, parser)

    args = parser.parse_args()
    cvparam.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."
        # img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

        h, w = img.shape[:2]

        cv2.imshow('results',
                   img)  # window needs to exist before we add sliders
        cvparam.addSlidersToWindow(cvparam_dict, "results")
        updateImage()
        ch = cv2.waitKey()
        if ch == 27:
            break

    cv2.destroyAllWindows()

    # print selected parameters to console
    cvparam.dump(cvparam_dict)
コード例 #3
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)
コード例 #4
0
    cvparam_dict['blockSize'] = cvparam.kernelparam("Block Size (3,5,..)", 21, 5, updateImage)

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

    args = parser.parse_args()
    cvparam.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."
        img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

        h, w = img.shape[:2]

        cv2.imshow('results', img) # window needs to exist before we add sliders
        cvparam.addSlidersToWindow(cvparam_dict, "results")
        updateImage()
        ch = cv2.waitKey()
        if ch == 27:
            break

    cv2.destroyAllWindows()

    # print selected parameters to console
    cvparam.dump(cvparam_dict)