ir_beacon_grayscale_tracking.py

# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2023 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# IRビーコングレースケール追跡の例
#
# この例では、OpenMV Camを使ったIRビーコンのグレースケール追跡を示します。

import csi
import time

thresholds = (255, 255)  # IRからの明るい白色光のしきい値。

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.VGA)
csi0.window((240, 240))  # VGAの中央240x240ピクセル
csi0.snapshot(time=2000)
csi0.auto_gain(False)  # カラートラッキングでは無効にする必要があります
csi0.auto_whitebal(False)  # カラートラッキングでは無効にする必要があります

clock = time.clock()

# ピクセル数が"pixel_threshold"より多く、面積が"area_threshold"より大きいブロブのみが
# 以下の"find_blobs"によって返されます。カメラの解像度を変更する場合は
# "pixels_threshold"と"area_threshold"を変更してください。"merge=True"にすると画像内の重なり合うブロブがすべて統合されます。

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):  # 正方形に近くないブロブを除外します
            img.draw_detection(blob)
    print(clock.fps())

results matching ""

    No results matching ""