本文介绍了使用Zbar确定QR代码的角位置的Python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这里扩展代码以提取QCodes的角落.

I would like to extend the code here to extract the corners of the QCodes.

#!/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提供了一种以像素值表示的方法(一旦知道像素值的大小,您就可以在%**>中找到它了")

In a previous posting, the author indicates that this is possible "*zBar provides a method to do this in terms of pixel values (Once you know the size in pixel values, you can find it in %**>"

请参见)

我提到了Zbar SDK( http://zbar.sourceforge.net/api/classzbar_1_1Symbol.html ),但仍然不知道如何提取角点.如果有人可以向我展示如何(使用Python提取角落),我将不胜感激.

I referred to the Zbar SDK ( http://zbar.sourceforge.net/api/classzbar_1_1Symbol.html ), and still couldn't figure out how to extract the corners. I'd appreciate it if someone could show me how (to extract the corners using Python).

推荐答案

在您的循环中,尝试:

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

您将获得4个角点

最新答案,但这可以帮助其他人Dom

Late answer but this can help othersDom

这篇关于使用Zbar确定QR代码的角位置的Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-07 23:38