Example: 04-Barcodes/find_datamatrices.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Find Data Matrices Example
#
# This example shows off how easy it is to detect data matrices using the
# OpenMV Cam M7. Data matrices detection does not work on the M4 Camera.

import sensor
import time
import math

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time=2000)
sensor.set_auto_gain(False)  # 必须关闭此功能以防止图像褪色...
sensor.set_auto_whitebal(False)  # 必须关闭此功能以防止图像褪色...
clock = time.clock()

while True:
    clock.tick()
    img = sensor.snapshot()
    img.lens_corr(1.8)  # 1.8的强度对于2.8mm镜头来说很好。

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