用于检测图像中的QRCode的示例代码

编程入门 行业动态 更新时间:2024-10-07 08:27:05
本文介绍了用于检测图像中的QRCode的示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在C#中使用此代码对QRCode进行解码(但无法检测到),并且有效:

I use this code in C# to decode (not detect) a QRCode and it works:

LuminanceSource ls = new RGBLuminanceSource(image, image.Width, image.Height); Result result = new QRCodeReader().decode(new BinaryBitmap(new HybridBinarizer(ls)));

现在,我想在更复杂的图像中检测QRCode,其中包含许多其他内容,例如图像和文本.我无法理解如何完成此操作,因为我找不到任何示例,而且将位图(C#)转换为检测器的Bitmatrix(zxing)并不是那么直接.

Now I would like to detect a QRCode in a more complex image with a lot of other stuffs such images and text. I'm not able to understand how to accomplish this because I cannot find any sample and transforming Bitmap (C#) to Bitmatrix for Detector (zxing) is not so direct.

有人有一段代码可以给我吗?

Does anyone have a piece of code to give me?

非常感谢

我尝试了这段代码,但出现了ReaderException:

I try this code but I get a ReaderException:

代码:

LuminanceSource ls = new RGBLuminanceSource(bitmap, bitmap.Width, bitmap.Height); QRCodeMultiReader multiReader = new QRCodeMultiReader(); Result[] rs = multiReader.decodeMultiple(new BinaryBitmap(new HybridBinarizer(ls)), hints); return rs[0].Text;

例外

com.google.zxing.ReaderException: in com.google.zxing.qrcode.detector.FinderPatternFinder.selectBestPatterns() in com.google.zxing.qrcode.detector.FinderPatternFinder.find(Hashtable hints) in com.google.zxing.qrcode.detector.Detector.detect(Hashtable hints) in com.google.zxing.qrcode.QRCodeReader.decode(BinaryBitmap image, Hashtable hints) in com.google.zxing.qrcode.QRCodeReader.decode(BinaryBitmap image) in ...Logic.BarCodeManager.QRCodeReader(Bitmap bitmap) in

更新02/12/2011

我刚刚尝试用iPhone上的应用程序扫描打印的QRCode(帖子顶部的代码段),并且效果很好!因此,问题肯定在检测/解码阶段.

UPDATE 02/12/2011

I have just tried to scan the printed QRCode (with the piece of code on the top of the post) with an App on my iPhone and it works well! So the problem is surely in the detection/decode phase.

推荐答案

虽然很旧.我仍然想发布它,以防有人需要.图像的噪声使zxing难以检测到qrcode.如果图像无噪点,则效果会更好.我使用一种简单的方法来减少扫描图像的噪点.可以通过缩小图像来完成.缩小因数可能会因图像的噪点而异.我发现因子3在我的情况下效果很好.

Though it's old. I still want to post it in case someone needs it. The noise of images makes them difficult for zxing to detect qrcodes. The results are much better if the images are noise free. I use a simple method to reduce noise of scanned images. It can be done by shrinking the image. The shrink factor may vary by the noise of images. I found the factor 3 works fine in my case.

更多推荐

用于检测图像中的QRCode的示例代码

本文发布于:2023-11-28 04:31:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   图像   代码   QRCode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!