[Automatic clock-in walking timing system based on face recognition] K210 MAIXBIT uses QR code recognition as user information
[Copy link]
Debug Target
- Considering that the K210 has relatively few interactive interfaces, the user information entry method is considered to be a QR code. The ID name can be scanned once, and then the user is prompted by voice that the entry is successful.
Debugging preparation
- Based on the previous post about the playback of wav voice, you first need to use GoldenWav CN software to convert text to speech and prepare a "successful recognition" voice file.
- Use the grass QR code (https://cli.im/text) to convert a QR code containing the following information: "eeworld,123654,01:02:03:04:05:06,cs".
Debugging Code
import sensor
import image
import lcd
import time
from fpioa_manager import *
from Maix import I2S, GPIO
import audio
def audio_init():
# register i2s(i2s0) pin
fm.register(34, fm.fpioa.I2S0_OUT_D1, force=True)
fm.register(35, fm.fpioa.I2S0_SCLK, force=True)
fm.register(33, fm.fpioa.I2S0_WS, force=True)
# init i2s(i2s0)
wav_dev = I2S(I2S.DEVICE_0)
print("i2s init")
return wav_dev
def audio_play(wav_dev, volume):
# init audio
player = audio.Audio(path="/sd/2.wav")
player.volume(volume)
print("audio init")
# read audio info
wav_info = player.play_process(wav_dev)
# config i2s according to audio info
wav_dev.channel_config(wav_dev.CHANNEL_1, I2S.TRANSMITTER, resolution=I2S.RESOLUTION_16_BIT,
cycles=I2S.SCLK_CYCLES_16, align_mode=I2S.RIGHT_JUSTIFYING_MODE)
wav_dev.set_sample_rate(wav_info[1])
# loop to play audio
while True:
ret = player.play()
if ret == None:
print("format error")
break
elif ret == 0:
print("end")
break
player.finish()
#-----------------------------------------------------------
clock = time.clock()
dev = audio_init()
lcd.init()
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_vflip(1)
sensor.run(1)
sensor.skip_frames(30)
while True:
clock.tick()
img = sensor.snapshot()
res = img.find_qrcodes()
fps =clock.fps()
if len(res) > 0:
img.draw_string(2, 2, res[0].payload(), color=(0,128,0), scale=2)
print(res[0].payload())
audio_play(dev, 50)
lcd.display(img)
Debugging results
- When the QR code is presented on a mobile phone, a string of characters will appear on the interface and a voice prompt will be played, indicating successful recognition!
|