genx320_event_mode_high_speed.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2025 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 此示例展示了如何使用Prophesee的GENX320事件相机,
# 使用事件流模式。
#
# 此示例没有帧缓冲可视化,以便以极快速度运行。

import csi
import time
# https://micropython-ulab.readthedocs.io/en/latest/index.html
from ulab import numpy as np

# 存储相机事件
# 形状:(EVT_res, 6),其中EVT_res是事件分辨率
# EVT_res:必须是1024到65536之间的2的幂。
# 各列含义:
# [0]  事件类型
# [1]  秒时间戳
# [2]  毫秒时间戳
# [3]  微秒时间戳
# [4]  X坐标,GENX320为0到319
# [5]  Y坐标,GENX320为0到319
events = np.zeros((2048, 6), dtype=np.uint16)

# 初始化传感器。
csi0 = csi.CSI(cid=csi.GENX320)
csi0.reset()
csi0.ioctl(csi.IOCTL_GENX320_SET_MODE, csi.GENX320_MODE_EVENT, events.shape[0])

clock = time.clock()
t = time.ticks_us()

i = 0
while True:
    clock.tick()
    t1 = time.ticks_us()
    diff = time.ticks_diff(t1, t)
    t = t1
    i += 1

    # 从相机读取最多2048个事件。
    # 返回有效事件数(0-2048)或负的错误码。
    # 注意,为节省CPU时间,缓冲区中的旧事件不会被清除。
    event_count = csi0.ioctl(csi.IOCTL_GENX320_READ_EVENTS, events)

    # 对事件速率输出进行降采样,以免影响事件数据处理的性能。
    # 在高事件速率下,向IDE发送统计输出的开销
    # 可能变得相当可观。
    if not i % 10:
        print(f'{event_count} events\t{clock.fps()} fps\t{diff} us')

results matching ""

    No results matching ""