grayscale_binary_filter.py

# Ce travail est publié sous licence MIT.
# Copyright (c) 2013-2023 OpenMV LLC. Tous droits réservés.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Exemple de filtre binaire en niveaux de gris
#
# Ce script montre le filtre d'image binaire. Vous pouvez passer à binary un
# nombre quelconque de seuils pour segmenter l'image.

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:
    # Tester le seuil bas
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold])
        print(clock.fps())

    # Tester le seuil haut
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold])
        print(clock.fps())

    # Tester non seuil bas
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold], invert=1)
        print(clock.fps())

    # Tester non seuil haut
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold], invert=1)
        print(clock.fps())

results matching ""

    No results matching ""