一、二维码检测识别
1、实验步骤
#导入标准库os
import os
#导入numpy
import numpy as np
#导入matplotlib
from matplotlib import pyplot as plt
#导入OpenCV
import cv2 as cv
src = cv.imread(‘tt.png’)
#绘制热图
plt.imshow(src)
#图片显示
plt.show()
gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
qrcoder = cv.QRCodeDetector()
codeinfo, points, straight_qrcode = qrcoder.detectAndDecode(gray)
print(points)
print(points[0][0])
result = np.copy(src)
cv.putText(result,‘%s’%codeinfo,tuple(points[2][0]),cv.FONT_HERSHEY_SIMPLEX, 0.8,(0, 0, 255))
cv.drawContours(result, [np.int32(points)], 0, (0, 0, 255), 2)
print(“qrcode : %s”% codeinfo)
#绘制热图
plt.imshow(result)
#图片显示
plt.show()
code_roi = np.uint8(straight_qrcode)
#绘制热图
plt.imshow(code_roi)
#图片显示
plt.show()
c