栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python学习笔记之图片二维码识别算法

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python学习笔记之图片二维码识别算法

# !/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)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/932485.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号