Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ZBAR-Python没有输出_Python_Barcode - Fatal编程技术网

ZBAR-Python没有输出

ZBAR-Python没有输出,python,barcode,Python,Barcode,我读条形码有困难。我所有的条形码都是用代码39编码的 这是我从zbar网站得到的代码,无休止的谷歌搜索返回空值 from sys import argv import zbar import Image if len(argv) < 2: exit(1) # create a reader scanner = zbar.ImageScanner() # configure the reader scanner.parse_config('enable') # obtain imag

我读条形码有困难。我所有的条形码都是用代码39编码的

这是我从zbar网站得到的代码,无休止的谷歌搜索返回空值

from sys import argv
import zbar
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:
# do something useful with results
print 'decoded', symbol.type, 'symbol', '"%s"' % symbol.data

# clean up
del(image)
从系统导入argv
进口zbar
导入图像
如果len(argv)<2:退出(1)
#创建一个阅读器
scanner=zbar.ImageScanner()
#配置读卡器
scanner.parse_config('enable'))
#获取图像数据
pil=Image.open(argv[1]).convert('L')
宽度、高度=桩号
raw=pil.tostring()
#包装图像数据
图像=zbar.图像(宽度、高度,'Y800',原始)
#扫描图像中的条形码
扫描器.扫描(图像)
#提取结果
对于图像中的符号:
#对结果做一些有用的事情
打印'decoded',symbol.type','symbol','%s''%symbol.data
#清理
德尔(图片)

任何帮助都将不胜感激。

看来我的条形码不好。还要注意的是,如果条形码位于包含其他数据的文档上,除非我启用网络摄像头扫描条形码,否则它也不会拾取。似乎是一个限制或只是坏条形码。

那么有什么问题?(另一方面,大多数条形码扫描仪可以通过串行端口(或伪串行端口)进行通信)只需发送解码值字符串…我打赌你没有向脚本传递任何命令行参数…我传递的是png图像的位置作为参数。我的问题是,我只有一个满是png图像的文件夹,希望获取此代码并循环通过条形码获取值并生成一个CSV文件。但目前我无法获取没有一个图像可以阅读。