Optical Flow Center-X and Center-Y always 0
I'm running into a strange problem where I am trying to process the optical flow of data and plot their position over time using the center_x and center_y values. For some reason, the center_x and center_y values are all essentially zero with some floating point error. I have a snip from the data in the Metavision Studio software below. I have a ROI set and no other filtering. I wanted to see the actual event x and y data, so I examined the 'x' and 'y' properties of the optical flow data and found that they span the expected range, with some reporting values that were well out of bounds (25743 and above). I'm not sure why that happens or if it's related.
My code is below
- import matplotlib.pyplot as plt
- from matplotlib.animation import FuncAnimation
- # Constants
- dt = 200
- start_ts = 0
- # Input for the file path
- filename = input('Path to the file: ')
- evts_iterator = EventsIterator(filename)
- reader = evts_iterator.reader
- # Get start timestamp from external trigger
- for evts in evts_iterator:
- external_events = evts_iterator.get_ext_trigger_events()
- if len(external_events) > 0:
- start_ts = external_events[0]['t']
- break
- # Initialize iterators and algorithms
- start_ts = int(start_ts / dt) * dt
- evts_iterator = EventsIterator(
- filename, start_ts=start_ts, relative_timestamps=False, delta_t=dt)
- height, width = evts_iterator.get_size()
- activity_filter = ActivityNoiseFilterAlgorithm(
- width, height, 500) # 500 us threshold
- # 1: suppress on events, 0: suppress off events
- polarity_filter = PolarityFilterAlgorithm(0)
- flow = TimeGradientFlowAlgorithm(
- width, height, radius=15, bit_cut=5, min_flow_mag=10)
- activity_buffer = activity_filter.get_empty_output_buffer()
- polarity_buffer = polarity_filter.get_empty_output_buffer()
- flow_buffer = flow.get_empty_output_buffer()
- # Prepare to store event data
- event_data_list = []
- query_points_list = []
- # Process events
- for evts in evts_iterator:
- activity_filter.process_events(evts, activity_buffer)
- polarity_filter.process_events(activity_buffer, polarity_buffer)
- flow.process_events(polarity_buffer, flow_buffer)
- processed_events = flow_buffer.numpy()
- current_ts = evts_iterator.get_current_time()
- event_data_list.append(processed_events)
- # Concatenate all collected data into single arrays
- if event_data_list:
- X = np.concatenate(event_data_list, axis=0)
- else:
- X = np.empty((0, 3), dtype=np.float64)
- # X is a 3D array with columns [x, y, t]
- # Plot the events in 3D
- fig = plt.figure()
- ax = fig.add_subplot(111, projection='3d')
- ax.set_xlabel('X')
- ax.set_ylabel('Y')
- ax.set_zlabel('Time')
- ax.set_xlim(0, width)
- ax.set_ylim(0, height)
- ax.set_zlim(0, current_ts)
- ax.set_title('Event data')
- ax.scatter(X['center_x'], X['center_y'], X['t'], c='r', marker='o')
- plt.show()
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