微信開發者工具掃描二維碼(微信二維碼識別庫wechat)
2023-05-01 12:18:13 1
微信二維碼檢測器是微信計算機視覺團隊(微信)提供的一款高性能、輕量級的二維碼檢測和解碼庫。 已廣泛應用於微信、WeCom、QQ、QQ瀏覽器等騰訊應用中。目前這個功能已經集成到opencv_contrib模塊,使用十分方便。
開源地址:https://github.com/opencv/opencv_contrib/tree/4.x/modules/wechat_QRCode
安裝和使用非常簡單
1. 安裝:pip install opencv-pythonpip install opencv-contrib-python2. 如下地址下載四個模型文件:detect.prototxt, detect.caffemodel, sr.prototxt, sr.caffemodel:https://github.com/Tianxiaomo/qrDecoder/tree/master/model
如下是例子,更詳細的例子可以參看項目中的samples/qrcode.py,裡面包含調用攝像頭的例子:
import cv2detector = cv2.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel", "sr.prototxt", "sr.caffemodel")img = cv2.imread("qrcode.jpg") # 包含二維碼的圖片res, points = detector.detectAndDecode(img)print(res, points)