In this repo you will find some basic scripts to show how to work with data from Prophesee sensors in MATLAB. These scripts require a DAT file as an input with data recorded with one of our cameras.
If you only have a RAW file, you need to convert it to DAT format first. To this end, use our application metavision_file_to_dat which is part of Metavision SDK.
To try out those scripts, you can also download and use one of the RAW and DAT files we provide.
The MATLAB scripts allow to:
load_cd_events.m
: uploads CD events to MATLABload_em_events.m
: uploads EM events to MATLAB (deprecated for the current sensor generation)load_ext_trigger_data.m
: uploads data from external triggers to MATLABplay_cd_recording.m
: generates a video from CD eventsgenerate_em_snapshot.m
: generates gray-scale images from EM events (deprecated for the current sensor generation)
Note that by default the provided scripts will attempt to upload the entire DAT files into memory. Therefore, it will be useful to split your DAT file into several smaller files at first, or modify the Matlab scripts to limit the memory requirements.
The script load_cd_events.m
provides an example of uploading CD events to MATLAB.
The function load_cd_events
requires the following input arguments:
- path to DAT file with recorded CD events
- flipX flag - for flipping data over the X axis (0 by default)
- flipY flag - for flipping data over the Y axis (0 by default)
The script returns a data structure containing the following fields for every CD event:
x
- x-position of the event in the sensor matrixy
- y-position of the event in the sensor matrixts
- timestamp of the eventp
- polarity of the event
Example of script execution:
cd_data = load_cd_events("/path/to/my_record.dat")
The script play_cd_recording.m
provides an example of generating a video from CD events and replaying this video.
The function play_cd_recording
requires the following input arguments:
filename
- path to a DAT file with recorded CD eventswidth
- width of the sensorheight
- height of the sensorframerate
- frame rate of the output fileacc_time
- accumulation time (in microseconds). This is the duration during which each event will be shown
The script returns a structure containing a sequence of frames generated by iteratively accumulating the information from the CD events. Each frame shows the CD events generated by the sensor over the given accumulation time duration preceding the timestamp associated with the frame. For instance, if the given frame rate is 1000 FPS (frames per seconds) and the accumulation time is 10000 µs (microseconds), each CD event will be displayed during 10 frames. See Generating frames from CD events SDK doc page to know more on this topic.
For example, for a Gen3 sensor, the following command will generate a 25 FPS video with the accumulation time of 10000 µs:
play_cd_recording('/path/to/my_record.dat',640,480,25,10000)
This code is open to contributions, thus do not hesitate to propose pull requests or create/fix bug reports.
For any other information, contact us