【问题标题】:Can not decode QR code using pyzbar with python3无法使用带有python3的pyzbar解码QR码
【发布时间】:2020-09-06 17:53:12
【问题描述】:

我需要使用 python3、opencv 和 pyzbar 解码 this QR Code,但我无法获得任何好的结果:脚本无法检测/解码 QR 码。

这是我使用的代码。有什么好的方法可以提高识别度吗?

import cv2
from pyzbar import pyzbar

# Image load
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="path to input image")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])

# Read QR
qr_code = pyzbar.decode(image)
print(qr_code)

在应用 QR 解码器之前,我还尝试过:

改变亮度/对比度:

# Change brightness/contrast
image = cv2.convertScaleAbs(image, alpha=6, beta=0)

制作二值图像:

# Make binary image
image[image > 19] = 255
image[image <= 19] = 0

旋转图片 (using this function):

def rotate_image(image, angle):
    image_center = tuple(np.array(image.shape[1::-1]) / 2)
    rot_mat = cv2.getRotationMatrix2D(image_center, angle, 1.0)
    result = cv2.warpAffine(image, rot_mat, image.shape[1::-1], flags=cv2.INTER_LINEAR)
    return result

image = rotate_image(image, 7)

【问题讨论】:

    标签: python qr-code


    【解决方案1】:

    好的,我发现我试图解码的图像不是二维码,而是数据矩阵条码。现在用pylibdmtx我可以解码了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多