做非法网站怎么盈利,php网站开发实例教程思考题,昭通网站建设 hardlcp,一键修改wordpress密码1 问题描述
#xff08;1#xff09;图像分辨率小。例如一些嵌入在海报#xff08;如图1#xff09;或远距离拍摄的码#xff0c;其分辨率远小于通常情况下的码图像。 图1.海报中的二维码占比很小 #xff08;2#xff09;图像质量较低。有很多是经过了多次的压缩和转…1 问题描述
1图像分辨率小。例如一些嵌入在海报如图1或远距离拍摄的码其分辨率远小于通常情况下的码图像。 图1.海报中的二维码占比很小 2图像质量较低。有很多是经过了多次的压缩和转发存在严重的人工效应如振铃效应干扰。 3由于光照等原因导致二维码亮度不均匀、图像模糊等。 2 微信超分辨率重构的框架
通常情况下相比于低分辨率图像高分辨率图像能够提供更丰富的细节呈现出良好的视觉效果对于二维码识别这种以图像作为输入的后续流程也有助于提高系统的整体表现。然而受成像设备、存储空间和网络资源的限制我们常常只能获得较低分辨率的图像。于是超分辨率技术便派上了用场。 超分辨率技术以低分辨率图像作为输入重建高分辨率输出是计算机视觉领域的一个经典问题。传统的基于像素插值的超分算法以其计算简单、速度快的优势被广泛采用如最近邻nearest插值双线性bilinear插值以及双三次bicubic插值等。但它们无法适应多样的图像内容感知能力较差难以重建出图像的高频信息输出图像过于模糊应用于压缩图像时甚至会放大人工效应干扰。 近年来计算机视觉技术和深度学习飞速发展学术界开始关注利用深度学习解决图像重建问题。我们根据扫码图像的特点设计了适用于移动端的超分网络实现了快速高效的码图像重建并改善图像质量大大提高了扫码算法的识别成功率。网络结构如图所示。 图1 码图像重建网络结构
3 API
基于OpenCV开发了相应的API。
3.1 cv.wechat_qrcode_WeChatQRCode
cv.wechat_qrcode_WeChatQRCode(detector_prototxt_path, detector_caffe_model_path, super_resolution_prototxt_path, super_resolution_caffe_model_path) - wechat_qrcode_WeChatQRCode object初始化微信 QR 码检测模块包括两个基于 CNN 的模型对象检测模型和超分辨率模型。对象检测模型用于检测带有边界框的二维码。当 QR 码较小时采用超分辨率模型对其进行放大。
文件地址https://github.com/WeChatCV/opencv_3rdparty
3.1.1 参数说明
参数名参数含义detector_prototxt_path对象检测模型的prototex文件路径detector_caffe_model_path对象检测模型的caffe模型文件路径super_resolution_prototxt_path超分辨率模型的prototex文件路径super_resolution_caffe_model_path超分辨率模型的caffe模型文件路径
3.1.2 返回值
wechat_qrcode_WeChatQRCode 对象
3.2 cv.wechat_qrcode_WeChatQRCode.detectAndDecode
cv.wechat_qrcode_WeChatQRCode.detectAndDecode(img[, points]) -retval, points检测和解析二维码
3.2.1 参数说明
参数名参数含义imgopencv 读取的灰度图或 BGR 图points检测到 QR 码四边形顶点后将其位置输出到该数组
3.2.2 返回值
retval: 解析结果
points: QR 码四边形顶点位置数组如果找不到则为空
4 二维码提升对比度测试
4.1 测试代码
import cv2
import osif __name__ __main__:# 初始化对象detector cv2.wechat_qrcode_WeChatQRCode(detect.prototxt,detect.caffemodel,sr.prototxt,sr.caffemodel)results {image: [], res: [], points: []}image_dir srcfiles os.listdir(image_dir)# 遍历图片目录for f in files:image_file os.path.join(image_dir, f)img cv2.imread(image_file) # 读取图像res, points detector.detectAndDecode(img) # 检测图像if res: # 非空表示检测成功results[image].append(image_file)results[res].append(res)results[points].append(points)image_num len(files)detected_num len(results[res])print(Image dir:, image_dir)print(fProcessed images: {image_num} , detected images: {detected_num},fdetection success rate : {detected_num / image_num * 100}%. )print(Detected images are:)for i in results[image]:print(i, end,)4.2 输出结果
Image dir: src Processed images: 134 , detected images: 19 detection success rate : 14.17910447761194%.
Dected images are: src/4_217.jpg,src/4_135.jpg,src/10_144.jpg,src/4_171.jpg,src/19_146.jpg,src/4_148.jpg,src/19_164.jpg,src/6_29.jpg,src/19_171.jpg,src/4_39.jpg,src/2.jpg,src/6_41.jpg,src/19_162.jpg,src/19_154.jpg,src/19_181.jpg,src/4_228.jpg,src/4_140.jpg,src/4_26.jpg,src/4_38.jpg
Image dir: detect Processed images: 137 , detected images: 22 detection success rate : 16.05839416058394%.
Detected images are: detect/4_217.jpg,detect/4_171.jpg,detect/19_146.jpg,detect/4_148.jpg,detect/19_164.jpg,detect/4_196.jpg,detect/19_151.jpg,detect/4_76.jpg,detect/4_81.jpg,detect/4_39.jpg,detect/19_159.jpg,detect/2.jpg,detect/19_165.jpg,detect/6_41.jpg,detect/19_162.jpg,detect/19_154.jpg,detect/19_137.jpg,detect/5_13.jpg,detect/4_132.jpg,detect/4_228.jpg,detect/4_26.jpg,detect/4_38.jpg
5 简单分析
以未能成功检测的src/5_50.jpg为例
该图片通过微信扫码可以成功检测检测成功时摄像头离图片较近因此考虑在 QR 检测程序中对图片进行缩放预处理
x, y img.shape[0:2]
img cv2.resize(img, (int(y * 1.5), int(x * 1.5)))结果如下 Image dir: detect Processed images: 137 , detected images: 33 detection success rate : 24.087591240875913%. Detected images are: detect/4_217.jpg,detect/4_135.jpg,detect/10_144.jpg,detect/4_171.jpg,detect/4_133.jpg,detect/4_69.jpg,detect/19_164.jpg,detect/19_151.jpg,detect/6_29.jpg,detect/4_76.jpg,detect/6_2.jpg,detect/7_47.jpg,detect/4_81.jpg,detect/4_39.jpg,detect/2.jpg,detect/19_165.jpg,detect/15_75.jpg,detect/7_44.jpg,detect/7_7.jpg,detect/6_12.jpg,detect/19_162.jpg,detect/11_99.jpg,detect/4_100.jpg,detect/19_154.jpg,detect/19_137.jpg,detect/5_50.jpg,detect/5_13.jpg,detect/19_181.jpg,detect/14_11.jpg,detect/4_228.jpg,detect/6_30.jpg,detect/4_26.jpg,detect/4_38.jpg
Image dir: src Processed images: 134 , detected images: 32 detection success rate : 23.88059701492537%. Detected images are: src/4_217.jpg,src/4_135.jpg,src/10_144.jpg,src/4_171.jpg,src/19_146.jpg,src/4_69.jpg,src/19_164.jpg,src/4_196.jpg,src/6_29.jpg,src/4_76.jpg,src/19_171.jpg,src/6_2.jpg,src/4_220.jpg,src/7_47.jpg,src/4_81.jpg,src/7_29.jpg,src/4_39.jpg,src/19_159.jpg,src/4_237.jpg,src/2.jpg,src/19_165.jpg,src/15_75.jpg,src/4_115.jpg,src/19_162.jpg,src/19_154.jpg,src/5_50.jpg,src/5_13.jpg,src/19_181.jpg,src/4_228.jpg,src/6_30.jpg,src/4_26.jpg,src/4_38.jpg
测试结果表明 opencv 中的 QR 码识别 API 主要针对理想位置和大小的 QR 码图像进行识别而简单的图像预处理可以提高 QR 码识别成功率。
6 总结及展望
我们目前通过调用微信API来实现检测和超分辨率重构下一步工作将搭建图1所示的网络利用微信已经训练好的模型来看看通过超分辨率重构后的效果。
参考文献
https://blog.csdn.net/qq_35054151/article/details/113647111