logo

识别二维码,屏蔽无效信息(特殊符号,小写字母),串口发送数据只留数字跟大写字母应该如何修改,求解答?

2022-03-29 19:59
A
ty3p
请import sensor, image, time, math
from pyb import UART
import json

threshold = [(0, 20, -18, 127, -8, 22), #black
(0, 70, -128, -28, 22, 127), #green
(0, 50, -128, 127, 12, 127)] #red

   sensor.reset()
   sensor.set_pixformat(sensor.RGB565)
   sensor.set_framesize(sensor.QQVGA) # can be QVGA on M7...
   sensor.skip_frames(30)
   sensor.set_auto_gain(False) # must turn this off to prevent image washout...
   sensor.set_auto_whitebal(False) # must be turned off for color tracking
clock = time.clock()
uart = UART(3, 19200)
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)
   output_str="%d,%d" % (code.x(), code.y())
    UART.write(output_str)
2022-03-29 20:11
I
网红小智智 星瞳科技

你把二维码的信息发一下。

2022-03-29 20:51
A
ty3p

示例:二维码信息为:/-A*1xB2C|3-<D4mE-5/,则有效数据为:A1B2C3D4E5。

2022-03-29 20:56
A
ty3p

@kidswong999 这个应该怎么屏蔽干扰信息然后去发送。

2022-03-30 19:55
I
网红小智智 星瞳科技

这个是代码:

raw = r'/-A*1xB2C|3-<D4mE-5/'
result = filter(str.isalnum, a)
print(result)

但是我还是想说一下,你说的这种干扰信息,在现实的场景下并不存在。

2022-04-01 08:36
A
ty3p

@kidswong999 好的谢谢

2022-04-01 14:57
A
ty3p

@kidswong999 您好这个要是只给发送二维码信息应该如何改(不发送坐标等,只发送出识别的结果)

2022-04-01 17:25
I
网红小智智 星瞳科技

@ty3p 新的问题单独发帖子。