Welcome to K210 Module repository
3.QR code recognition
3 QR code recognition
3 QR code recognition 3.1 experimental goals 3.2 experimental procedure 3.3 experimental results 3.4 the experiments are summarized
3.1 experimental goals
This lesson is mainly learning the two-dimensional code recognition function, detecting whether the image with the QR code, if there is a box out and print the QR code information.
The present experiments the reference code path is: CanMV\05-AI\find_qrcodes.py
3.2 experimental procedure
The factory firmware of the module has integrated the AI vision algorithm module. If you have downloaded other firmware, please burn it back to the factory firmware before doing the experiment.
Import the relevant libraries and initialize the camera and LCD display.
import sensor, image, time, lcdlcd. init()sensor. reset()sensor. set_pixformat(sensor. RGB565)sensor. set_framesize(sensor. QVGA)sensor.skip_frames(time = 100)
Use the built-in find_qrcodes function to find whether there is a QR code, if the QR code to block it out, and print out the QR code information.
xxxxxxxxxxclock = time. clock()while(True):clock. tick()img = sensor. snapshot()for code in img. find_qrcodes():img. draw_rectangle(code. rect(), color = 127, thickness=3)print(code)lcd. display(img)#print(clock. fps())
3.3 experimental results
Connect the K210 module to the computer through the microUSB data cable, CanMV IDE click the connect button, after the connection is completed click the Run button to run the routine code. You can also download the code as main.py and run it in the K210 module.
Wait for the system initialization is complete, the LCD displays the camera screen, the camera captured the two-dimensional code, you can see QR code is box out, and in the bottom of the IDE serial terminal to print out the QR code information.


3.4 the experiments are summarized
QR code test can identify the use of the information that comes with the test image, it can also to find online QR code generator, generate additional own information of QR code.
