一、概述

微信二维码检测器,用于检测和解析二维码。

微信二维码包括两个基于 CNN 的模型:物体检测模型和超分辨率模型。 对象检测模型用于检测带有边界框的二维码。 二维码较小时,应用超分辨率模型放大二维码。

二、类参考

1、函数原型

初始化微信二维码。 它包括两个模型,它们以 caffe 格式打包。 因此,有prototxt和caffe模型(总共四个参数)。

WeChatQRCode (const std::string &detector_prototxt_path="", const std::string &detector_caffe_model_path="", const std::string &super_resolution_prototxt_path="", const std::string &super_resolution_caffe_model_path="")

2、参数详解

detector_prototxt_path prototxt file path for the detector
detector_caffe_model_path caffe model file path for the detector
super_resolution_prototxt_path prototxt file path for the super resolution model
super_resolution_caffe_model_path caffe file path for the super resolution model

上述四个模型文件下载地址

GitHub - WeChatCV/opencv_3rdparty: OpenCV - 3rdpartyhttps://github.com/WeChatCV/opencv_3rdparty

3、函数原型

检测和解码 QR 码。

detectAndDecode (InputArray img, OutputArrayOfArrays points=noArray())

4、参数详解

img 支持灰度或彩色(BGR)图像。
points 找到的二维码四边形的顶点的可选输出数组。 如果找不到,则为空。

三、OpenCV源码

1、源码路径

opencv_contrib\modules\wechat_qrcode\src\wechat_qrcode.cpp

2、源码代码

WeChatQRCode::WeChatQRCode(const String& detector_prototxt_path,const String& detector_caffe_model_path,const String& super_resolution_prototxt_path,const String& super_resolution_caffe_model_path) {p = makePtr<WeChatQRCode::Impl>();if (!detector_caffe_model_path.empty() && !detector_prototxt_path.empty()) {// initialize detector model (caffe)p->use_nn_detector_ = true;CV_Assert(utils::fs::exists(detector_prototxt_path));CV_Assert(utils::fs::exists(detector_caffe_model_path));p->detector_ = make_shared<SSDDetector>();auto ret = p->detector_->init(detector_prototxt_path, detector_caffe_model_path);CV_Assert(ret == 0);} else {p->use_nn_detector_ = false;p->detector_ = NULL;}// initialize super_resolution_model// it could also support non model weights by cubic resizing// so, we initialize it first.p->super_resolution_model_ = make_shared<SuperScale>();if (!super_resolution_prototxt_path.empty() && !super_resolution_caffe_model_path.empty()) {p->use_nn_sr_ = true;// initialize dnn model (caffe format)CV_Assert(utils::fs::exists(super_resolution_prototxt_path));CV_Assert(utils::fs::exists(super_resolution_caffe_model_path));auto ret = p->super_resolution_model_->init(super_resolution_prototxt_path,super_resolution_caffe_model_path);CV_Assert(ret == 0);} else {p->use_nn_sr_ = false;}
}vector<string> WeChatQRCode::detectAndDecode(InputArray img, OutputArrayOfArrays points) {CV_Assert(!img.empty());CV_CheckDepthEQ(img.depth(), CV_8U, "");if (img.cols() <= 20 || img.rows() <= 20) {return vector<string>();  // image data is not enough for providing reliable results}Mat input_img;int incn = img.channels();CV_Check(incn, incn == 1 || incn == 3 || incn == 4, "");if (incn == 3 || incn == 4) {cvtColor(img, input_img, COLOR_BGR2GRAY);} else {input_img = img.getMat();}auto candidate_points = p->detect(input_img);auto res_points = vector<Mat>();auto ret = p->decode(input_img, candidate_points, res_points);// opencv type convertvector<Mat> tmp_points;if (points.needed()) {for (size_t i = 0; i < res_points.size(); i++) {Mat tmp_point;tmp_points.push_back(tmp_point);res_points[i].convertTo(((OutputArray)tmp_points[i]), CV_32FC2);}points.createSameSize(tmp_points, CV_32FC2);points.assign(tmp_points);}return ret;
};

四、效果图像示例

使用了和QRCodeDetector模块相同的图像对微信二维码进行了简单测试。

OpenCV每日函数 Object Detection目标检测模块 (3) 二维码检测和生成_坐望云起的博客-CSDN博客OpenCV提供的二维码生成的类。 OpenCV提供的二维码检测的类。https://skydance.blog.csdn.net/article/details/125300314        参考代码如下

Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.CompositionSurface.CreateAliasedBitmap();Mat src = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);OpenCvSharp.WeChatQRCode weChatQRCode = WeChatQRCode.Create("wechat\\detect.prototxt","wechat\\detect.caffemodel","wechat\\sr.prototxt","wechat\\sr.caffemodel");Mat[] mats;string[] res;weChatQRCode.DetectAndDecode(src, out mats, out res);if(res!=null && res.Length > 0){foreach (string s in res)this.richTextBox1.Text += s;}

示例图像如下

OpenCV每日函数 WeChat QR 微信二维码检测器相关推荐

  1. opencv contrib模块 示例 WeChat qrcode微信二维码检测解码

    在opencv 4.5.3 的 contrib中, 腾讯WeChatCV团队贡献了wechat_qrcode模块,3行代码即可在opencv中实现微信的扫码功能. 文档链接为https://docs. ...

  2. Opencv之微信二维码检测与解析

    简介 微信二维码检测器是由微信计算机视觉团队(WeChatCV)提供的一个高性能.轻量级的二维码检测与解码库.它已广泛应用于腾讯的各种应用,包括微信.微信.QQ.QQ浏览器等.微信二维码检测仪有四个主 ...

  3. 使用 OpenCV + 微信二维码引擎实现二维码识别

    Part1背景 今年自疫情以来,我都没有写过文章.一方面是疫情导致居家办公比较烦躁,另一方面最近有点懒了.但是工作还是要继续,趁这几天优化了一下最近的项目,我整理了一下如何使用 OpenCV 和微信二 ...

  4. 重磅!微信二维码引擎OpenCV开源!3行代码让你拥有微信扫码能力

    点击上方"CVer",选择加"星标"置顶 重磅干货,第一时间送达 本文转载自:OpenCV团队 2011年12月微信3.5版本正式上线"扫一扫&quo ...

  5. 基于CNN的微信二维码引擎OpenCV开源!

    2011年12月微信3.5版本正式上线"扫一扫"二维码,历经9年蜕变,"扫一扫"从二维码名片到扫码支付.从小程序码到健康码,二维码已经成为一种生活方式,连接着数 ...

  6. opencv微信二维码引擎的使用(for java)

    前面讲了windows系统下opencv+opencv的编译方法,编译方法和编译好的文件如下: Windows下联合编译opencv+opencv_contrib微信二维码引擎 OpenCV4.5.2 ...

  7. CameraX 下使用 OpenCV 微信二维码识别

    前言 前面,我们已经介绍了两种集成 wechat_qrcode 微信二维码识别能力的做法: 完整编译 OpenCV 和 OpenCV Contrib Native C++ 单独集成 wechat_qr ...

  8. 微信二维码引擎OpenCV开源

    zxing:jni方式调用: https://github.com/devilsen/CZXing android studio4.1 十天前,微信官方开发团队在 opencv_contrib 开源了 ...

  9. Jetson Nano 从入门到实战(转载)(案例:Opencv配置、人脸检测、二维码检测)

    目录 1. Jetson Nano简介 2. Jetson Nano环境配置 2.1 开箱配件介绍 2.2 烧录系统 2.3 开机和基本设置 2.4 开发环境配置 2.4.1 更新源和软件 2.4.2 ...

  10. Jetson Nano 从入门到实战(案例:Opencv配置、人脸检测、二维码检测)

    目录 1. Jetson Nano简介 2. Jetson Nano环境配置 2.1 开箱配件介绍 2.2 烧录系统 2.3 开机和基本设置 2.4 开发环境配置 2.4.1 更新源和软件 2.4.2 ...

最新文章

  1. Windows CE 6.0正式发布 源代码100%开放
  2. Redis命令——哈希(Hash)
  3. Oracle分析函数六——数据分布函数及报表函数
  4. 一台linux上运行多个mysql_linux下同时运行多个mysql
  5. Java笔记学习2.2.2 常量与变量 - 常量
  6. mysql内外三种连接_mysql之内连接,外连接(左连接,右连接),union,union all的区别...
  7. 基于bp神经网络的房价预测,房价预测 神经网络
  8. 数字电路基础知识(一) 复位设计-同步复位与异步复位
  9. ARM嵌入式开发入门必要步骤
  10. 安装Linux系统不分区的问题,浅谈linux系统的分区问题
  11. Ttest(T检验)
  12. 开发QQ桌球瞄准器(5):使用注册表保存配置
  13. 《程序员修炼之道》读书笔记(4):注重实效的偏执(防卫策略)
  14. Linux之Redis安装(解压版)
  15. 初入职场,菜鸟北漂记
  16. Unity学习 HTC Vive Hi5 2.0
  17. ORA-3136 WARNING: inbound connection timed out (ORA-3136)
  18. Unnecessary escape character: \- no-useless-escape eslint
  19. 测试工程师-yy面试 cvte面试总结
  20. c语言统计输入文本不同字母单词数,统计文本中单词的个数

热门文章

  1. 【毕业设计】基于单片机的智能饮水控制系统 - 物联网 嵌入式 stm32 c51
  2. PPT~PPT修改行间距磅值
  3. 宏病毒的研究与实例分析01——基础篇
  4. 苹果鼠标右键怎么按_iPadOS 鼠标支持详解
  5. 远程桌面要求更改电源_远程工作实际上可以使老板动态改变电源
  6. 单片机广告灯实验总结_单片机流水灯实验总结精选 .doc
  7. 新加坡国立大学计算机系访学,从实践中来,到实践中去——记新加坡国立大学访学项目...
  8. 大数据思维的核心是什么?
  9. 启用或禁用笔记本自带键盘
  10. php网页代码字体大小,html字体大小怎么设置