Optical Flow Center-X and Center-Y always 0

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

  1. import matplotlib.pyplot as plt
  2. from matplotlib.animation import FuncAnimation


  3. # Constants
  4. dt = 200
  5. start_ts = 0

  6. # Input for the file path
  7. filename = input('Path to the file: ')
  8. evts_iterator = EventsIterator(filename)
  9. reader = evts_iterator.reader
  10. # Get start timestamp from external trigger
  11. for evts in evts_iterator:
  12.     external_events = evts_iterator.get_ext_trigger_events()
  13.     if len(external_events) > 0:
  14.         start_ts = external_events[0]['t']
  15.         break


  16. # Initialize iterators and algorithms
  17. start_ts = int(start_ts / dt) * dt
  18. evts_iterator = EventsIterator(
  19.     filename, start_ts=start_ts, relative_timestamps=False, delta_t=dt)
  20. height, width = evts_iterator.get_size()
  21. activity_filter = ActivityNoiseFilterAlgorithm(
  22.     width, height, 500)  # 500 us threshold
  23. # 1: suppress on events, 0: suppress off events
  24. polarity_filter = PolarityFilterAlgorithm(0)
  25. flow = TimeGradientFlowAlgorithm(
  26.     width, height, radius=15, bit_cut=5, min_flow_mag=10)
  27. activity_buffer = activity_filter.get_empty_output_buffer()
  28. polarity_buffer = polarity_filter.get_empty_output_buffer()
  29. flow_buffer = flow.get_empty_output_buffer()


  30. # Prepare to store event data
  31. event_data_list = []
  32. query_points_list = []

  33. # Process events
  34. for evts in evts_iterator:
  35.     activity_filter.process_events(evts, activity_buffer)
  36.     polarity_filter.process_events(activity_buffer, polarity_buffer)
  37.     flow.process_events(polarity_buffer, flow_buffer)
  38.     processed_events = flow_buffer.numpy()
  39.     current_ts = evts_iterator.get_current_time()
  40.     event_data_list.append(processed_events)


  41. # Concatenate all collected data into single arrays
  42. if event_data_list:
  43.     X = np.concatenate(event_data_list, axis=0)
  44. else:
  45.     X = np.empty((0, 3), dtype=np.float64)


  46. # X is a 3D array with columns [x, y, t]
  47. # Plot the events in 3D
  48. fig = plt.figure()
  49. ax = fig.add_subplot(111, projection='3d')
  50. ax.set_xlabel('X')
  51. ax.set_ylabel('Y')
  52. ax.set_zlabel('Time')
  53. ax.set_xlim(0, width)
  54. ax.set_ylim(0, height)
  55. ax.set_zlim(0, current_ts)
  56. ax.set_title('Event data')
  57. ax.scatter(X['center_x'], X['center_y'], X['t'], c='r', marker='o')
  58. plt.show()



    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