JavaScript QR 码阅读器 - 可以做到吗?或者,远程服务?

发布于 2024-08-27 03:22:06 字数 301 浏览 6 评论 0原文

我正在对一个即将到来的项目进行一些初步研究,我有一个简单的问题,我想当我在其他地方寻找时我会在这里提出这个问题,以防有人有这方面的经验。

问题很简单:是否可以使用 JavaScript 读取 QR 码?是否有一个远程服务可以将位图对象从相机传递到该服务并以这种方式执行?目前是否有任何库允许这样做?

该项目将部署到各种移动设备上,我们想尝试使用 Appcelerator 来使其工作。我知道 Appcelerator 确实在其主机设备上公开了相机 API,但无论我们用它做什么都必须能够解析 QR 码。这是可以做的事情吗?

提前致谢! 米克

I'm doing a bit of preliminary research on an upcoming project and I have a quick question that I figure I'll throw up here while I look elsewhere, in case anyone has any experience with this.

The question is simple: is it possible to read a QR code using JavaScript? Is there a remote service to which I can pass a bitmap object from a camera and do it that way? Are there currently any libraries that allow this?

The project is going to be deployed to various mobile devices and we'd like to try to use Appcelerator to make it work. I know Appcelerator does expose the Camera API on its host devices, but whatever we do with it has to be able to parse QR codes. Is this something that can be done?

Thanks in advance!
myk

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

要走就滚别墨迹 2024-09-03 03:22:06

我打赌这是可能的,但这将是一个挑战。有人编写了一个用于读取 QR 码的 AS3 库。我首先阅读 Canvas 中的图像操作

如果您走远程 API 路线,Kaywa 有一个您可以使用的 API。

I bet it's possible, but it would be a challenge. Someone's written an AS3 library for reading QR codes. I'd start by reading up on image manipulation in Canvas.

If you go down the remote API route, Kaywa have an API you may be able to use.

单身情人 2024-09-03 03:22:06

您可以使用 getUserMedia API 从网络摄像头获取视频,然后将其放入画布元素中,并使用画布读取像素并解码 QR 码。

我不知道有一个库可以解码 QR 码,但这里有一个库 可以做条形码。

You can use the getUserMedia API to get video from the webcam and you could put it into a canvas element and use the canvas to read the pixels and decode a QR code.

I don't know of a library to decode QR codes but here is one library that can do bar codes.

一桥轻雨一伞开 2024-09-03 03:22:06

已经有一个 javascript library 了,但是注释大多是日语,而且没有文档。

There's a javascript library already, however the comments are mostly in Japanese and there's no documentation.

安静被遗忘 2024-09-03 03:22:06

由于移动设备上 JavaScript 的内存限制,如果纯 JS 可以的话,实际使用可能会花费太长时间。

我不确切知道 Appcelerator API 如何与外部本机库配合使用,但最好的选择是将图像数据传递到本机代码(Objective-C 或 Java),然后使用较低级别的库(例如 iphone-qrcode) 解析二维码,然后将结果传回 JS 执行上下文。

这具有离线工作的额外优势,这是远程服务无法做到的。

Because of memory limits for JavaScript on mobile devices, it's likely to take too long for practical use, if it is possible with purely JS.

I don't know exactly how the Appcelerator API works with external native libraries, but your best bet is to pass the image data to the native code (Objective-C or Java) and then use a lower-level library (like iphone-qrcode) to parse the QR code, then pass the result back to the JS execution context.

This has the added advantage of working offline, which a remote service could not do.

我不在是我 2024-09-03 03:22:06

如果您想要概念验证,那么这里就是 - 运动跟踪器用纯 JavaScript 编写。

然而,目前对其的支持并不广泛。据我所知,只有 FF 和最新的 Webkit 版本支持它。

刚刚注意到您希望将其用于移动设备。那么绝对要选择远程服务。即使是最高端的设备(假设它们支持它)也会非常繁重,对此我非常怀疑。

If you want a proof-of-concept, then here it is - a motion tracker written in pure Javascript.

However, support for it is not widespread right now. Only FF and the latest Webkit builds support it afaik.

Just noticed that you wanted this for a mobile device. Then absolutely go with a remote service. It will be really taxing even on the most high end devices assuming they even support it, which I highly doubt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文