例程讲解16-Codes->find_datamatrices 矩形码识别
import sensor, image, time, 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)
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())
星瞳科技OpenMV官方中文文档函数讲解: