Airfrog editorial team ·

OpenCV Does Not Detect a QR Code: QRCodeDetector and WeChat

What to do when detectAndDecode returns an empty string or detectAndDecodeMulti misses codes. How QRCodeDetector differs from WeChat QRCode, and how to evaluate alternatives.

An empty string from detectAndDecode is not a diagnosis

Separate file loading, region detection, and text decoding. If cv2.imread returns None, the problem occurred before the QR detector ran. If corners are present but the text is empty, finding a region does not mean decoding succeeded. Record the OpenCV version and save the source frame so you can repeat the check.

Check whether resizing made the QR code too small, whether the quiet zone is visible, and whether the image is blurred or overexposed. Image preprocessing may help one frame and hurt another; keep the original and measure changes across the full sample, not just the frame that failed.

Multiple QR codes: detectAndDecodeMulti and partial results

import cv2

image = cv2.imread("frame.png")
if image is None:
    raise ValueError("Could not read image")
ok, texts, points, _ = cv2.QRCodeDetector().detectAndDecodeMulti(image)
if ok and points is not None:
    for text, corners in zip(texts, points):
        if text:
            print(text, corners)

The example uses QRCodeDetector's multi-code method. Check each string: an empty string in the results is not a decoded QR code. If your task is to read every label, compare the number of correct objects with the expected count, not just the ok flag. Keep duplicate text values until you have matched them by position.

Check the syntax against the documentation for your version. Your test sample should include one QR code, several different codes, repeated text, and images with no codes. Read more about reading every QR code in one image.

WeChat QRCode is a separate detector

The wechat_qrcode module in OpenCV-contrib uses its own pipeline and detection and upscaling models. It is not another name for the standard QRCodeDetector. Having cv2 installed does not guarantee that this module or its model files are included in your build.

Before integration, check the build contents, whether model paths resolve, and which model file versions are present. Decide whether model loading is included in your latency measurements. For a long-running process, measure startup separately from processing with the detector already loaded.

References: QRCodeDetector, multi-code decoding with GraphicalCodeDetector, WeChat QRCode models.

When to evaluate an OpenCV alternative

If the same difficult frames regularly require another capture, compare QRCodeDetector, WeChat, ZXing-C++, and Airfrog on the same sample. Measure complete reads, false results, and time. Our benchmark reports standard OpenCV and WeChat separately; combining them into one “OpenCV quality” result would be misleading.

Airfrog's Python API accepts image bytes; its result format and errors differ from OpenCV's. Keep image processing in your existing pipeline if you need it, but measure the cost of converting data before replacing the QR decoder.

A step-by-step QRCodeDetector diagnosis

“The QR is visible in the photo, but OpenCV returned nothing” can describe several different problems. Save the failing file and check the stages in order so you know what changed on the next attempt.

  1. Open the same file the application receives. Confirm it is the full frame from the intended camera, not a thumbnail or a file that is still being written.
  2. Inspect the QR at its original scale. Enlarging it on screen makes blur easier to see, but adds no detail. Check the edges of small modules and the quiet zone around the code.
  3. Separate detection from decoding. Found corners with empty text indicate a different failure stage than no detected region.
  4. Compare the full frame with a crop. If the cropped QR decodes, investigate its scale and detection in the full frame. If the crop also fails, check print quality and which details remain.
  5. Repeat the test on the other images. Higher contrast or a new binarization step should help the intended group without breaking ordinary cases.

A useful failure report includes the source image, OpenCV version, method used, dimensions before and after preprocessing, returned text, and corners. This lets you compare another version or decoder without guessing what differed between runs.

OpenCV QR detection FAQ

Why does it detect one QR code when the frame has several?

Check that you call detectAndDecodeMulti, then inspect every result string. If you already use the multi-code method, compare the full frame with cropped regions: nearby labels, scale, and background can affect detection.

Should I always convert the image to black and white?

Do not add hard binarization without testing it. It can erase weak edges on a shaded label. Compare the original input with the processed version on the same sample, and keep track of failed attempts.

Can I keep OpenCV and replace only QR decoding?

Yes. Your application can keep using OpenCV to capture and prepare frames, then send them to another library for decoding. For Airfrog, account for the byte input, result format, and coordinate mapping. Include the cost of converting the image array in the measurements.