ironbow_color_tracking.py
# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2024 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 単一色RGB565ブロブ追跡の例
#
# この例では、FLIR BOSONを使用したOpenMV Camで単一色のRGB565トラッキングを行う方法を示します。
import csi
import time
import image
# カラートラッキングのしきい値(L Min, L Max, A Min, A Max, B Min, B Max)
threshold_list = [(70, 100, -30, 40, 20, 100)]
# センサーを初期化します。
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.VGA)
csi0.color_palette(image.PALETTE_IRONBOW)
csi0.snapshot(time=5000)
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(
threshold_list, pixels_threshold=200, area_threshold=200, merge=True
):
img.draw_detection(blob)
print(clock.fps())