logo

openmv串口发送中文会乱码这是为什么,数字和英文不会?

2022-07-08 13:05
G
_1d6n

# 二维码例程

#

# 这个例子展示了OpenMV Cam使用镜头校正来检测QR码的功能(请参阅qrcodes_with_lens_corr.py脚本以获得更高的性能)。

import sensor, image, time

from pyb import UART

sensor.reset()

sensor.set_pixformat(sensor.RGB565)

sensor.set_framesize(sensor.QVGA)

sensor.skip_frames(time = 2000)

sensor.set_auto_gain(False) # 必须关闭此功能,以防止图像冲洗…

clock = time.clock()

uart3 = UART(3, 9600)

while(True):

clock.tick()

img = sensor.snapshot()

img.lens_corr(1.8) # 1.8的强度参数对于2.8mm镜头来说是不错的。

for code in img.find_qrcodes():

img.draw_rectangle(code.rect(), color = (255, 0, 0))

print(code.payload())

uart3.write(code.payload())

uart3.write("\r\n")

#print(clock.fps())

二维码中扫出来的数据是张三,打印到openmvIDE上的是对的的,打印到串口就是乱码

2022-07-11 15:51
I
网红小智智 星瞳科技

OpenMV上使用的utf8编码,你生成二维码的时候,中文使用utf8编码。