# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @Author : QQ736592720
# @file : 简答题480___图片二维码检测算法AI.py
# @Time : 2022/5/26 15:56
import glob
import os
import shutil
import cv2 as cv
'''
https://github.com/WeChatCV/opencv_3rdparty/blob/wechat_qrcode/detect.prototxt
https://github.com/WeChatCV/opencv_3rdparty/blob/wechat_qrcode/detect.caffemodel
https://github.com/WeChatCV/opencv_3rdparty/blob/wechat_qrcode/sr.prototxt
https://github.com/WeChatCV/opencv_3rdparty/blob/wechat_qrcode/sr.caffemodel
'''
def qrd_decode(filepath):
img = cv.imread(filepath, 0)
res, points = detector.detectAndDecode(img)
# print(res, points)
return len(res) > 0
if __name__ == '__main__':
detector = cv.wechat_qrcode_WeChatQRCode("detect.prototxt", "detect.caffemodel",
"sr.prototxt", "sr.caffemodel")
ls = glob.glob(r"C:Users73659Desktopw321*.jpg")
t, f = 0, 0
shutil.rmtree(r"C:Users73659Desktoptt")
os.mkdir(r"C:Users73659Desktoptt")
shutil.rmtree(r"C:Users73659Desktopff")
os.mkdir(r"C:Users73659Desktopff")
for filepath in ls:
a, b = os.path.split(filepath)
if qrd_decode(filepath):
t += 1
shutil.copy(filepath, os.path.join(r"C:Users73659Desktoptt", b))
else:
f += 1
print(filepath)
shutil.copy(filepath, os.path.join(r"C:Users73659Desktopff", b))
print(t, f)