def get_data(file,
             min,
             max,
             animation_time=animation_time,
             num_events=num_events_p_s * animation_time,
             offset=0):
    aefile = paer.aefile(file, max_events=max + 1)
    aedata = paer.aedata(aefile)
    #print 'Points: %i, Time: %0.2f. End Time: %0.2f. Start Time: %0.2f.Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000, aefile.timestamp[-1]/1000000, aefile.timestamp[0]/1000000,
    #                                              np.floor(len(aefile.data)/num_events))

    sparse = aedata[min:max].make_sparse(np.floor((max - min) / num_events))
    for i in range(1, len(sparse.ts)):
        #print sparse.y[-i]
        if (sparse.ts[-i] != 0):
            last_index = -i
            break
    print "last index: %d, last time stamp %d" % (last_index,
                                                  sparse.ts[last_index])
    actual_time = (sparse.ts[last_index] - sparse.ts[0]) / 1000000
    scale = actual_time / animation_time
    sparse.ts = (offset * 1000000) + np.round(
        (sparse.ts - sparse.ts[0]) / scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000
    print len(sparse[0:len(sparse.ts) + last_index + 1])
    return sparse[0:len(sparse.ts) + last_index + 1]
コード例 #2
0
def get_data(file, min, max, animation_time=animation_time, whitespace_time=whitespate_time, num_events=num_events_p_s*animation_time, offset=0):
    aefile = paer.aefile(file, max_events=max+1)
    aedata = paer.aedata(aefile)
    print 'Points: %i, Time: %0.2f. Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000,
                                                  np.floor(len(aefile.data)/num_events))

    sparse = aedata[min:max].make_sparse(np.floor(len(aefile.data)/num_events))

    actual_time = (sparse.ts[-1]-sparse.ts[0])/1000000
    scale = actual_time/animation_time
    sparse.ts = (offset * 1000000) + np.round((sparse.ts-sparse.ts[0])/scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000

    return sparse
コード例 #3
0
def get_data(file,
             min,
             max,
             animation_time=animation_time,
             num_events=num_events_p_s * animation_time,
             offset=0):
    aefile = paer.aefile(file, max_events=max + 1)
    aedata = paer.aedata(aefile)
    print 'Points: %i, Time: %0.2f. Sparsity: %i' % (
        len(aefile.data),
        (aefile.timestamp[-1] - aefile.timestamp[0]) / 1000000,
        np.floor(len(aefile.data) / num_events))

    sparse = aedata[min:max].make_sparse(
        np.floor(len(aefile.data) / num_events))

    actual_time = (sparse.ts[-1] - sparse.ts[0]) / 1000000
    scale = actual_time / animation_time
    sparse.ts = (offset * 1000000) + np.round(
        (sparse.ts - sparse.ts[0]) / scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000

    return sparse
コード例 #4
0
from os import listdir
from os.path import isfile, join
import paer

mypath = '/path/to/fyp-aedata-matlab'
onlyfiles = [
    f for f in listdir(mypath)
    if isfile(join(mypath, f)) and f.endswith('.aedat')
]

for file in onlyfiles:
    ae = paer.aefile('path/to/fyp-aedata-matlab/' + str(file))
    aed = paer.aedata(ae).downsample((16, 16))

    paer.create_pngs(aed,
                     '16x16_' + str(file) + '_',
                     path='testing_something',
                     step=3000,
                     dim=(16, 16))
コード例 #5
0
        else:
            polOne[0][cntOnes] = d1.x[x]
            polOne[1][cntOnes] = d1.y[x]
            polOne[2][cntOnes] = d1.ts[x] / 10**6
            cntOnes += 1

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.scatter(polZero[0][0:cntZeros],
               polZero[1][0:cntZeros],
               polZero[2][0:cntZeros],
               c='r',
               label='P=0')
    ax.scatter(polOne[0][0:cntOnes],
               polOne[1][0:cntOnes],
               polOne[2][0:cntOnes],
               c='b',
               label='P=1')
    ax.set_xlabel('x [px]')
    ax.set_ylabel('y [px]')
    ax.set_zlabel('z [s]')
    ax.set_xlim([0, 128])
    ax.set_ylim([0, 128])
    ax.set_zlim([0, max(d1.ts) / 10**6])
    ax.legend()
    plt.show()

# save the data into a new .aedat file
if save:
    lib = paer.aefile(filename, max_events=1)
    lib.save(d1, 'test.aedat')
コード例 #6
0
    sparse = aedata[min:max].make_sparse(
        np.floor(len(aefile.data) / num_events))

    actual_time = (sparse.ts[-1] - sparse.ts[0]) / 1000000
    scale = actual_time / animation_time
    sparse.ts = (offset * 1000000) + np.round(
        (sparse.ts - sparse.ts[0]) / scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000

    return sparse


# Loop through all files - indexes are extrapolated.
d1 = get_data(file1, 300000, 750000, offset=0 * animation_time)
d2 = get_data(file2, 300000, 600000, offset=1 * animation_time)
d3 = get_data(file3, 85000, 140000, offset=2 * animation_time)
d4 = get_data(file4, 65200, 131800, offset=3 * animation_time)

# Need to pre-load a file, to get the correct headers when writing!
lib = paer.aefile(file1, max_events=1)

final = paer.concatenate((d1, d2, d3, d4))
final_16 = final.downsample((16, 16))

lib.save(final, 'test.aedat')
lib.save(final_16, 'test_16.aedat')

d1.save_to_mat('test_1.mat')
d2.save_to_mat('test_2.mat')
d3.save_to_mat('test_3.mat')
d4.save_to_mat('test_4.mat')
コード例 #7
0
ファイル: make_pngs.py プロジェクト: darioml/python-aer
from os import listdir
from os.path import isfile, join
import paer

mypath = '/path/to/fyp-aedata-matlab'
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) and f.endswith('.aedat')]

for file in onlyfiles:
    ae = paer.aefile('path/to/fyp-aedata-matlab/' + str(file))
    aed= paer.aedata(ae).downsample((16,16))

    paer.create_pngs(aed, '16x16_' + str(file) + '_',path='testing_something',step=3000, dim=(16,16))


コード例 #8
0
    print 'Points: %i, Time: %0.2f. Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000,
                                                  np.floor(len(aefile.data)/num_events))

    sparse = aedata[min:max].make_sparse(np.floor(len(aefile.data)/num_events))

    actual_time = (sparse.ts[-1]-sparse.ts[0])/1000000
    scale = actual_time/animation_time
    sparse.ts = (offset * 1000000) + np.round((sparse.ts-sparse.ts[0])/scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000

    return sparse

# Loop through all files - indexes are extrapolated.
d1 = get_data(base_dir+file1, 300000, 750000, num_events=.75*(num_events_p_s*animation_time), offset=0*(animation_time+whitespate_time))
d2 = get_data(base_dir+file2, 300000, 600000, num_events=0.94*(num_events_p_s*animation_time), offset=1*(animation_time+whitespate_time))
d3 = get_data(base_dir+file3,  85000, 140000, num_events=1.205*(num_events_p_s*animation_time), offset=2*(animation_time+whitespate_time))
d4 = get_data(base_dir+file4,  65200, 131800, num_events=1.1*(num_events_p_s*animation_time), offset=3*(animation_time+whitespate_time))

# Need to pre-load a file, to get the correct headers when writing!
lib = paer.aefile(base_dir+file1, max_events=1)

final = paer.concatenate( (d1,d2,d3,d4) )
final_16 = final.downsample((16,16))

lib.save(final, 'aedat/200ms_ws_all_dirs.aedat')
lib.save(final_16, 'aedat/200ms_16_16_ws_all_dirs.aedat')

# d1.downsample().save_to_mat('mat/200ms_16_16_ws_norm_l2r.mat')
# d2.downsample().save_to_mat('mat/200ms_16_16_ws_norm_r2l.mat')
# d3.downsample().save_to_mat('mat/200ms_16_16_ws_norm_t2b.mat')
d4.downsample().save_to_mat('mat/200ms_16_16_ws_norm_b2t.mat')
コード例 #9
0
ファイル: downsampling.py プロジェクト: darioml/fyp-public
import paer

file = 'aedat/left_to_right_1.aedat'

lib = paer.aefile(file, max_events=750001)
data = paer.aedata(lib)

sparse = data[300000:750000].make_sparse(64).downsample((16,16))

sparse.save_to_mat('mat/16_16_left_to_right_1_1.mat')
lib.save(sparse, 'aedat/16_16_left_to_right_1_1.aedat')
コード例 #10
0
ファイル: downsampling.py プロジェクト: sms821/python-aer
import paer

file = '/path/to/left_to_right_1.aedat'

lib = paer.aefile(file, max_events=750001)
data = paer.aedata(lib)

sparse = data[300000:750000].make_sparse(64).downsample((16, 16))

sparse.save_to_mat('downsample_left_to_right_1_1.mat')
lib.save(sparse, 'downsample_left_to_right_1_1.aedat')
コード例 #11
0
ファイル: make_pngs.py プロジェクト: darioml/fyp-public
from os import listdir
from os.path import isfile, join
import paer

mypath = 'aedat/'
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) and f.endswith('.aedat')]

for file in onlyfiles:
    ae = paer.aefile(mypath + str(file))
    aed= paer.aedata(ae).downsample((16,16))

    paer.create_pngs(aed, '16x16_' + str(file) + '_',path='more_images/temp',step=3000, dim=(16,16))


コード例 #12
0
def get_data(file, max=10**60):
    aefile = paer.aefile(file, max_events=max + 1)
    aedata = paer.aedata(aefile)
    aetime = (aefile.timestamp[-1] - aefile.timestamp[0])
    print 'Points: %i, Time: %0.2f us' % (len(aefile.data), aetime)
    return aedata, aetime
コード例 #13
0
ファイル: animate_dvs.py プロジェクト: sms821/python-aer
import paer

data = paer.aedata(
    paer.aefile('/path/to/left_to_right_1.aedat', max_events=1000000))

data = data.make_sparse(64).downsample((16, 16))
data.interactive_animation(step=1000, limits=(0, 16))
コード例 #14
0
ファイル: animate_dvs.py プロジェクト: darioml/fyp-public
import paer

data = paer.aedata(paer.aefile('aedat/left_to_right_1.aedat', max_events=1000000))

data = data.make_sparse(64).downsample((16,16))
data.interactive_animation(step=1000,limits=(0,16))
コード例 #15
0
    print 'Points: %i, Time: %0.2f. Sparsity: %i' % (len(aefile.data), (aefile.timestamp[-1]-aefile.timestamp[0])/1000000,
                                                  np.floor(len(aefile.data)/num_events))

    sparse = aedata[min:max].make_sparse(np.floor(len(aefile.data)/num_events))

    actual_time = (sparse.ts[-1]-sparse.ts[0])/1000000
    scale = actual_time/animation_time
    sparse.ts = (offset * 1000000) + np.round((sparse.ts-sparse.ts[0])/scale)
    # print sparse_ts[0], sparse_ts[-1], sparse_ts[-1]-sparse_ts[0], (sparse_ts[-1]-sparse_ts[0])/1000000

    return sparse

# Loop through all files - indexes are extrapolated.
d1 = get_data(file1, 300000, 750000, offset=0*animation_time)
d2 = get_data(file2, 300000, 600000, offset=1*animation_time)
d3 = get_data(file3,  85000, 140000, offset=2*animation_time)
d4 = get_data(file4,  65200, 131800, offset=3*animation_time)

# Need to pre-load a file, to get the correct headers when writing!
lib = paer.aefile(file1, max_events=1)

final = paer.concatenate( (d1,d2,d3,d4) )
final_16 = final.downsample((16,16))

lib.save(final, 'test.aedat')
lib.save(final_16, 'test_16.aedat')

d1.save_to_mat('test_1.mat')
d2.save_to_mat('test_2.mat')
d3.save_to_mat('test_3.mat')
d4.save_to_mat('test_4.mat')
コード例 #16
0
# Count aedat files for progress bar
files = 0
for filename in os.listdir(directory):
    if filename.endswith(".aedat"):
        files += 1

# Timer output format
widgets = [
    'Processing ' + str(files) + ' files:',
    pb.Percentage(), ' ',
    pb.Bar(marker='|'), ' '
]

# Start timer
timer = pb.ProgressBar(widgets=widgets, maxval=files).start()
iter = 0

for filename in os.listdir(directory):
    if filename.endswith(".aedat"):
        d = paer.aedata(paer.aefile(filename))
        d = d.filter_events('OFF')
        d = d.take_v2(89).change_timescale(length=200, start=0)
        d.save_to_mat(os.path.splitext(filename)[0] + '.mat')

        #Update timer
        iter += 1
        timer.update(iter)

# Stop timer
timer.finish()
コード例 #17
0
def get_data(file):
    aefile = paer.aefile(file)
    aedata = paer.aedata(aefile)
    print 'Points: %i, Time: %0.2f' % (len(
        aefile.data), (aefile.timestamp[-1] - aefile.timestamp[0]) / (10**6))
    return aedata