Пример #1
0
def pytestcase_load_n_events_second_test(dataset_dir):
    """Tests loading events of a file by n events with different values"""
    filename = os.path.join(dataset_dir,
                            "metavision_core", "event_io", "recording_td.dat")
    record = EventDatReader(filename)
    assert record.current_event_index() == 0
    assert record.event_count() == 667855
    events = record.load_n_events(824)
    assert record.current_event_index() == 824
    assert record.done is False
    # current time should be the timestamp of the event that will be loaded next
    assert record.current_time == 9814
    events = record.load_n_events(2)
    reference = np.array([(364, 97, 0, 9814), (254, 463, 0, 9824)],
                         dtype={'names': ['x', 'y', 'p', 't'], 'formats': ['<u2', '<u2', '<i2', '<i8'],
                                'offsets': [0, 2, 4, 8], 'itemsize': 16})

    assert all([np.allclose(events[name], reference[name]) for name in events.dtype.names])
    assert record.current_event_index() == 826
    assert not record.done
    # current time should be the timestamp of the last event + 1
    assert record.current_time == 9867
Пример #2
0
def pytestcase_init(dataset_dir):
    """Tests initialization of all member variables after creation of EventDatReader object from a file"""
    filename = os.path.join(dataset_dir,
                            "metavision_core", "event_io", "recording_td.dat")
    record = EventDatReader(filename)
    # check that the representation strings Works
    print(record)
    assert record.ev_type == 12
    assert record._ev_size == 8
    assert record.get_size() == [480, 640]
    assert EV_TYPES[record.ev_type] == [('t', 'u4'), ('_', 'i4')]

    assert record.event_count() == 667855
    assert record.done is False
    assert record.current_time == 0
    assert record.current_event_index() == 0
    assert record.duration_s == 7.702845
    assert record.load_n_events(1).dtype == np.dtype({'names': ['x', 'y', 'p', 't'],
                                                      'formats': ['<u2', '<u2', '<i2', '<i8'],
                                                      'offsets': [0, 2, 4, 8], 'itemsize': 16})