genx320_histogram_grayscale_mode_with_tracking.py
# Эта работа лицензирована по лицензии MIT.
# Copyright (c) 2013-2024 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Этот пример демонстрирует использование событийной камеры genx320 от Prophesee.
import csi
import time
csi0 = csi.CSI(cid=csi.GENX320)
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize((320, 320))
csi0.brightness(128) # Обычно оставляйте 128 (значение по умолчанию).
csi0.contrast(16) # Увеличьте, чтобы изображение выглядело более контрастным.
# Частота кадров по умолчанию — 50 FPS. Вы можете изменить её в диапазоне примерно от 20 FPS до 350 FPS.
csi0.framerate(50)
clock = time.clock()
while True:
clock.tick()
img = csi0.snapshot()
# img.median(1) # устранение шума.
blobs = img.find_blobs(
[(120, 130)], invert=True, pixels_threshold=10, area_threshold=100, merge=True
)
for blob in blobs:
img.draw_detection(blob, color1=(255, 255, 255), color2=(0, 0, 0))
print(clock.fps())