从php中的图像读取/解码条形码 [英] Read/decode bar codes from an image in php

查看:445
本文介绍了从php中的图像读取/解码条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究构建一个13位EAN条形码扫描器,该扫描器可在移动设备上在网络上运行,并将使用设备相机拍摄条形码图像进行扫描和解码。我不是想通过原生应用程序来做这件事,因为我更愿意将这部分作为我的原生网站搜索体验。例如。移动设备上的网站访问者将被提示扫描条形码而无需打开应用程序。

I am look at building a 13 digit EAN bar code scanner which works on the web on mobile devices and will use the devices camera to take an image of bar code to scan and decode. I'm not trying to do this through a native app as I would prefer to make this part of my native website search experience. E.g. website visitors on a mobile will be prompted to scan a bar code without having to open an app.

此脚本适用于桌面 https://github.com/EddieLa/JOB 并使用Navigator.getUserMedia属性在JavaScript中完成所有这些操作但Android中的支持才刚刚开始不存在对IOS的支持 http://caniuse.com/#feat=stream

This script works well on desktop https://github.com/EddieLa/JOB and uses the Navigator.getUserMedia property to do all this in JavaScript however support in Android is only just starting and support on IOS is non-existent http://caniuse.com/#feat=stream

所以我想知道我是否可以支持移动设备这是我想要做的全部,而不是阅读浏览器中的条形码,条形码的图片,通过Ajax将其发送到服务器,让服务器解码图像并将响应发送回网页。

So I am wondering if I can instead, to support mobile devices which is the whole point of what I am trying to do, rather than read the bar code in the browser, take a picture of the bar code, send this to a server via Ajax, have the server decode the image and send the response back to webpage.

通过这种方法,我知道有些python脚本可以读取条形码,例如 https://pypi.python.org/pypi/zbar ,但是它有PHP等价吗?

With this approach I know there are python scripts which can read a bar code, such as https://pypi.python.org/pypi/zbar, however are there PHP equivalents to this?

推荐答案

根据我的经验 ZBAR 只是经过长时间的研究后我发现了最好的一个,并尝试了其他免费选项,包括BarBara。只需下载并安装ZBar(取决于您的操作系统)并运行PHP的 exec 命令。 Windows示例:

From my experience ZBAR is just the best one I found after a long research and many tries with other free options available, including BarBara. Just download and install ZBar (depending on your OS) and run PHP's exec command. Windows example:

exec('C:\\"Program Files (x86)"\\ZBar\\bin\\zbarimg -q C:\\path\\img.jpg', $result);

print_r($result);

我在多种格式的10.000+大图像中运行ZBar(jpg,gif,png& bmp)并且它在大约70%的条件下成功检测到了条形码。它可以读取许多条形码格式,包括EAN-13,QR-Code等,并且可以读取同一图像中的多个条形码。确实值得一试!

I run ZBar in 10.000+ big images in many formats (jpg, gif, png & bmp) and it detected the barcodes successfully in about 70% of them. It can read many barcode formats, including EAN-13, QR-Code and others, and can read multiple barcodes in the same image as well. Defenitely worth a try!

这篇关于从php中的图像读取/解码条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆