find_datamatrices.py

# この作品はMITライセンスの下で提供されています。
# Copyright (c) 2013-2023 OpenMV LLC. 全著作権所有。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# データマトリクス検出の例
#
# この例では、OpenMV Cam M7を使ってデータマトリクスを検出するのがいかに簡単かを
# 示します。データマトリクス検出はM4カメラでは動作しません。

import csi
import time
import math

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.QVGA)
csi0.snapshot(time=2000)
csi0.auto_gain(False)  # 画像の白飛びを防ぐため、これをオフにする必要があります……
csi0.auto_whitebal(False)  # 画像の白飛びを防ぐため、これをオフにする必要があります……

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()
    img.lens_corr(1.8)  # 2.8mmレンズには1.8の強度が適しています。

    matrices = img.find_datamatrices()
    for matrix in matrices:
        img.draw_rectangle(matrix.rect, color=(255, 0, 0))
        print_args = (
            matrix.rows,
            matrix.columns,
            matrix.payload,
            (180 * matrix.rotation) / math.pi,
            clock.fps(),
        )
        print(
            'Matrix [%d:%d], Payload "%s", rotation %f (degrees), FPS %f' % print_args
        )
    if not matrices:
        print("FPS %f" % clock.fps())

results matching ""

    No results matching ""