微信开源二维码检测识别-实时检测识别-opencv-Python

import cv2 import numpy as np

cap = cv2.VideoCapture(0)

while True:

       ret, frame = cap.read()

      detector = cv2.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel",                  "sr.prototxt", "sr.caffemodel")

      res, points = detector.detectAndDecode(frame)

      for one_pt in points:

              one_pt = np.array(one_pt, dtype=np.int)

              cv2.polylines(frame, [one_pt], isClosed=True, color=(255, 0, 0), thickness=3)

       print('条码信息:', res)

       cv2.imshow("cap", frame)

       if cv2.waitKey(100) & 0xff == ord('q'):

           break

cap.release()

cv2.destroyAllWindows()

调用微信开源库进行二维码的检测和识别

import cv2 import numpy as np

cap = cv2.VideoCapture(0)

while True:

       ret, frame = cap.read()

      detector = cv2.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel",                  "sr.prototxt", "sr.caffemodel")

      res, points = detector.detectAndDecode(frame)

      for one_pt in points:

              one_pt = np.array(one_pt, dtype=np.int)

              cv2.polylines(frame, [one_pt], isClosed=True, color=(255, 0, 0), thickness=3)

       print('条码信息:', res)

       cv2.imshow("cap", frame)

       if cv2.waitKey(100) & 0xff == ord('q'):

           break

cap.release()

cv2.destroyAllWindows()

微信开源二维码检测识别-实时检测识别-opencv-Python_第1张图片

 汉字 字母均可识别生成     opencv的zbar库只能识别生成字母   如果二维码封存的是汉字 则zbar会乱码  

开源库下载链接

链接:https://pan.baidu.com/s/1aYNJ8ukV8qraOQuiiIwG-Q 
提取码:apbo

将开源库内文件放在跟代码同级的目录即可

你可能感兴趣的:(笔记,opencv,python,计算机视觉,机器学习,人工智能)