Help generating an event rate per allocation period plot

Help generating an event rate per allocation period plot

I am running the following code to plot event rates as a function of allocation time. Unfortunately, python crashes without any error when I call histo for the first time. Looking at it as far as I can, it seems the error is occurring on the C side. I guess it's a memory issue since this doesn't occur when using fewer bins. So I have a few questions.

1. Is this the right way to produce this information?
2. If it is, is there a preprocessing step I could/should perform to reduce the amount of data required? I considered the ROIFilterAlgorithm, but I assume I would need to normalize the x and y values to avoid allocating the full sensor width and height.

from metavision_ml.preprocessing import histo
import numpy as np
from metavision_core.event_io import RawReader
import matplotlib.pyplot as plt
from tqdm import tqdm

file = input('Enter the path to the input file: ').strip()
rates = []
dt = int(1e6) # 1s
record = RawReader(file)
# record.seek_time(1e6) # skip first second if needed
events = record.load_delta_t(dt)
events['t'] -= events[0]['t'] # important! almost all preprocessing use relative time!
height, width = record.get_size()

tbins = np.arange(100, 1000, 100) # Time bins from 100us to 1ms

for tb in tqdm(tbins):
volume = np.zeros((dt // tb, 2, height, width), dtype=np.float32)
histo(events, volume, tb)
# combine the two polarities
im = volume.sum(axis=1) # sum the two polarities
# average the time bins
im = im.mean(axis=0) # average the time bins
# flatten the image
im = im.flatten() # 1D array
# Calculate the event rate
rates.append(np.count_nonzero(im) / im.size)
del volume # free memory

    As a Prophesee customer, join the community conversation. 
    Request your free access today.

      Information

      In this Community Forum, you can discuss products, technology and applications. Only registred users can post but everyone can read. To ask a private question, enter a support ticket in My Area https://support.prophesee.ai/portal/en/newticket