示例#1
0
def horn_schunck(stem, pat:str):
    flist = getimgfiles(stem, pat)

    for i in range(len(flist)-1):
        fn1 = flist[i]
        im1 = imageio.imread(fn1, as_gray=True)

 #       Iold = gaussian_filter(Iold,FILTER)

        fn2 = flist[i+1]
        im2 = imageio.imread(fn2, as_gray=True)
#        Inew = gaussian_filter(Inew,FILTER)

        U,V = HornSchunck(im1, im2, 1., 100)
        compareGraphs(U,V, im2, fn=fn2.name)

    return U,V
示例#2
0
def horn_schunck(stem: Path, pat: str, alpha: float, Niter: int,
                 verbose: bool):
    flist = getimgfiles(stem, pat)

    for i in range(len(flist) - 1):
        fn1 = flist[i]
        im1 = imageio.imread(fn1, as_gray=True)

        #       Iold = gaussian_filter(Iold,FILTER)

        fn2 = flist[i + 1]
        im2 = imageio.imread(fn2, as_gray=True)
        #        Inew = gaussian_filter(Inew,FILTER)

        U, V = HornSchunck(im1, im2, alpha=1.0, Niter=100)
        compareGraphs(U, V, im2, fn=fn2.name)

    return U, V
示例#3
0
def gif_generator(path, filenames=[]):
    """Saves a sequence of images as a .gif
    input:
        path: str, folder path where the images are located. It is also where the gif is saved.
        filenames: list[str], a list containing the file names. If not provided it will use all .png images in the
            folder provided in path. The file names are assumed sorted.
    output:
        saves flow.gif in the folder provided in path.
    """
    images = []

    if filenames == []:
        filenames = getimgfiles(path, "*.png")

    for filename in tqdm(filenames, ncols=100, desc="GIFing"):
        images.append(imageio.imread(filename))

    imageio.mimsave(path + "/flow.gif", images)
示例#4
0
def horn_schunck(stem, pat: str, save_to: str):
    flist = getimgfiles(stem, pat)

    for i in tqdm(range(len(flist) - 1), ncols=100, desc="HS flow"):
        fn1 = flist[i]
        im1 = imageio.imread(fn1, as_gray=False)

        im1 = np.flip(im1, 0)

        fn2 = flist[i + 1]
        im2 = imageio.imread(fn2, as_gray=False)
        im2 = np.flip(im2, 0)

        U, V = HornSchunck(rgb2gray(im1), rgb2gray(im2), 1., 100)

        path = save_to + "/" + fn2.name
        compareGraphs(U, V, im2, fn=fn2.name, save=path)

    return U, V
示例#5
0
def lucas_kanade(stem, pat: str, kernel: int = 5, Nfilter: int = 7):
    flist = getimgfiles(stem, pat)

    # %% priming read
    im1 = imageio.imread(flist[0], as_gray=True)

    # %% evaluate the first frame's POI
    X = im1.shape[1] // 16
    Y = im1.shape[0] // 16
    poi = getPOI(X, Y, kernel)
    # % get the weights
    W = gaussianWeight(kernel)
    # %% loop over all images in directory
    for i in range(1, len(flist)):
        im2 = imageio.imread(flist[i], as_gray=True)

        im2 = gaussian_filter(im2, Nfilter)

        V = LucasKanade(im1, im2, kernel, poi, W)

        compareGraphsLK(im1, im2, poi, V)

        im1 = im2.copy()
示例#6
0
def test_io():
    flist = pof.getimgfiles(RDIR / 'data/box', 'box*')
    print(flist)
示例#7
0
def test_io():
    flist = pof.getimgfiles(RDIR / "data/box", "box*")
    assert len(flist) == 2