ir_beacon_grayscale_tracking.py
# Dieses Werk ist unter der MIT-Lizenz lizenziert.
# Copyright (c) 2013-2023 OpenMV LLC. Alle Rechte vorbehalten.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Beispiel für IR-Beacon-Tracking in Graustufen
#
# Dieses Beispiel zeigt das IR-Beacon-Tracking in Graustufen mit der OpenMV Cam.
import csi
import time
thresholds = (255, 255) # Schwellenwerte für helles weißes Licht von IR.
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.VGA)
csi0.window((240, 240)) # 240x240 mittlere Pixel von VGA
csi0.snapshot(time=2000)
csi0.auto_gain(False) # muss für das Farb-Tracking deaktiviert werden
csi0.auto_whitebal(False) # muss für das Farb-Tracking deaktiviert werden
clock = time.clock()
# Nur Blobs, die mehr Pixel als "pixel_threshold" und eine größere Fläche als "area_threshold" haben, werden
# von "find_blobs" unten zurückgegeben. Ändern Sie "pixels_threshold" und "area_threshold", wenn Sie die
# Kameraauflösung ändern. "merge=True" führt alle sich überlappenden Blobs im Bild zusammen.
while True:
clock.tick()
img = csi0.snapshot()
for blob in img.find_blobs(
[thresholds], pixels_threshold=200, area_threshold=200, merge=True
):
ratio = blob.w / blob.h
if (ratio >= 0.5) and (ratio <= 1.5): # nicht annähernd quadratische Blobs herausfiltern
img.draw_detection(blob)
print(clock.fps())