Skip to content

QR code detecting in python with OpenCV raises UnicodeDecodeError: 'utf-8' codec can't decode byte #23728

@MKraemer85

Description

@MKraemer85

System Information

OpenCV python version: 4.7.0
Operating System: Windows 10
Python Version: Python 3.10.5

Detailed description

Related to this Question:
https://stackoverflow.com/questions/76362026/qr-code-detecting-in-python-with-opencv-raises-unicodedecodeerror-utf-8-codec

As I'm trying to detect an qr code and the qr code values, I get this error:

Traceback (most recent call last):
  File "C:\Users\m7073\Repos\Chronos_New\invoice_extraction\qr_code_scan.py", line 128, in <module>
    qrcode.set_qr_values()
  File "C:\Users\m7073\Repos\Chronos_New\invoice_extraction\qr_code_scan.py", line 73, in set_qr_values
    text, points, straight_qrcode = detect.detectAndDecode(img)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 157: invalid start byte

Steps to reproduce

import cv2
img = cv2.imread(f"page_1.png")
detect = cv2.QRCodeDetector()
text, points, straight_qrcode = detect.detectAndDecode(img)

page_1

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions