Example #1
0
def synth_circle_noise(infiles, outfiles, NOISE):

    SIM_DURATION = 30.0
    TDELTA = 1 / 30.

    t = np.arange(0, SIM_DURATION, TDELTA)

    frames_to_skip = [20, 35, 36, 50, 51, 52, 53]

    env = util.Environmentz((1.5, 2), (240, 320))

    state = simulate.gen_track_circle(t,
                                      np.pi * 2 / 10,
                                      env,
                                      circle_radius=0.5)
    images = simulate.render(env, state)
    new_images = simulate.add_noise_background(images, NOISE, NOISE,
                                               frames_to_skip)
    pickle.dump(
        {
            'state': state,
            'video': new_images,
            'noise': NOISE,
            'frames_skipped': frames_to_skip
        }, open(outfiles[0], 'w'))
    videotools.dump_grey_movie(outfiles[1], new_images)
def synth_circle_noise(infiles, outfiles, NOISE):
    
    SIM_DURATION = 30.0
    TDELTA = 1/30.
    
    t = np.arange(0, SIM_DURATION, TDELTA)
    
    frames_to_skip = [20, 35, 36, 50, 51, 52, 53]
    
    env = util.Environmentz((1.5, 2), (240, 320))
    
    state = simulate.gen_track_circle(t, np.pi*2/10, env, circle_radius=0.5)
    images = simulate.render(env, state)
    new_images = simulate.add_noise_background(images, NOISE, NOISE, 
                                               frames_to_skip)
    pickle.dump({'state' : state, 
                 'video' : new_images, 
                 'noise' : NOISE, 
                 'frames_skipped' : frames_to_skip
                 }, 
                open(outfiles[0], 'w'))
    videotools.dump_grey_movie(outfiles[1], new_images)    
                                   "r:gz")
    
    positions_interp, missing = measure.interpolate(positions)
    pos_derived = measure.compute_derived(positions_interp)
    

    N = len(positions)
    state = np.zeros(N, dtype=util.DTYPE_STATE)
    state['x'] = positions_interp['x']
    state['y'] = positions_interp['y']
    state['phi'] = pos_derived['phi']
    state['theta'] = np.pi/2.0

    env = util.Environmentz((1.5, 2), (240, 320))

    images = simulate.render(env, state[:100])
    NOISE = 0


    new_images = simulate.add_noise_background(images, NOISE, NOISE, 
                                               [])

    FN = 100
    pylab.figure()
    pylab.subplot(2, 1, 1)
    pylab.plot(state['x'][:FN])
    pylab.plot(state['y'][:FN])
    pylab.subplot(2, 1, 2)
    pylab.scatter(positions['led_front'][:FN, 0], positions['led_front'][:FN, 1], c='g')
    pylab.scatter(positions['led_back'][:FN, 0], positions['led_back'][:FN, 1], c='r')
Example #4
0
    # open the frame tarball
    tf = tarfile.open(os.path.join(directory, "%08d.tar.gz" % start_f), "r:gz")

    positions_interp, missing = measure.interpolate(positions)
    pos_derived = measure.compute_derived(positions_interp)

    N = len(positions)
    state = np.zeros(N, dtype=util.DTYPE_STATE)
    state['x'] = positions_interp['x']
    state['y'] = positions_interp['y']
    state['phi'] = pos_derived['phi']
    state['theta'] = np.pi / 2.0

    env = util.Environmentz((1.5, 2), (240, 320))

    images = simulate.render(env, state[:100])
    NOISE = 0

    new_images = simulate.add_noise_background(images, NOISE, NOISE, [])

    FN = 100
    pylab.figure()
    pylab.subplot(2, 1, 1)
    pylab.plot(state['x'][:FN])
    pylab.plot(state['y'][:FN])
    pylab.subplot(2, 1, 2)
    pylab.scatter(positions['led_front'][:FN, 0],
                  positions['led_front'][:FN, 1],
                  c='g')
    pylab.scatter(positions['led_back'][:FN, 0],
                  positions['led_back'][:FN, 1],