Skip to content

Basic scripts showing how to work with data from Prophesee sensors in MATLAB

License

Notifications You must be signed in to change notification settings

prophesee-ai/prophesee-matlab-scripts

Repository files navigation

MATLAB scripts

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.

Main features

The MATLAB scripts allow to:

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.

Uploading CD data to MATLAB

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 matrix
  • y - y-position of the event in the sensor matrix
  • ts - timestamp of the event
  • p - polarity of the event

Example of script execution:

cd_data = load_cd_events("/path/to/my_record.dat")

Generating a video and frames from CD events

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 events
  • width - width of the sensor
  • height - height of the sensor
  • framerate - frame rate of the output file
  • acc_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)

Contact

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

About

Basic scripts showing how to work with data from Prophesee sensors in MATLAB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages