win32 zbar
一、zbar官方介绍
ZBar 是款桌面电脑用条形码/二维码扫描工具,支持摄像头及图片扫描,支持多平台,例如 iPhone,Andriod 手机,同时 ZBar封装了二维码扫描的 API 开发包。
ZBar 目前条码类型有:EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.
从上可以看出,zbar有挺多优势,封装了API,支持多平台,支持多种条码类型,包括一维、二维码。
具体主页:http://zbar.sourceforge.net/
二、zbar的python安装
进入https://pypi.python.org/pypi/zbar,可以看到最新版本是0.10,提供源码以及python2.5、python2.6下的exe版本。
| File | Type | Py Version | Uploaded on | Size | |
|---|---|---|---|---|---|
| zbar-0.10.tar.bz2 (md5, pgp) | Source | 2009-11-10 | 15KB | ||
| zbar-0.10.tar.gz (md5, pgp) | Source | 2009-11-10 | 18KB | ||
| zbar-0.10.win32-py2.5.exe (md5, pgp) | MS Windows installer | 2.5 | 2009-11-10 | 74KB | |
| zbar-0.10.win32-py2.6.exe (md5, pgp) | MS Windows installer | 2.6 | 2009-11-10 | 205KB | |
| zbar-0.10.zip (md5, pgp) | Source | 2009-11-10 | 31K | ||
结论:没有whl,没有python2.7的exe安装,更不奢望64位版本之类。
1、pypi网址,找whl或者exe安装包
百度找到非官方发布的python2.7下zbar安装文件,https://github.com/jacobvalenta/zbar-py27-msi/blob/master/zbar-0.10.win32-py2.7_2.msi。
实测可用,这里为了说明pypi的编译过程,不使用该方案。
2、pypi源码安装
2.1、配置mingw编译环境
windows系统安装并配置mingw编译器,是另一个大坑,爬坑的过程不细说,简要描述如下:
1、下载mingw 5.1.6 ,地址如下:http://d1.rsdown.cn/soft1/mingw5.1.6.zip
2、解压后,双击其中的mingw.exe进行安装,选择常用的安装包,例如gcc等。
3、配置mingw安装路径,参看:http://blog.csdn.net/wangrouyi/article/details/7454687(注意,这个说明中的mingw是按照在d:\mingw下,如果你是安装在c盘,则要改成c:\mingw。)
右击我的电脑,点属性->高级->环境变量。然后:
1)、在PATH里加入D:\MinGW\bin,记得,如果里面还有其他的变量,记得要加个分号啊,分号得在英文输入模式下输入的。
2)、新建LIBRARY_PATH变量,如果有的话,在值中加入D:\MinGW\lib,这是标准库的位置。
3)、新建C_INCLUDEDE_PATH变量,值设为D\MinGW\include。
4)、新建CPLUS_INCLUDE_PATH变量,值为D\MinGW\include\c++\3.4.5;D:\MinGW\include\c++\3.4.5;D:\MinGW\include\c++\3.4.5\backward;D:\MinGW\include。
4、python中配置mingw编译器。
在C:\Python27\Lib\distutils下新建或者修改distutils.cfg文件,内容如下:
[build]
compiler=mingw32
2.2、pip安装(pip install zbar),下面开始逐项排雷。
1、pip install zbar,果然出现c语言编译错误,没有找到zbar.h头文件(下图中蓝色字体部分)
C:\Users\zou>pip install zbar
Collecting zbar
Downloading http://mirrors.aliyun.com/pypi/packages/33/54/cc5819efc9ee7e34b60b41e1d2d4753b6dd0c26a41c9a552611f66aa106e/zbar-0.10.tar.bz2
Installing collected packages: zbar
Running setup.py install for zbar ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__=‘c:\\users\\joshua~1\\appdata\\local\\temp\\pip-build-pnikpa\\zbar\\setup.py‘;f=getattr(tokenize, ‘open‘, open)(__file__);code=f.read().replace(‘\r\n‘, ‘\n‘);f.close();exec(compile(code, __file__, ‘exec‘))" install --record c:\users\joshua~1\appdata\local\temp\pip-2chu03-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building ‘zbar‘ extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\python27\include -Ic:\python27\PC -c zbarmodule.c -o build\temp.win32-2.7\Release\zbarmodule.o
In file included from zbarmodule.c:24:
zbarmodule.h:26:18: zbar.h: No such file or directory
In file included from zbarmodule.c:24:
zbarmodule.h:37: error: `ZBAR_ERR_NUM‘ undeclared here (not in a function)
zbarmodule.h:67: error: syntax error before "zbar_image_t"
zbarmodule.h:67: warning: no semicolon at end of struct or union
zbarmodule.h:69: error: syntax error before ‘}‘ token
zbarmodule.h:69: warning: type defaults to `int‘ in declaration of `zbarImage‘
zbarmodule.h:69: warning: data definition has no type or storage class
ext_modules = [
Extension(‘zbar‘, [
‘zbarmodule.c‘,
‘enum.c‘,
‘exception.c‘,
‘symbol.c‘,
‘symbolset.c‘,
‘symboliter.c‘,
‘image.c‘,
‘processor.c‘,
‘imagescanner.c‘,
‘decoder.c‘,
‘scanner.c‘,
],
libraries = [ ‘zbar‘ ],
include_dirs = [ ‘..\include‘ ],(自己的路径)
),
4、再次执行安装。
D:\src\python>python setup.py install
running install
running build
running build_ext
building ‘zbar‘ extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c zbarmodule.c -o build\temp.win32-2.7\Release\zbarmodule.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c enum.c -o build\temp.win32-2.7\Release\enum.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c exception.c -o build\temp.win32-2.7\Release\exception.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c symbol.c -o build\temp.win32-2.7\Release\symbol.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c symbolset.c -o build\temp.win32-2.7\Release\symbolset.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c symboliter.c -o build\temp.win32-2.7\Release\symboliter.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c image.c -o build\temp.win32-2.7\Release\image.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c processor.c -o build\temp.win32-2.7\Release\processor.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c imagescanner.c -o build\temp.win32-2.7\Release\imagescanner.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c decoder.c -o build\temp.win32-2.7\Release\decoder.o
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -Ic:\python27\include -Ic:\python27\PC -c scanner.c -o build\temp.win32-2.7\Release\scanner.o
writing build\temp.win32-2.7\Release\zbar.def
creating build\lib.win32-2.7
c:\mingw\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\zbarmodule.o build\temp.win32-2.7\Release\enum.o build\temp.win32-2.7\Release\exception.o build\temp.win32-2.7\Release\symbol.o build\temp.win32-2.7\Release\symbolset.o build\temp.win32-2.7\Release\symboliter.o build\temp.win32-2.7\Release\image.o build\temp.win32-2.7\Release\processor.o build\temp.win32-2.7\Release\imagescanner.o build\temp.win32-2.7\Release\decoder.o build\temp.win32-2.7\Release\scanner.o build\temp.win32-2.7\Release\zbar.def -Lc:\python27\libs -Lc:\python27\PCbuild -Lc:\python27\PC\VS9.0 -lzbar -lpython27 -lmsvcr90 -o build\lib.win32-2.7\zbar.pyd
c:\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lzbar
collect2: ld returned 1 exit status
error: command ‘c:\\mingw\\bin\\gcc.exe‘ failed with exit status 1
继续报错,不能zbar的lib库。
5、进入https://github.com/ZBar/ZBar/tree/master/python 目录,查看python下的说明,发现如下文字:
To install this module type the following:: python setup.py install Dependencies
------------ This module requires the ZBar Bar Code Reader, which may be obtained
from: * http://zbar.sourceforge.net/ Windows users please note: the module *will NOT load* unless the ZBar
library DLL (currently libzbar-0.dll) is available in your Windows system
PATH!
简单翻译一下:
a、python zbar安装方法:python setup.py install
b、python zbar需要zbar reader,zbar reader可以从http://zbar.sourceforge.net/网址下载到。
c、windows平台,需要zbar dll,最新版本名字为libzbar-0.dll 。
6、进入http://zbar.sourceforge.net/download.html,下载windows下的zbar reader执行程序。
Windows Installer Note that the Windows port is in an unstable, testing phase. If you do try it out, please let us know how well it‘s working for you and open a support request if you encounter any problems. The Windows Installation Guide has detailed instructions for installing and getting started with ZBar on Windows. ZBar 0.10 Windows installer The Windows installer now includes pre-built binaries of the dependencies (ImageMagick et al). Copyright, license, and source code details for these libraries may be found in the README included with the distribution. Windows binaries for the Python module are available from PyPI
具体网址:https://jaist.dl.sourceforge.net/project/zbar/zbar/0.10/zbar-0.10-setup.exe ,下载后安装zbar reader执行程序
7、安装zbar reader,默认路径 C:\Program Files (x86)\ZBar ,在bin目录下,果然找到libzbar-0.dll动态链接库文件。
8、拷贝libzbar-9.dll 到c:\python27\LIBS目录下
9、修改setup.py文件,指向zbar-0
ext_modules = [
Extension(‘zbar‘, [
‘zbarmodule.c‘,
‘enum.c‘,
‘exception.c‘,
‘symbol.c‘,
‘symbolset.c‘,
‘symboliter.c‘,
‘image.c‘,
‘processor.c‘,
‘imagescanner.c‘,
‘decoder.c‘,
‘scanner.c‘,
],
libraries = [ ‘zbar-0‘ ],
include_dirs = [ ‘..\include‘ ],
),
10、再次执行 python setup.py install
C:\src\python>python setup.py install
running install
running build
running build_ext
building ‘zbar‘ extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c zbarmodule.c -o build\temp.win32-2.7\Release\zbarmodule.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c enum.c -o build\temp.win32-2.7\Release\enum.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c exception.c -o build\temp.win32-2.7\Release\exception.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c symbol.c -o build\temp.win32-2.7\Release\symbol.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c symbolset.c -o build\temp.win32-2.7\Release\symbolset.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c symboliter.c -o build\temp.win32-2.7\Release\symboliter.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c image.c -o build\temp.win32-2.7\Release\image.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c processor.c -o build\temp.win32-2.7\Release\processor.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c imagescanner.c -o build\temp.win32-2.7\Release\imagescanner.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c decoder.c -o build\temp.win32-2.7\Release\decoder.o
C:\mingw/bin\gcc.exe -mno-cygwin -mdll -O -Wall -I..\include -IC:\Python27\include -IC:\Python27\PC -c scanner.c -o build\temp.win32-2.7\Release\scanner.o
writing build\temp.win32-2.7\Release\zbar.def
creating build\lib.win32-2.7
C:\mingw/bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\zbarmodule.o build\temp.win32-2.7\Release\enum.o build\temp.win32-2.7\Release\exception.o
build\temp.win32-2.7\Release\symbol.o build\temp.win32-2.7\Release\symbolset.o build\temp.win32-2.7\Release\symboliter.o build\temp.win32-2.7\Release\image.o
build\temp.win32-2.7\Release\processor.o build\temp.win32-2.7\Release\imagescanner.o build\temp.win32-2.7\Release\decoder.o build\temp.win32-2.7\Release\scanner.o
build\temp.win32-2.7\Release\zbar.def -LC:\Python27\libs -LC:\Python27\PCbuild -LC:\Python27\PC\VS9.0 -lzbar-0 -lpython27 -lmsvcr90 -o build\lib.win32-2.7\zbar.pyd
running install_lib
copying build\lib.win32-2.7\zbar.pyd -> C:\Python27\Lib\site-packages
running install_egg_info
Writing C:\Python27\Lib\site-packages\zbar-0.10-py2.7.egg-info
至此,编译并安装成功。
注意,上文中蓝色字体部分,Lib目录默认找了python27\libs目录,所以前文第8步拷贝到libs的奥秘正在于此。
win32 zbar的更多相关文章
- VS2010+OpenCV3.4.1+zbar 64位
1. OpenCV3.4.1和zbar文件夹放到指定的路径下,我把它们放在了"D:\二维码\环境"中. zbar:链接:https://pan.baidu.com/s/11eCDV ...
- 配置zbar识别二维码(转载)
原文地址:http://blog.csdn.net/dcrmg/article/details/52108258 二维码解码器Zbar+VS2012开发环境配置 Zbar条码解码器是一个开源的二维码 ...
- 二维码解码器Zbar+VS2012开发环境配置
Zbar条码解码器是一个开源的二维码(包括条形码)解码器,可以识别来至于视频流,图像文件.手持扫码器和视频设备(如摄像头)等二维码识别,支持EAN-13/UPC-A, UPC-E, EAN-8, Co ...
- C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper
前言 在开发应用程序时,通常只让程序运行一个实例.所以,就要判断程序是否已经运行. 下面是我自己在项目中使用到,封装好的帮助类.有 普通的 C# 应用程序 和 Windows CE 和 Windows ...
- java.lang.UnsatisfiedLinkError: %1 不是有效的 Win32 应用程序。
JNA 调用 dll 库时,保错: ///////////////// 通过 JNA 引入 DLL 库 //////////// /** * ID_FprCap.dll 负责指纹的采集, 指纹仪的初始 ...
- C#使用zxing,zbar,thoughtworkQRcode解析二维码,附源代码
最近做项目需要解析二维码图片,找了一大圈,发现没有人去整理下开源的几个库案例,花了点时间 做了zxing,zbar和thoughtworkqrcode解析二维码案例,希望大家有帮助. zxing是谷歌 ...
- 初次认识 C# win32 api
第一次接触win32api,刚开始的时候有点迷迷糊糊的. Windows API 就是windows应用程序接口. win api向上就是windows应用程序,向下就是windows操作系统核心. ...
- [老文章搬家] [翻译] 深入解析win32 crt 调试堆
09 年翻译的东西. 原文见: http://www.nobugs.org/developer/win32/debug_crt_heap.html 在DeviceStudio的Debug编译模式下, ...
- Virus.Win32.Virlock.b分析
0x00 样本说明 分析样本是被0b500d25f645c0b25532c1e3c9741667的样本感染得到.感染前的文件是Tcpview.exe,一款windows网络连接查看工具. 感染前后文件 ...
随机推荐
- PHP如何知道一个类中所有的方法
当我们使用一个类时既没有源码也没有文档时(尤其是php扩展提供的类,比如mysqli,Redis类),我们该怎么知道这个类中提供了哪些方法,以及每个方法该怎么使用呢,此时就该PHP中强大的反射登场了, ...
- Tkinter Dimensions
Tkinter Dimensions: 各种长度,宽度,和其他部件的尺寸可以在许多不同的单位描述 各种长度,宽度,和其他部件的尺寸可以在许多不同的单位描述. 如果您设置了尺寸为整数,它被假定为 ...
- 2、keys相关命令
redis的官网http://redis.io是学习redis的重要资源库,所有命令都分门别类的罗列在了这里http://redis.io/commands. 1.数据库选择命令: SELECT in ...
- DataMatrix二维条码源码分析检测识别图像位置
发布时间:2014-10-31 DataMatrix的代码结构和QR码基本相同: 其中Detector的功能还是从原始图像中找出符号码的部分,并且进行透视转换纠正扭曲. 其解码流程与QR码差不多,关键 ...
- GridhEH 选择勾CheckBox
GridhEH 选择勾CheckBox Grideh>IndicatorOptions>gioShowRowSelCheckbox
- 发生在阿里云 SLB 4 层的一次故障记录
阿里云 SLB 与 ECS 之间发生故事.环境如下: SLB api-node: 该 SLB 后端接着 10 台节点服务器 SLB sql-node: 该 SLB 后端接着 2 台节点服务器 问题描述 ...
- 【原】Coursera—Andrew Ng机器学习—Week 5 习题—Neural Networks learning
课上习题 [1]代价函数 [2]代价函数计算 [3] [4]矩阵的向量化 [5]梯度校验 Answer:(1.013 -0.993) / 0.02 = 3.001 [6]梯度校验 Answer:学习的 ...
- 深入探究jvm之GC的算法及种类
一.GC基本概念 GC(Garbage Collection)垃圾收集,1960年最早在List中使用.在Java中GC回收的对象是堆空间和永久区,可以有效避免程序员人为造成内存泄漏问题.将堆空间和永 ...
- centos7 修改静态ip 和dns
1.修改对应网卡的IP地址的配置文件# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 #描述网卡对应的设备别名,例如ifcfg-et ...
- kubernetes 集群安全配置
版本:v1.10.0-alpha.3 openssl genrsa -out ca.key 2048 openssl req -x509 -new -nodes -key ca.key -subj & ...