grayscale_binary_filter.py

# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2023 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# グレースケール二値化フィルタの例
#
# このスクリプトでは、二値化画像フィルタを示します。binaryには
# 任意の数のしきい値を渡して画像をセグメント化できます。

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:
    # 低しきい値のテスト
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold])
        print(clock.fps())

    # 高しきい値のテスト
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold])
        print(clock.fps())

    # 低しきい値以外のテスト
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([low_threshold], invert=1)
        print(clock.fps())

    # 高しきい値以外のテスト
    for i in range(100):
        clock.tick()
        img = csi0.snapshot()
        img.binary([high_threshold], invert=1)
        print(clock.fps())

results matching ""

    No results matching ""