When trying to read a QRcode using the following code:
detector = cv2.QRCodeDetector() while True: _, img = cap.read() data, _, _ = detector.detectAndDecode(img)
I get this exception upon trying to read a QR code:
Exception in thread Thread-2: Traceback (most recent call last): File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner self.run() File "/usr/lib/python3.5/threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "main.py", line 100, in qr_checker jwt, _, _ = detector.detectAndDecode(img) cv2.error: OpenCV(4.1.1) /home/pi/opencv-python/opencv/modules/core/src/alloc.cpp:72: error: (-4:Insufficient memory) Failed to allocate 152100e0000 bytes in function 'OutOfMemoryError'
The error is fairly descriptive: insufficient memory, but I don't know how to avoid it. Is there a more efficient approach I can take that avoids this?
It does work with a simpler QR-code that encodes less data, but I need it to work wit more complex QR-codes as well.