find_datamatrices_w_lens_zoom.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 使用镜头缩放查找数据矩阵示例
#
# 此示例展示了使用OpenMV Cam M7检测Data Matrix码是多么容易。
# Data Matrix检测无法在M4摄像头上运行。

import csi
import time
import math

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)
csi0.window((320, 240))  # 2倍缩放
csi0.snapshot(time=2000)
csi0.auto_gain(False)  # 必须关闭此功能以防止图像褪色...
csi0.auto_whitebal(False)  # 必须关闭此功能以防止图像褪色...

clock = time.clock()

while True:
    clock.tick()
    img = csi0.snapshot()

    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 ""