I've just started getting familiar with the library Pyzbar, but when using the decode
method I get an error. Here's the code:
import cv2
import numpy as np
import pyzbar
code_image = cv2.imread("C:\Users\Acer\Desktop\qr.PNG")
cv2.imshow("QR", code_image)
cv2.waitKey(0) #this command is to hold the image open after opening it
from pyzbar import decode
decoded = pyzbar.decode(code_image)
print(decoded)
qr.PNG is just a picture of a QR Code. OpenCV displays the image just fine but it's the decoding part that doesn't work:
Traceback (most recent call last): File "C:/Users/Acer/Desktop/ML >Projects/Projects/OpenCV/QR_Code_Detection.py", line 17, in from pyzbar import decode ImportError: cannot import name decode
When excluding this line: from pyzbar import decode
I get the following error:
Traceback (most recent call last): File "C:/Users/Acer/Desktop/ML >Projects/Projects/OpenCV/QR_Code_Detection.py", line 17, in decoded = pyzbar.decode(code_image) AttributeError: 'module' object has no attribute 'decode'
Hope someone more knowledgeable can help. Thanks a lot.
After wresting with this problem for quite some time and trying different methods that worked for other people (Reinstalls, repairs, patches, Windows Updates, setting pathways, renaming directories, importing within a function, using Dependency Walker to install dependencies and so much more...) it turned out it was a Microsoft Visual C++
problem and the only thing that I saw on some obscure forum and that worked for me was installing ALL versions of Visual C++ (from 2008 to 2017) both x64 and x86 (or else it doesn't work) and it worked like a charm.
So I'm just gonna leave this here hopefully it spares somebody the hassle.