
Then use the detectAndDecode method to parse the QR code. In the main function, we first read the image. The default OpenCV detector uses traditional computer vision methods for detection and decoding. You can also download these files from this link. We have included these files in the model directory. A model weights file (“model.caffemodel”) contains the weights and biases learned in the training process.A model architecture file (“model.prototxt”).The two CNN models are in the Caffe Deep Learning framework format which consists of two files. It is, therefore, able to deliver superior results when the resolution of the QR code is small (e.g., when you are scanning it from far away.) WeChat QR code scanner uses a super-resolution model to enhance the resolution of the QR code. Super Resolution Model: The class of techniques used for improving the resolution of an image is called Super Resolution.Detector Model: This CNN model is used to locate the QR code.WeChat QR code scanner uses two CNN models internally.

Now, without further ado, let’s dive into the code.Ĭv2.line(im, tuple(bbox), tuple(bbox), (0,255,0), 3) Navigate to the code folder, fire up terminal/powershell and install the required packages using the requirements.txt file. Please download the code from the link above. The WeChat QR code scanner is part of the opencv-contrib repository. Moreover, there are plenty of good online resources explaining QR code. If you are interested in knowing how a QR code is encoded and decoded, check out this link for more information. In this blog post, we are not going to discuss every parameter in detail. The scanner detects the QR code with the help of these parameters and decodes the data. The higher the level, the lower is the storage capacity. Based on the level of error correction, there can be 4 different categories. Error correction level tells about the percentage of data bytes that can be recovered. There are 40 different types of QR code based on the timing. The timing (repeating black and white pattern between position boxes) provides information about the size of the QR code. The distinct black squares containing smaller squares are the tracker boxes that help determine the position and rotation of the QR code. Five parameters describe the format of a QR code to the decoder.


The illustration shows the format parameters of a QR code.
