幫幫我,我有一個關于錯誤的問題
import sys
import cv2
import time
camera = cv2.VideoCapture(0)
if (camera.isOpened() == False):
print("Can not open camera #0.")
sys.exit(0)
print("Camera ready")
doAgain = True
while doAgain:
ret, image = camera.read()
if ret:
qrCodeDetector = cv2.QRCodeDetector()
text, points = qrCodeDetector.detectAndDecode(image)
if points is not None:
print(text)
cv2.imwrite("./result.jpg",image)
else:
print("QR code not detected")
cv2.imshow("Image", image)
key = cv2.waitKey(1) & 0xFF
if key == 27: # ESC
cv2.destroyAllWindows()
doAgain = False
camera.release()

Camera ready
Traceback (most recent call last):
File "C:\Users\User\Desktop\testtest00\code24-2.py", line 15, in <module>
text, points = qrCodeDetector.detectAndDecode(image)
ValueError: too many values to unpack (expected 2)
uj5u.com熱心網友回復:
該qrCodeDetector.detectAndDecode()方法回傳 3 個值;retval,points和straight_qrcode。
所以只需更換線
text, points = qrCodeDetector.detectAndDecode(image)
和
text, points, _ = qrCodeDetector.detectAndDecode(image)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/394624.html
