grayscale_binary_filter.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 Binärfilter bei Graustufenbildern
#
# Dieses Skript demonstriert den Binärbildfilter. Sie können binary() eine beliebige
# Anzahl von Schwellenwerten übergeben, nach denen das Bild segmentiert wird.

import csi
import time

csi0 = csi.CSI()
csi0.reset()
csi0.framesize(csi.QVGA)
csi0.pixformat(csi.GRAYSCALE)
csi0.snapshot(time=2000)

clock = time.clock()

low_threshold = (0, 50)
high_threshold = (205, 255)

while True:
    # Unteren Schwellenwert testen
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold])
        print(clock.fps())

    # Oberen Schwellenwert testen
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold])
        print(clock.fps())

    # Nicht-unteren Schwellenwert testen
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold], invert=1)
        print(clock.fps())

    # Nicht-oberen Schwellenwert testen
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold], invert=1)
        print(clock.fps())

results matching ""

    No results matching ""