prophesee-ai / prophesee-automotive-dataset-toolbox

A set of Python scripts to evaluate the Automotive Datasets provided by Prophesee
Apache License 2.0
157 stars 30 forks source link

trouble reading the data #14

Closed munirfarzeen closed 3 years ago

munirfarzeen commented 3 years ago

Hi, I am trying to visualize the data using code you have provided. The events and boxes are coming up empty. Any idea why? events = videos.load_delta_t(delta_t) box_events = box_videos.load_delta_t(delta_t) for index, (evs, boxes) in enumerate(zip(events, box_events)):

thank you for your help

etienne87 commented 3 years ago

Hi, can you tell us which recording you are processing?

munirfarzeen commented 3 years ago

@etienne87 test_b/17-04-04_11-00-13_cut_15_61500000_121500000_td.dat from Gen1 data

munirfarzeen commented 3 years ago

@etienne87 @dmigliore @laurentbristiel @nlyubova Hello, i am having trouble reading the .dat file. Can you guys help me in reading the data off .dat file and visualise as image. i understand the data is in binary format. If i use function the following function

`record = EventDatReader(path) height, width = record.get_size() print('record dimensions: ', height, width) start_ts = 1 * 1e6 record.seek_time(start_ts) # seek in the file to 1s

delta_t = 50000 #sampling duration events = record.load_delta_t(delta_t) `

the events out put is xypt, how can i trsnform it into image? thank you for your help

etienne87 commented 3 years ago

hi @likui01. Glad that you are able to load events.

img = np.zeros((height,width,3), dtype=np.uint8)
p = events['p']
y_on = events['y'][p]
y_off = events['y'][p==0]
x_on = events['x'][p]
x_off = events['x'][p==0]
img[y_on, x_on, 1] = 255
img[y_off, x_off, 2] = 255

this is an example for visualization, it does not take time nor number of events per pixel into account.

munirfarzeen commented 3 years ago

@etienne87 Thank you for your reply. I was successfully able to visualize the events and their labels. Now if I want to save events of 10ms and their corresponding labels, how would I do that. saving the events in the image frame I understand, but I am confused about the labels? thank you.

etienne87 commented 3 years ago

Our bbox format has a numpy structured dtype, so if you want to rewrite an array of box events, you can just use:

np.save("box_file.npy", box_events) 
munirfarzeen commented 3 years ago

how do I sync event frames and labels?

etienne87 commented 3 years ago

if you want to load a specific duration you can use our openeb code: https://github.com/prophesee-ai/openeb/blob/main/sdk/modules/core/python/pypkg/metavision_core/event_io/py_reader.py#L287

box_video = EventNpyReader(box_path)
box_video.seek_time(start_time + 1)
box_events = box_video.load_delta_t(duration)