OpenCV QRCodeDetector 导致 ValueError 太多值无法解包(预期 2)

OpenCV QRCodeDetector causes ValueError too many values to unpack (expected 2)

帮帮我,我有一个关于错误的问题

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)
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()

qrCodeDetector.detectAndDecode()方法returns3个值; retvalpointsstraight_qrcode

所以只需替换行

text, points = qrCodeDetector.detectAndDecode(image)

text, points, _ = qrCodeDetector.detectAndDecode(image)