![](/img/trans.png)
[英]from pyzbar.pyzbar import decode gives error while running it on google colab
[英]Get coordinates from pyzbar decode
我正在嘗試使用 pyzbar 模塊從掃描的二維碼中獲取坐標。 如果我使用下面的代碼來做到這一點:
test = decode(img)
print(test)
我得到以下結果:
[解碼后(data=b'Part4', type='QRCODE', rect=Rect(left=172, top=332, width=75, height=76))]
然而,問題是我不知道如何只提取這個字符串的 rect 部分。 我正在使用 spyder,如果我去變量資源管理器嘗試查看變量是如何構建的,我會收到以下錯誤:
AttributeError("無法在"上獲取屬性'Rect',)
有誰知道可能是什么?
還有另一種方法可以幫助。 您可以將數據更改為 Numpy 數組並將其與 OpenCV 一起使用,其他庫會更容易。 說明:(導入 OpenCV、Numpy 庫)
points = np.array(decoded_objects_by_pyzbar[0].polygon, np.int32)
cv.polylines(img,[points],True,(0,255,255),9)
cv.imshow("detected code", frame)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.