I'm trying to work on QR code scanner and I get this error: pixels, width, height = image TypeError: cannot unpack non-iterable NoneType object
I'm trying to work on QR code scanner and I get this error: pixels, width, height = image TypeError: cannot unpack non-iterable NoneType object
几周前我尝试了相同的代码并且运行良好,但现在我遇到了这个错误
pixels, width, height = image TypeError: cannot unpack non-iterable NoneType object
编辑:问题已解决。代码很好,问题是我的内置网络摄像头。当我连接一个新的网络摄像头时,它工作正常。
非常感谢您的帮助。这是我在堆栈中的第一个问题
很可能您的 read()
失败了。你必须先检查你的读取是否成功,然后继续迭代:
while True:
success, image = capture.read()
if success:
for eachcode in decode(image):
...
else:
print('Capture failed')
如果你仍然得到同样的错误,你也可以检查一下 decode()
是否没有 return None
:
while True:
success, image = capture.read()
decoded_image = decode(image)
if success and decoded_image is not None:
for eachcode in decoded_image:
...
else:
print('Capture failed')
几周前我尝试了相同的代码并且运行良好,但现在我遇到了这个错误
pixels, width, height = image TypeError: cannot unpack non-iterable NoneType object
编辑:问题已解决。代码很好,问题是我的内置网络摄像头。当我连接一个新的网络摄像头时,它工作正常。
非常感谢您的帮助。这是我在堆栈中的第一个问题
很可能您的 read()
失败了。你必须先检查你的读取是否成功,然后继续迭代:
while True:
success, image = capture.read()
if success:
for eachcode in decode(image):
...
else:
print('Capture failed')
如果你仍然得到同样的错误,你也可以检查一下 decode()
是否没有 return None
:
while True:
success, image = capture.read()
decoded_image = decode(image)
if success and decoded_image is not None:
for eachcode in decoded_image:
...
else:
print('Capture failed')