Ai
1 Star 5 Fork 1

cubone/learnopencv

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
qrCodeOpencv.py 1020 Bytes
一键复制 编辑 原始数据 按行查看 历史
vikas 提交于 2018-12-11 13:24 +08:00 . added README and CMakeLists.txt and some bug fixes
import cv2
import numpy as np
import sys
import time
if len(sys.argv)>1:
inputImage = cv2.imread(sys.argv[1])
else:
inputImage = cv2.imread("qrcode-learnopencv.jpg")
# Display barcode and QR code location
def display(im, bbox):
n = len(bbox)
for j in range(n):
cv2.line(im, tuple(bbox[j][0]), tuple(bbox[ (j+1) % n][0]), (255,0,0), 3)
# Display results
cv2.imshow("Results", im)
# Create a qrCodeDetector Object
qrDecoder = cv2.QRCodeDetector()
# Detect and decode the qrcode
t = time.time()
data,bbox,rectifiedImage = qrDecoder.detectAndDecode(inputImage)
print("Time Taken for Detect and Decode : {:.3f} seconds".format(time.time() - t))
if len(data)>0:
print("Decoded Data : {}".format(data))
display(inputImage, bbox)
rectifiedImage = np.uint8(rectifiedImage);
cv2.imshow("Rectified QRCode", rectifiedImage);
else:
print("QR Code not detected")
cv2.imshow("Results", inputImage)
cv2.imwrite("output.jpg",inputImage)
cv2.waitKey(0)
cv2.destroyAllWindows()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cubone/learnopencv.git
git@gitee.com:cubone/learnopencv.git
cubone
learnopencv
learnopencv
master

搜索帮助