Skip to content

QRCodeDetector::decode error: (-4:Insufficient memory) Failed to allocate ... bytes (tens of GBs) #21287

@crackwitz

Description

@crackwitz
  • OpenCV => 4.5.4 (not specifically)

QRCodeDetector::decode (also QRCodeDetector::detectAndDecode) crashes trying to allocate an unreasonable amount of memory.

cv2.error: OpenCV(4.5.4) D:\a\opencv-python\opencv-python\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 54056250000 bytes in function 'cv::OutOfMemoryError'

Steps to reproduce

Use the attached QR code

import cv2 as cv
im = cv.imread("hIfAR.png")
det = cv.QRCodeDetector()
(rv, points) = det.detect(im) # succeeds
(data, rectified) = det.decode(im, points) # fails
# (data, points, rectified) = det.detectAndDecode(im) # also fails

The issue was brought to my attention by pepoluan on Stack Overflow, who allows the code to be a test case. The code contains a zip file of a json file.

the information within the Zip file is dummy info, so it's okay to be public.

hIfAR

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions