[SOLVED] Do you work with Python cv2 and qr codes?
by Pedroski from LinuxQuestions.org on (#5CZ7Z)
EDIT: solved this by using pyzbar to decode the data. Thaat presents another problem, because the Chinese names need to be decoded to utf-8, and that doesn't work too well, but the most important is student number.
I use Ubuntu 18.04, Python 3.6.9 Idle shell
I have a strange problem with cv2, I can't seem to find an answer.
Maybe someone here has experience with this?
I use Python to make qr codes for each student. The data in the qr code is just the student number and name.
After making them, I first want to check them, to make sure they can be read. I noticed that some were not read, so I made a list to collect the names of the files which showed no data.
Code:# show the data from each QR code
missing = []
count=0
for f in QRfiles:
img = cv2.imread(savepathQRcodes + f)
window_name = 'qr-code'
cv2.imshow(window_name, img)
cv2.waitKey(1000) # all the qr codes show up
cv2.destroyAllWindows()
qrCodeDetector = cv2.QRCodeDetector()
decodedText, points, _ = qrCodeDetector.detectAndDecode(img)
# but some of the qrcodes cannot be read. Save the name, check it with the moblie
if decodedText == '':
count+=1
missing.append(f)
print(decodedText)Then, I go to the folder with the qr files, find the ones that could not be read.
I open them and scan them with my phone qr scanner: the data is there, I see it immediately!
So, this part is failing on some of the qr codes:
Code:qrCodeDetector = cv2.QRCodeDetector()
decodedText, points, _ = qrCodeDetector.detectAndDecode(img)Yesterday, 7 files from 114 did not show any data in the above loop. (But my phone confirms the data is there and can be read.)
Have you had this problem? Do you have any tips for me?
I'm wondering if this is a computer memory problem, because 90+% of the files can be read in the above loop.


I use Ubuntu 18.04, Python 3.6.9 Idle shell
I have a strange problem with cv2, I can't seem to find an answer.
Maybe someone here has experience with this?
I use Python to make qr codes for each student. The data in the qr code is just the student number and name.
After making them, I first want to check them, to make sure they can be read. I noticed that some were not read, so I made a list to collect the names of the files which showed no data.
Code:# show the data from each QR code
missing = []
count=0
for f in QRfiles:
img = cv2.imread(savepathQRcodes + f)
window_name = 'qr-code'
cv2.imshow(window_name, img)
cv2.waitKey(1000) # all the qr codes show up
cv2.destroyAllWindows()
qrCodeDetector = cv2.QRCodeDetector()
decodedText, points, _ = qrCodeDetector.detectAndDecode(img)
# but some of the qrcodes cannot be read. Save the name, check it with the moblie
if decodedText == '':
count+=1
missing.append(f)
print(decodedText)Then, I go to the folder with the qr files, find the ones that could not be read.
I open them and scan them with my phone qr scanner: the data is there, I see it immediately!
So, this part is failing on some of the qr codes:
Code:qrCodeDetector = cv2.QRCodeDetector()
decodedText, points, _ = qrCodeDetector.detectAndDecode(img)Yesterday, 7 files from 114 did not show any data in the above loop. (But my phone confirms the data is there and can be read.)
Have you had this problem? Do you have any tips for me?
I'm wondering if this is a computer memory problem, because 90+% of the files can be read in the above loop.