博客转载自:https://blog.csdn.net/sunflower_boy/article/details/50429252

为了减少处理时间,可以设定更大的扫描间距,减少不必要的解码类型,去除位置记录:zbarimg -Sdisable -Scode128.enable -Sno-position -Sx-density=0 -Sy-density=10 160220206.jpg。在ubuntu系统下,jpg格式并不比bmp格式更耗时,可能是因为bmp格式图片太大,载入耗了太多时间。
测试过程:

测试条件

测试图像:2560x1920pixels
联想 IdeaPad Z470
英特尔 Core i3-2310M @ 2.10GHz 双核
2 GB ( 三星 DDR3 1333MHz )
Ubuntu 15.04  

测试程序

import re
import commands
picname = '1553520702.jpg'
regex = re.compile(r'\d+\.?\d*\sseconds')
f=open('timeresult.txt','w') cmdlist = ['zbarimg ',
'zbarimg -Sdisable -Scode128.enable ',
'zbarimg -Sno-position ',
'zbarimg -Sy-density=10 ',
'zbarimg -Sy-density=20 ',
'zbarimg -Sy-density=40 ',
'zbarimg -Sy-density=10 -Sx-density=10 ',
'zbarimg -Sy-density=10 -Sx-density=20 ',
'zbarimg -Sy-density=10 -Sx-density=40 ',
'zbarimg -Sy-density=10 -Sx-density=0 ',
'zbarimg -Sy-density=20 -Sx-density=0 ',
'zbarimg -Sy-density=40 -Sx-density=0 ',
'zbarimg -Sy-density=40 -Sx-density=0 \
-Sdisable -Scode128.enable -Sno-position ',
]
for i in range(len(cmdlist)):
cmdstr = cmdlist[i] + picname
print cmdstr+':'
f.write(cmdstr+':')
for j in range(1,6):
cmdout = commands.getoutput(cmdstr)
timelist = regex.findall(cmdout)
if timelist:
timestr = timelist[0]
timestr = timestr[:len(timestr)-7]
else:
timestr = '-1'
print timestr
f.write(timestr)
print '\n'
f.write('\n') f.close()   

输出结果

zbarimg .jpg:0.63 0.61 0.59 0.62 0.6
zbarimg -Sdisable -Scode128.enable .jpg:0.56 0.61 0.55 0.56 0.55
zbarimg -Sno-position .jpg:0.59 0.6 0.62 0.6 0.62
zbarimg -Sy-density= .jpg:0.42 0.43 0.41 0.42 0.42
zbarimg -Sy-density= .jpg:0.42 0.4 0.41 0.41 0.4
zbarimg -Sy-density= .jpg:0.4 0.4 0.42 0.4 0.39
zbarimg -Sy-density= -Sx-density= .jpg:0.2 0.2 0.21 0.23 0.21
zbarimg -Sy-density= -Sx-density= .jpg:0.2 0.2 0.19 0.19 0.21
zbarimg -Sy-density= -Sx-density= .jpg:0.19 0.2 0.21 0.2 0.19
zbarimg -Sy-density= -Sx-density= .jpg:0.18 0.18 0.18 0.18 0.18
zbarimg -Sy-density= -Sx-density= .jpg:0.17 0.17 0.17 0.18 0.16
zbarimg -Sy-density= -Sx-density= .jpg:0.16 0.16 0.17 0.16 0.16
zbarimg -Sy-density= -Sx-density= -Sdisable -Scode128.enable -Sno-position .jpg:0.16 0.16 0.16 0.16 0.17

man zbarimg查看配置信息

ZBARIMG(1)                    ZBar Barcode Reader                   ZBARIMG(1)  

NAME
zbarimg - scan and decode bar codes from image file(s) SYNOPSIS
zbarimg [-qv] [--quiet] [--verbose[=n]]
{-dD | --display | --nodisplay | --xml | --noxml |
-S[symbology.]config[=value] | --set [symbology.]config[=value]
| image...} zbarimg {-h | --help | --version} DESCRIPTION
For each specified image file zbarimg scans the image for bar codes and
prints any decoded data to stdout. Images may optionally be displayed
to the screen. The underlying library currently supports EAN-13 (including UPC and
ISBN subsets), EAN-8, Code 128, Code 39, and Interleaved 2 of 5
symbologies. The specific type of each detected symbol is printed with
the decoded data. Note that "image" in this context refers to any format supported by
ImageMagick, including many vector formats such as PDF and PostScript.
Keep in mind that vector formats are rasterized before scanning;
manually rasterize vector images before scanning to avoid
unintentionally corrupting embedded barcode bitmaps. OPTIONS
This program follows the usual GNU command line syntax. Single letter
options may be bundled, long options start with two dashes (`-´). -h, --help
Print a short help message describing command line options to
standard output and exit --version
Print program version information to standard output and exit -v, --verbose[=n]
Increase debug output level. Multiple -v options create more spew.
Alternatively specify n to set the debug level directly -S[symbology.]config[=value], --set [symbology.]config[=value]
Set decoder configuration option config for symbology to value.
value defaults to 1 if omitted. symbology is one of ean13, ean8,
upca, upce, isbn13, isbn10, i25, code39, code128 or the special
value *. If symbology is omitted or *, the config will be set for
all applicable symbologies. These are the currently recognized
configs. Prefix a config with "no-" to negate it. Not all configs
are appropriate for every symbology. enable
Control decoding/reporting of a symbology. For symbologies
which are just subsets of ean13 (upca, upce, isbn13, isbn10),
this config controls whether the subsets are detected and
reported as such. These special cases are disabled by default,
all other symbologies default to enabled disable
Antonym for enable emit-check
Control whether check digits are included in the decoded
output. Enabled by default. This config does not apply for
code128, which never returns the check digit. It also not apply
for cases where the check digit is disabled (see add-check).
Check digits are currently not implemented for i25 or code39 add-check
Enable decode and verification of a check digit for symbologies
where it is optional: this will include code39 and i25, neither
of which implements the check digit yet ascii
Enable escape sequences that encode the full ASCII character
set. This would apply to code39, except that it´s not
implemented either... position
Enable collection of symbol position information. Enabled by
default. Currently, the position information is unusable, so
you can save a few cycles by disabling this. min-length=n, max-length=n
Bound the number of decoded characters in a valid symbol. If a
decode result is outside the configured min/max range
(inclusive), it will not be reported. Set to 0 to disable the
corresponding check. This setting applies to variable-length
symbologies: i25, code39, code128 and pdf417. min-length
defaults to 6 for i25 and 1 for code39 (per Code 39
autodiscrimination recommendation); all others default to 0 x-density=n, y-density=n
Adjust the density of the scanner passes. Lower values scan
more of the image at the cost of decreased performance. Setting
to 0 disables scanning along that axis. Defaults are both 1. -q, --quiet
Quiet operation; only output decoded symbol data. specifically this
disables the statistics line printed (to stderr) before exiting, as
well as the warning message printed (also to stderr) when no
barcodes are found in an image -d, --display, -D, --nodisplay
Enable/disable display of subsequent image files, until next
--display or --nodisplay is encountered. This option may appear
multiple times to enable display of specific images. Image display
is disabled by default --xml, --noxml
Enable/disable result output using an XML format. This format wraps
the raw data from the symbol with information about the scan (such
as page indices) in an easy to parse format. The latest schema is
available from http://zbar.sourceforge.net/2008/barcode.xsd. --raw
Enable raw symbol data output. This format prints symbol data
separated by newlines without the additional symbology type
information that is printed by default EXAMPLES
Scan a PNG image of a UPC bar code symbol and pass resulting data to a
script that searches for the code in a database and does something
useful with it: zbarimg product.png | upcrpc.py The upcrpc.py example script included in the examples/ subdirectory of
the distribution will make an XMLRPC call to a popular internet UPC
database and print the product description if found. Scan a JPEG image containing several barcodes and display the image in
a window, also disabling recognition of Interleaved 2 of 5 codes to
prevent confusion with other symbologies or background noise: zbarimg --display -Si25.disable label.jpg Look in a scanned document only for Code 39, using XML output format so
the page numbers are available. To enable only Code 39, first all
symbologies are disabled, then Code 39 is re-enabled: zbarimg --xml -Sdisable -Scode39.enable scan.tiff SEE ALSO
zbarcam(1) http://zbar.sf.net/ BUGS
See http://sf.net/tracker/?group_id=189236&atid=928515 AUTHOR
Jeff Brown <spadix@users.sourceforge.net>
Lead developer COPYRIGHT
Copyright © 2007-2009 Jeff Brown All Rights Reserved zbar-0.10 2009-10-23 ZBARIMG(1)

  

Zbar 大图像分析的更多相关文章

  1. 《JAVA语言程序设计》上课笔记

    教学目标:1.使学生了解JAVA课程的性质.定位.作用:为什么要学习JAVA?让学生知道如何学好JAVA: 教学内容: 一.        问几个问题 1.             你们到这里来干什么 ...

  2. Atitit 图像处理和计算机视觉的分类 三部分 图像处理 图像分析 计算机视觉

    Atitit 图像处理和计算机视觉的分类 三部分 图像处理 图像分析 计算机视觉 1.1. 按照当前流行的分类方法,可以分为以下三部分:三部分 图像处理 图像分析 计算机视觉1 1.2. 图像处理需要 ...

  3. (转) OpenCV学习笔记大集锦 与 图像视觉博客资源2之MIT斯坦福CMU

          首页 视界智尚 算法技术 每日技术 来打我呀 注册     OpenCV学习笔记大集锦 整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的 ...

  4. 264分析两大利器:264VISA和Elecard StreamEye Tools

    学了264有将近3个月有余,好多时候都在学习老毕的书和反复看JM86的代码,最近才找到264分析两大利器:264VISA和Elecard StreamEye Tools.不由得感叹,恨不逢同时. 简单 ...

  5. [原]Hadoop海量视频、图像分析分布式处理总结

    在刚刚入手视频图像分析时,有点不知所措,后来经过查找了很多资料.本篇文章主要叙述图像的分析处理,至于视频,实际上视频本身就是一个大文件,hadoop对于大文件处理是高效的,所以在MapReduce的处 ...

  6. 二维码开源库zbar、zxing使用心得

    首先说明我的测试场景是“识别打印在纸上的二维码”,在扫描结果中寻找二维码并进行识别,而不是直接让摄像头对着二维码扫描. zbar和zxing用的都是自己从github上clone的c++源码/接口编译 ...

  7. 第二篇:智能电网(Smart Grid)中的数据工程与大数据案例分析

    前言 上篇文章中讲到,在智能电网的控制与管理侧中,数据的分析和挖掘.可视化等工作属于核心环节.除此之外,二次侧中需要对数据进行采集,数据共享平台的搭建显然也涉及到数据的管理.那么在智能电网领域中,数据 ...

  8. 大数据测试之初识Hadoop

    大数据测试之初识Hadoop POPTEST老李认为测试开发工程师是面向测试的开发,也就是说,写代码就是为完成测试任务服务的,写自动化测试(性能自动化,功能自动化,安全自动化,接口自动化等等)的cas ...

  9. (iOS)关于zbar扫描条形码,所搭载的设备

    四个月之前写的,现在发出来. 最近在开发一款程序的时候,功能要求扫描条形码. 现在最流行的扫描条形码的开源代码有zbar和zxing两种,可以支持多种一维和二维码. 之前了解过zbar,所以这次试用z ...

随机推荐

  1. JavaScript如何处理解析JSON数据详解

    JSON (JavaScript Object Notation)一种简单的数据格式,比xml更轻巧. JSON 是 JavaScript 原生格式,这意味着在 JavaScript 中处理 JSON ...

  2. 《Effective C++》——条款04:确定对象使用前已先被初始化

    读取未初始化的值会导致不明确的行为.在某些平台上,仅仅只是读取未初始化的值,就可能让你的程序终止运行.更可能的情况是读入一些“半随机”bits,污染了正在进行读取动作的那个对象,最终导致不可预知的程序 ...

  3. New Concept English three (50)

    31 39 The New Year is a time for resolutions. Mentally, at least, most of us could compile formidabl ...

  4. python虚拟开发环境搭建(virtualenv和virtualenvwrapper)

    虚拟开发环境的搭建 (0) 搭建虚拟环境的意义 使不同的开发环境独立 环境升级不影响其他开发环境,也不影响全局 防止包管理的混乱 (1) 指定 虚拟环境的创建目录 环境变量设置 创建 WORKON_H ...

  5. Image Pyramid

    今天我们介绍图像处理邻域中比较常用的一种方法,image pyramid, 也叫图像金字塔.就是将图像进行一层一层的下采样,图像金字塔是为了构建图像的多尺度,让模型能够更好的适应图像的尺度变化,图像金 ...

  6. linux下使用fstat来计算文件的大小

    #include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <fcntl.h ...

  7. HihoCoder1407 后缀数组二·重复旋律2

    重复旋律2 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成的数列.小Hi在练习过很多 ...

  8. java向excel写数据

    package pymongo1; import java.io.File;import java.io.IOException;import java.io.OutputStream; import ...

  9. LoadRunner常见错误代码解决方案

    一.LoadRunner26377错误 通常不是长度的问题,如果长度有问题就都出错了.应该是服务器返回的数据问题,导致没有找到这个参数. 26377错误的成因很多,总结最直接的结果就是No match ...

  10. datepicker

    准备工作 首先请到jqueryui.com官网下载datepicker插件代码,注意官网提供了整个jquery ui的所有插件下载,但是您可以选择其中几个用到的插件下载,本文中只用到datepicke ...