Skip to content

Incorrect events decoding using numpy 2.x #19

@andberto

Description

@andberto

Hi,
I'm trying to decode events from a ROS bag recorded with the sensor Prophesee EVK4 (IMX636) so the event codec should be EVT3.0.
Using the example provided I obtain events that are not correct (i.e x > senso_with, y > sensor_height, polarity not in {-1, 1} wrong timestamps).

Here's my code:

import argparse
import glob
import os
from bag_reader_ros2 import BagReader
from event_camera_py import Decoder

def extract_bag(input, output, event_topic):
    bag = BagReader(input, event_topic)
    decoder = Decoder()
    while bag.has_next():
        topic, msg, t_rec = bag.read_next()
        print(topic)
        decoder.decode_bytes(msg.encoding, msg.width, msg.height,
                             msg.time_base, msg.events.tobytes())
        cd_events = decoder.get_cd_events()
        print(cd_events)

def main(args=None):
    parser = argparse.ArgumentParser()
    parser.add_argument("path", help="ROS 2 bag file to extract or directory containing bags")
    parser.add_argument("--output_dir", default="/tmp/extracted_data", help="Folder where to extract the data")
    parser.add_argument("--events_topic", default="/event_camera/events", help="Event camera topic")
    args = parser.parse_args()

    bag_path = ''
    
    print(f'Data will be extracted in folder: {args.output_dir}')
    if not os.path.exists(args.output_dir):
        os.makedirs(args.output_dir)
    if os.path.isdir(args.path):
        bag_path = sorted(glob.glob(os.path.join(args.path, "*.db3")))[0]
    else:
        bag_path = args.path

    extract_bag(input = bag_path, output = args.output_dir, event_topic = args.events_topic)

if __name__ == '__main__':
    main()

Some events i'm obtaining:

[( 879, 16, 0, 5962275) (59904, 16948, 37, 14287178)
(64039, 90, 116, 1110764033) ... (32480, 16922, 100, -1017008928)
(24158, 52683, 1, 449) (32480, 16922, 100, -1017008928)]

Thank you in advance for the help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions