How to get time mat of time surface in Python

40 views
Skip to first unread message

Jinghang Li

unread,
Jul 14, 2023, 12:07:18 PM7/14/23
to dv-users
Dear all,

I am using the TimeSurface() Class in dv_processing and found that there is no function provided in the Class to read out the generated timesurface as a mat, I can only traverse each pixel one by one through getitem() to read out the time values in it, is there any way to read out all the values in it quickly?

Many thanks,
Jhang

jonatan....@gmail.com

unread,
Jul 14, 2023, 12:17:07 PM7/14/23
to dv-users
Hi Jihang, 
Can you please provide a code snippet of how you use it? I am not sure I understand what you want. 


You can also see a general use of TimeSurface() here: https://dv-processing.inivation.com/rel_1.7/accumulators.html#time-surface

Best,
Jonatan

Jinghang Li

unread,
Jul 14, 2023, 12:51:04 PM7/14/23
to dv-users
Dear Jonatan

Thank you for your reply! My code snippet is as follows:
2023-07-15_00-29.png

I want to store the generated time surface in 1 channel numpy array format so that I can do subsequent operations on the generated time surface.
The generateFrame() gets the converted 3-channel image format output, not what I need.

Also, I would like to ask if the result of dv.Accumulator() can also be stored in numpy array format? Because I want to get the time surface with time gradient information, but it seems that only dv.Accumulator() can set the time decay function. Like picture blow.

aa.pnga2.png

Many thanks,
Jhang

jonatan....@gmail.com

unread,
Jul 17, 2023, 9:35:36 AM7/17/23
to dv-users

Hi Jhang, 

generateFrame() should only output a 1 channel image if frame.image is called. This representation is in range [0,255]. This is scaled since the data in the time surface is of sign 64bit int, which a matrix using openCV can't handle. If you want the true time surface, you indeed need to call it as you described in the red box of your code.  


For dv.Accumulator I think you want to use getPotentialSurface(). However, it's not available through python bindings but only using c++ library of dv-processing. I'll look into why it's not implemented in python library but this might take some time and don't expect a quick fix. 


Best, 

Jonatan

Reply all
Reply to author
Forward
0 new messages