I try to run a camera reading code in macOS. Here is my code:
import cv2
from pyzbar.pyzbar import decode
import os
os.system("clear")
cap = cv2.VideoCapture(0)
cap.set(3 , 640)
cap.set(4 , 480)
while True:
success, img = cap.read()
for barcode in decode(img):
print(barcode.data)
print(barcode.rect)
x = barcode.data.decode('utf-8')
print(x)
cv2.imshow('Result', img)
cv2.waitKey(1)
This is current error:
Traceback (most recent call last):
File "/Users/username/Documents/Pyzbar Lesson 2.py", line 21, in <module>
for barcode in decode(img):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyzbar/pyzbar.py", line 207, in decode
pixels, width, height = _pixel_data(image)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyzbar/pyzbar.py", line 173, in _pixel_data
pixels, width, height = image
TypeError: cannot unpack non-iterable NoneType object
Please, share if I miss anything or other error in the code.
Thanks.