yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
IMX 415 Camera Module📖
1. Jetson Orin Nano‑NX Usage Course
  • 1. Camera Driver Course
  • 2.1 Advanced AI Vision-Traffic Detection—DeepStream environment
  • 2.2 Advanced AI Vision-Traffic Detection—Four types of detection(traffic)
  • 3. YOLO11 Object Detection
  • 4. YOLO26 Object Detection
  • 5. Mediapipe Environment
  • 6. Mediapipe Hand Detection
  • 7. MediaPipe Face Detection
  • 8. MediaPipe Face Effects
  • 9. MediaPipe 3D Object Recognition
  • 10. MediaPipe Virtual Brush
  • 11. MediaPipe Gesture Recognition
  • 12. MediaPipe Finger Control
  • 13. MediaPipe Posture Estimation
  • 14. MediaPipe Face Mask
  • 15. MediaPipe Overall Detection
  • 16. MediaPipe Green Scene Rremoval(Human)
  • 17. QR code recognition
2. Raspberry Pi 5 Usage Course
  • 1. Camera Driver Course
  • 2. Advanced AI Vision-Human Pose Estimation
  • 3. Target Detection
  • 4. QR Code
  • 5. Face Detection
  • 6. Color Recognition
  • 7. YOLO11 Object Detection
  • 8. YOLO26 Object Detection
  • 9. MediaPipe Face Effects
  • 10. MediaPipe Face Detection
  • 11. MediaPipe 3D Object Recognition
  • 12. MediaPipe Virtual Brush
  • 13. MediaPipe Finger Control
  • 14. MediaPipe Gesture Recognition
3. RDK X5 Usage Course
  • 1. Camera Driver Course
  • 2. Target Detection Algorithm-FCOS
  • 3. Target Detection Algorithm-YOLOv5s
  • 4. YOLO26 Object Detection
4. Camera Bracket Installation (Optional Video)
  • Installation Video
Download
  • Code
  • SystemFile
  • 3D_Model_File
  • Hardware_Info
Download ZIP

Welcome to IMX 415 Camera Module repository

4. QR Code

QR Code

QR Code1. Introduction to QR Code2. Structure of QR Code3. Features of QR Code4. QR Code Creation and Recognition

1. Introduction to QR Code

A QR code is a type of two-dimensional barcode. QR comes from the abbreviation of the English "Quick Response", meaning quick response, which originates from the inventor's hope that the QR code can allow its content to be quickly decoded. QR codes not only have large information capacity, high reliability, and low cost, but can also represent multiple types of text information such as Chinese characters and images. They have strong anti-counterfeiting and confidentiality properties and are very convenient to use. More importantly, the QR code technology is open source.

2. Structure of QR Code

ImageExplanation
imgPositioning markings indicate the orientation of the QR code.
imgAlignment markings If the QR code is very large, these additional elements help with positioning.
imgTiming pattern Through these lines, the scanner can identify how large the matrix is.
imgVersion information This specifies the version number of the QR code being used. Currently, there are 40 different version numbers for QR codes. The version numbers used in the retail industry are usually 1-7.
imgFormat information The format pattern contains information about the error tolerance and data mask patterns, and makes scanning the code easier.
imgData and error correction keys These patterns store the actual data.
imgQuiet zone This area is very important for the scanner. Its function is to separate itself from the surrounding area.

3. Features of QR Code

The data value in a QR code contains repeated information (redundancy). Therefore, even if up to 30% of the QR code structure is damaged, the readability of the QR code is not affected. The storage space of a QR code is up to 7089 bits or 4296 characters, including punctuation marks and special characters, all of which can be written into the QR code. In addition to digits and characters, words and phrases (such as URLs) can also be encoded. As more data is added to the QR code, the code size increases and the code structure becomes more complex.

4. QR Code Creation and Recognition

Source code path: /home/pi/yahboomcar_ws/src/yahboomcar_visual/simple_qrcode

Installation

python3 -m pip install qrcode pyzbar
sudo apt-get install libzbar-dev
  • Creation

Create the qrcode object

xxxxxxxxxx
    '''
    Parameter meaning:
    version: an integer with a value of 1~40, controls the size of the QR code (the minimum is 1, which is a 12x12 matrix).
             If you want the program to determine it automatically, set the value to None and use the fit parameter.
    error_correction: controls the error correction function of the QR code. You can use the following 4 constants.
    ERROR_CORRECT_L: about 7% or less errors can be corrected.
    ERROR_CORRECT_M (default): about 15% or less errors can be corrected.
    ROR_CORRECT_H: about 30% or less errors can be corrected.
    box_size: controls the number of pixels contained in each small grid of the QR code.
    border: controls the number of grids contained in the border (the distance between the QR code and the image boundary) (the default is 4, which is the minimum value specified by the relevant standard)
    '''
    qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_H, box_size=5, border=4,)

Add a logo to the QR code

xxxxxxxxxx
    # If the logo path exists, add the logo image
    my_file = Path(logo_path)
    if my_file.is_file(): img = add_logo(img, logo_path)

Note: When using Chinese, Chinese characters need to be added.

xxxxxxxxxx
Run it directly using python3 + py file, then enter the content to be generated and press Enter to confirm.

image-20220219091955454

  • Recognition
xxxxxxxxxx
def decodeDisplay(image, font_path):
    gray = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
    # The output Chinese characters need to be converted into Unicode encoding form first
    barcodes = pyzbar.decode(gray)
    for barcode in barcodes:
        # Extract the position of the bounding box of the QR code
        (x, y, w, h) = barcode.rect
        # Draw the bounding box of the barcode in the image
        cv.rectangle(image, (x, y), (x + w, y + h), (225, 0, 0), 5)
        encoding = 'UTF-8'
        # To draw it, it first needs to be converted into a string
        barcodeData = barcode.data.decode(encoding)
        barcodeType = barcode.type
        # Draw the data and type on the image
        pilimg = Image.fromarray(image)
        # Create a brush
        draw = ImageDraw.Draw(pilimg) 
        # Parameter 1: font file path, Parameter 2: font size
        fontStyle = ImageFont.truetype(font_path, size=12, encoding=encoding)
        # Parameter 1: print coordinates, Parameter 2: text, Parameter 3: font color, Parameter 4: font
        draw.text((x, y - 25), str(barcode.data, encoding), fill=(255, 0, 0), font=fontStyle)
        # Convert PIL image to cv2 image
        image = cv.cvtColor(np.array(pilimg), cv.COLOR_RGB2BGR)
        # Print the barcode data and barcode type to the terminal
        print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
    return image
  • Effect demonstration
xxxxxxxxxx
Run it directly using python3 + py file
(To parse the code, run QRcode_Parsing_USB.py with a USB camera; run QRcode_Parsing_CSI.py with a CSI camera)

image-20210901152557779

Target Detection
Face Detection

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文