【问题标题】:Python code for determining corner locations of a QR Code using Zbar使用 Zbar 确定二维码角位置的 Python 代码
【发布时间】:2014-05-22 00:36:05
【问题描述】:

我想在这里扩展代码以提取 QCode 的角。

#!/usr/bin/python
from sys import argv
import zbar
from PIL import Image

if len(argv) < 2: exit(1)

# create a reader
scanner = zbar.ImageScanner()

# configure the reader
scanner.parse_config('enable')

# obtain image data
pil = Image.open(argv[1]).convert('L')
width, height = pil.size
raw = pil.tostring()

# wrap image data
image = zbar.Image(width, height, 'Y800', raw)

# scan the image for barcodes
scanner.scan(image)

# extract results
for symbol in image.symbols:
    # do something useful with results
    print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data

# clean up
del(image)

在之前的帖子中,作者指出这是可能的“*zBar 提供了一种根据像素值执行此操作的方法(一旦您知道像素值的大小,您可以在 %**> 中找到它”

Detect the size of a QR Code in Python using OpenCV and Zbar)

我参考了 Zbar SDK (http://zbar.sourceforge.net/api/classzbar_1_1Symbol.html),但仍然不知道如何提取角落。如果有人能告诉我如何(使用 Python 提取角落),我将不胜感激。

【问题讨论】:

    标签: python zbar-sdk zbar


    【解决方案1】:

    在你的循环中,尝试:

    topLeftCorners, bottomLeftCorners, bottomRightCorners, topRightCorners = [item for item in symbol.location]
    

    你会得到 4 个角

    迟到的答案,但这可以帮助其他人 多姆

    【讨论】:

    • 要么我疯了,要么这个答案真的过时了。
    • 哦,我知道应该是for symbol in image.symbols:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多