Exemple #1
0
def poc():

    dset = dataset.dataset('data/basil/front')
    converted = cv2.cvtColor(dset[1], cv2.COLOR_BGR2HSV)

    h, s, v = cv2.split(converted)

    mask = (h > 45) & (h < 90)

    mask = np.invert(mask)

    v[mask] = 0

    converted = cv2.merge([h, s, v])

    cvutil.display_image(cv2.cvtColor(converted, cv2.COLOR_HSV2BGR))
Exemple #2
0
def poc() :

    dset = dataset.dataset('data/basil/front')
    converted = cv2.cvtColor(dset[1], cv2.COLOR_BGR2HSV)


    h, s, v = cv2.split(converted)

    mask = (h > 45) & (h < 90)

    mask = np.invert(mask)

    v[mask] = 0

    converted = cv2.merge([h,s,v])

    cvutil.display_image(cv2.cvtColor(converted, cv2.COLOR_HSV2BGR))
Exemple #3
0
def poc_dense() :

    dset = dataset.dataset('data/basil/front')
    first = cv2.cvtColor(dset[1],cv2.COLOR_BGR2GRAY, dstCn=1)
    last = cv2.cvtColor(dset[2], cv2.COLOR_BGR2GRAY, dstCn=1)

    canvas = np.zeros_like(dset[1])

    canvas[...,1] = 255

    flow = cv2.calcOpticalFlowFarneback(first,last ,flow=None, pyr_scale=0.5,levels= 3, winsize=15, iterations=2, poly_n=5, poly_sigma=1.1, flags=0)

    mag, ang = cv2.cartToPolar(flow[...,0], flow[...,1])

    canvas[...,0]  = ang * 180/np.pi/2
    canvas[...,2] = cv2.normalize(mag, None, 0, 255,cv2.NORM_MINMAX)

    print(canvas)
    cvutil.display_image(cv2.cvtColor(canvas, cv2.COLOR_HSV2BGR))
Exemple #4
0
def poc():

    image = dataset.dataset('edge')[2]
    orig = np.copy(image)
    checker = gen_bound_checker(image)

    traces = []

    cvutil.display_image(image)

    for y in range(image.shape[0]):
        for x in range(image.shape[1]):
            if not (checker(x, y) or trace.in_any_traces(x, y)):
                t = trace(x, y, checker)
                t.trace_bounds()
                t.fill_bounds()
                traces.append(t)
                dataset.print_status_bar(y * image.shape[1] + x,
                                         image.shape[0] * image.shape[1])

    print('\n coloring')
    for i, t in enumerate(traces):
        if len(t) < 50:
            for p in t.points:
                image[p.y][p.x][0] = 200
                image[p.y][p.x][1] = 200
                image[p.y][p.x][2] = 200
        else:
            randcolor = (random.choice(range(255)), random.choice(range(255)),
                         random.choice(range(255)))
            for p in t.points:
                image[p.y][p.x][0] = randcolor[0]
                image[p.y][p.x][1] = randcolor[1]
                image[p.y][p.x][2] = randcolor[2]
            image[t.init_p.y][t.init_p.x][0] = 0
            image[t.init_p.y][t.init_p.x][1] = 0
            image[t.init_p.y][t.init_p.x][2] = 255
        dataset.print_status_bar(i, len(traces))

    cvutil.comp_images(orig, image)
Exemple #5
0
def poc() :
    dset = dataset.dataset('data/basil/front')

    display = np.copy(dset[-1])

    tracking = cv2.goodFeaturesToTrack(cv2.cvtColor(dset[1], cv2.COLOR_BGR2GRAY), maxCorners = 100, qualityLevel = 0.3, minDistance = 7, blockSize = 7)

    old = tracking


    for i in range(2,len(dset)) :
        result, status, error = cv2.calcOpticalFlowPyrLK(dset[i - 1], dset[i], old, None, winSize=(15,15), maxLevel= 2)
        old = result

        for i in range(tracking.shape[0]) :

            for j in range(tracking.shape[1]) :

                cv2.circle(display, (old[i][j][0], old[i][j][1]), 4, (0,0,255))


    cvutil.display_image(display)
Exemple #6
0
def poc() :

    image = dataset.dataset('edge')[2]
    orig = np.copy(image)
    checker = gen_bound_checker(image)

    traces = []

    cvutil.display_image(image)

    for y in range(image.shape[0]) :
        for x in range(image.shape[1]) :
            if not (checker(x, y) or trace.in_any_traces(x, y)) :
                t = trace(x, y, checker)
                t.trace_bounds()
                t.fill_bounds()
                traces.append(t)
                dataset.print_status_bar(y * image.shape[1] + x, image.shape[0] * image.shape[1])

    print('\n coloring')
    for i,t in enumerate(traces) :
        if len(t) < 50 :
            for p in t.points :
                image[p.y][p.x][0] = 200
                image[p.y][p.x][1] = 200
                image[p.y][p.x][2] = 200
        else :
            randcolor = (random.choice(range(255)),random.choice(range(255)),random.choice(range(255)))
            for p in t.points :
                image[p.y][p.x][0] = randcolor[0]
                image[p.y][p.x][1] = randcolor[1]
                image[p.y][p.x][2] = randcolor[2]
            image[t.init_p.y][t.init_p.x][0] = 0
            image[t.init_p.y][t.init_p.x][1] = 0
            image[t.init_p.y][t.init_p.x][2] = 255
        dataset.print_status_bar(i, len(traces))

    cvutil.comp_images(orig, image)
Exemple #7
0
def poc() :
    image = dataset.dataset('data//basil/front')[2]
    image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    edges = cv2.Canny(image, 100,200)

    cvutil.display_image(cv2.cvtColor(edges, cv2.COLOR_GRAY2BGR))