簡體   English   中英

在 Python 中找到二維碼時如何破解?

[英]How can I break when found QR Code in Python?

我正在嘗試學習 Python 中的 QR 碼模塊,並且我正在嘗試制作一些代碼,所以當我找到 QR 碼時我想打破我該怎么做?

我的代碼是:

while 1:

    success, img= cap.read()
    for x in decode(img):
        data1 = x.data.decode('utf-8')
        pts = np.array([x.polygon],np.int32)
        pts = pts.reshape((-1,1,2))
        cv2.polylines(img,[pts],True,(122,25,245),(3))
        print(data1)
        
    cv2.imshow('Result',img)
    cv2.waitKey(10)

在范圍循環中使用 if 語句,如果那里有東西,打印它已被檢測到

   while 1:
    
        success, img= cap.read()
        for x in decode(img):
            data1 = x.data.decode('utf-8')
            pts = np.array([x.polygon],np.int32)
            pts = pts.reshape((-1,1,2))
            cv2.polylines(img,[pts],True,(122,25,245),(3))
            print(data1)
            if data1 is not None:
                print("QR code detected")
                break

     cv2.imshow('Result',img)
     cv2.waitKey(10)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM