Ejemplo n.º 1
0
def start(dset=None, frame_num=0):
    main.initialize()

    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()

        name = dset
        name = os.path.split(name)[1]
        custom = os.path.join('data/sets/', name, 'gt.txt')
        if os.path.exists(custom):
            # Try dataset directory first
            fname = custom
        else:
            import re
            # Fall back on generic ground truth file
            match = re.match('.*_z(\d)m_(.*)', name)            
            number = int(match.groups()[0])
            fname = 'data/experiments/gt/gt%d.txt' % number

        with open(fname) as f:
            GT = grid.gt2grid(f.read())
        grid.initialize_with_groundtruth(GT)

    else:
        config.load('data/newest_calibration')
        opennpy.align_depth_to_rgb()
        dataset.setup_opencl()
Ejemplo n.º 2
0
def start(dset=None, frame_num=0):
    main.initialize()

    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()

        name = dset
        name = os.path.split(name)[1]
        custom = os.path.join('data/sets/', name, 'gt.txt')
        if os.path.exists(custom):
            # Try dataset directory first
            fname = custom
        else:
            import re
            # Fall back on generic ground truth file
            match = re.match('.*_z(\d)m_(.*)', name)
            number = int(match.groups()[0])
            fname = 'data/experiments/gt/gt%d.txt' % number

        with open(fname) as f:
            GT = grid.gt2grid(f.read())
        grid.initialize_with_groundtruth(GT)

    else:
        config.load('data/newest_calibration')
        opennpy.align_depth_to_rgb()
        dataset.setup_opencl()
Ejemplo n.º 3
0
def run_normals():
    global ds
    ds = []

    try:
        shutil.rmtree(out_path)
    except:
        pass
    os.mkdir(out_path)

    for i in range(1):
        dataset.load_random_dataset()
        dataset.advance()

        name = 'dataset_%s' % str(i)
        d = dict(name=name)
        folder = os.path.join(out_path, name)
        os.mkdir(folder)

        depthL = dataset.depthL.astype('f')
        pylab.figure(0)
        pylab.clf()
        pylab.imshow(depthL)
        pylab.savefig(os.path.join(folder,'depth.jpg'))

        dt = timeit.timeit(lambda: normals.normals_numpy(depthL),
                           number=1)
        d['numpy'] = dt
        n,w = normals.normals_numpy(depthL)
        pylab.clf()
        show_normals(n, w)
        pylab.savefig(os.path.join(folder,'normals_numpy.jpg'))

        dt = timeit.timeit(lambda: normals.normals_c(depthL),
                           number=1)
        d['c'] = dt
        n,w = normals.normals_c(depthL)
        pylab.clf()
        show_normals(n, w)
        pylab.savefig(os.path.join(folder,'normals_c.jpg'))

        rect = ((0,0),(640,480))
        mask = np.zeros((480,640),'bool')
        mask[1:-1,1:-1] = 1
        normals.opencl.set_rect(rect, ((0,0),(0,0)))
        dt = timeit.timeit(lambda:
                        normals.normals_opencl(depthL, mask, rect).wait(),
                           number=1)
        d['opencl'] = dt
        nw,_ = normals.opencl.get_normals()
        n,w = nw[:,:,:3], nw[:,:,3]
        pylab.clf()
        show_normals(n,w)
        pylab.savefig(os.path.join(folder,'normals_opencl.jpg'))

        ds.append(d)
Ejemplo n.º 4
0
def start(dset=None, frame_num=0):
    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load('data/newest_calibration')
        dataset.setup_opencl()
Ejemplo n.º 5
0
def start(dset=None, frame_num=0):
    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load('data/newest_calibration')
        dataset.setup_opencl()
Ejemplo n.º 6
0
def start(dset=None, frame_num=0):
    main.initialize()
    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load('data/newest_calibration')
        opennpy.align_depth_to_rgb()
        dataset.setup_opencl()
Ejemplo n.º 7
0
def start(dset=None, frame_num=0):
    main.initialize()
    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load('data/newest_calibration')
        opennpy.align_depth_to_rgb()
        dataset.setup_opencl()
Ejemplo n.º 8
0
def start(dset=None, frame_num=0):
    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load("data/newest_calibration")
        dataset.setup_opencl()
        global R_correct
        if "R_correct" in globals():
            del R_correct
Ejemplo n.º 9
0
def start(dset=None, frame_num=0):
    main.initialize()

    #with open('data/experiments/collab/2011.txt') as f:
    global target_model
    with open('data/experiments/collab/block.txt') as f:
        target_model = grid.gt2grid(f.read())
    #grid.initialize_with_groundtruth(GT)

    if not FOR_REAL:
        if dset is None:
            dataset.load_random_dataset()
        else:
            dataset.load_dataset(dset)
        while dataset.frame_num < frame_num:
            dataset.advance()
    else:
        config.load('data/newest_calibration')
        opennpy.align_depth_to_rgb()
        dataset.setup_opencl()
Ejemplo n.º 10
0
def run_calib():
    global ds
    ds = []

    try:
        shutil.rmtree(out_path)
    except:
        pass
    os.mkdir(out_path)

    for i in range(1):
        dataset.load_random_dataset()
        table_calibration.newest_folder = dataset.current_path

        name = 'dataset_%s' % str(i)
        d = dict(name=name)
        folder = os.path.join(out_path, name)
        os.mkdir(folder)

        dt = timeit.timeit(lambda: table_calibration.finish_cube_calib(),
                           number=1)
        d['dt'] = dt

        depthL, depthR = table_calibration.depthL, table_calibration.depthR
        bgL, bgR = config.bgL, config.bgR
        for depth, side, bg in (depthL, 'left', bgL), (depthR, 'right', bgR):
            pylab.figure(0)
            pylab.clf()
            pylab.imshow(depth)
            pylab.savefig(os.path.join(folder, 'depth_%s.jpg' % side))

            pylab.clf()
            pylab.imshow(bg['bgHi'])
            pylab.savefig(os.path.join(folder, 'bghi_%s.jpg' % side))

            pylab.imshow(bg['bgLo'])
            pylab.savefig(os.path.join(folder, 'bglo_%s.jpg' % side))

        ds.append(d)
Ejemplo n.º 11
0
def run_calib():
    global ds
    ds = []

    try:
        shutil.rmtree(out_path)
    except:
        pass
    os.mkdir(out_path)

    for i in range(1):
        dataset.load_random_dataset()
        table_calibration.newest_folder = dataset.current_path

        name = "dataset_%s" % str(i)
        d = dict(name=name)
        folder = os.path.join(out_path, name)
        os.mkdir(folder)

        dt = timeit.timeit(lambda: table_calibration.finish_cube_calib(), number=1)
        d["dt"] = dt

        depthL, depthR = table_calibration.depthL, table_calibration.depthR
        bgL, bgR = config.bgL, config.bgR
        for depth, side, bg in (depthL, "left", bgL), (depthR, "right", bgR):
            pylab.figure(0)
            pylab.clf()
            pylab.imshow(depth)
            pylab.savefig(os.path.join(folder, "depth_%s.jpg" % side))

            pylab.clf()
            pylab.imshow(bg["bgHi"])
            pylab.savefig(os.path.join(folder, "bghi_%s.jpg" % side))

            pylab.imshow(bg["bgLo"])
            pylab.savefig(os.path.join(folder, "bglo_%s.jpg" % side))

        ds.append(d)
Ejemplo n.º 12
0
def test_tablecalib():
    dataset.load_random_dataset()
    dataset.advance()
    table_calibration.finish_table_calib()
Ejemplo n.º 13
0
def test_dataset():
    dataset.load_random_dataset()
Ejemplo n.º 14
0
def once():
    dataset.advance()
    depthL, depthR = dataset.depthL, dataset.depthR
    maskL, rectL = preprocess.threshold_and_mask(depthL, config.bgL)
    maskR, rectR = preprocess.threshold_and_mask(depthR, config.bgR)
    show_mask('maskL', maskL.astype('f'), rectL)
    show_mask('maskR', maskR.astype('f'), rectR)

    pylab.waitforbuttonpress(0.01)


def go():
    while 1:
        once()


def show_backgrounds():
    pylab.figure(1)
    pylab.imshow(config.bgL['bgHi'])
    pylab.draw()
    pylab.figure(2)
    pylab.clf()
    pylab.imshow(config.bgR['bgHi'])
    pylab.draw()


if __name__ == "__main__":
    dataset.load_random_dataset()
    go()
Ejemplo n.º 15
0
def test_tablecalib():
    dataset.load_random_dataset()
    dataset.advance()
Ejemplo n.º 16
0
def once():
    dataset.advance()
    depthL, depthR = dataset.depthL, dataset.depthR
    maskL, rectL = preprocess.threshold_and_mask(depthL, config.bgL)
    maskR, rectR = preprocess.threshold_and_mask(depthR, config.bgR)
    show_mask("maskL", maskL.astype("f"), rectL)
    show_mask("maskR", maskR.astype("f"), rectR)

    pylab.waitforbuttonpress(0.01)


def go():
    while 1:
        once()


def show_backgrounds():
    pylab.figure(1)
    pylab.imshow(config.bgL["bgHi"])
    pylab.draw()
    pylab.figure(2)
    pylab.clf()
    pylab.imshow(config.bgR["bgHi"])
    pylab.draw()


if __name__ == "__main__":
    dataset.load_random_dataset()
    go()