find_datamatrices_w_lens_zoom.py
# Эта работа лицензирована по лицензии MIT.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Пример поиска Data Matrix с увеличением объектива
#
# Этот пример показывает, насколько легко обнаруживать коды Data Matrix с помощью
# камеры OpenMV Cam M7. Обнаружение 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())