利用人工智能识别条形码

发布于 2024-09-15 07:28:57 字数 493 浏览 1 评论 0原文

作为一个宠物项目/学习经验(不,这不是家庭作业),我正在开发从照片中识别条形码的软件。我并不是在寻找能够实现这一点的软件或库 - 相反,我将其用作学习练习,我正在写博客并将其发布在 Codeplex 上。

我的代码可以成功识别 EAN13 条形码(我在 CodePlex 上发布) 并且应该遵循 UPC 版本 A/E不久。不过,我有两个方面值得关注。首先是解码图片中有点模糊或对比度差等的条形码。其次是在更大的图片中简单地找到实际的条形码(现在你必须给我一张只有条形码的照片)。

我有一种直觉,某种形式的人工智能会帮助我解决这个问题。我过去玩过一点遗传算法,而且我很久以前就学过人工智能课程,所以它对我来说并不完全陌生,但我不太确定从哪里开始。

什么类型的算法最适合此类问题?对于 AI 繁重的工作有什么推荐的读物或代码吗?是的,我想了解发生了什么,但我不一定想自己深入到编码等级别。

As a pet project/learning experience (no this is not homework) I'm working on software to recognize barcodes from a photograph. I'm not looking for software or a library that does it - instead I'm using this as a learning exercise that I'm blogging about and will post up on Codeplex.

I have code that successfully recognizes EAN13 barcodes (which I published on CodePlex) and UPC version A/E should follow shortly. I have two areas that I'm concerned about, though. First is in decoding barcodes that are in a picture that is bit blurry or with poor contrast, etc. Second is in simply finding the actual barcode in a larger picture (right now you have to give me a photo of just the barcode).

I have the gut feeling that some form of AI is going to help me out here. I played a bit in the past with genetic algorithms and I took a course ages ago on AI so it's not totally foreign to me, but I'm not quite sure where to start.

What type of algorithm is best suited to this type of problem? Any recommended reading or code for the AI grunt work? Yes, I want to understand what's happening, but I don't necessarily want to go down to the level of coding the sorts, etc myself.

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

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

发布评论

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

评论(3

绝影如岚 2024-09-22 07:28:57

我建议搜索条形码具有的属性。我想到的一些是:

  1. 颜色直方图显示大约均匀分布的两种不同颜色
  2. 进行 hough 变换 找到许多平行线
  3. 线的粗细有两个不同的维度。

还有其他的吗?

有了这个,我会将图像分成几部分,并使用这些特征进行分类,然后结合结果来计算该部分是否包含条形码的可能性。

对于你的第二个问题(模糊图像),我建议计算 一阶导数灰度值,然后检测该空间中线条的边缘。如果图像模糊,导数的最大值会较低,但在一定的模糊系数下应该可以检测到。

这对你有帮助吗?

I would suggest to search for properties that a barcode has. Some that I have in mind are:

  1. Histogram of colors shows two distinct colors in about even distribution
  2. Doing a hough transformation finds many parallel lines
  3. The thickness of the lines have two distinct dimensions.

Some other?

Having this I would split the image into pieces and do a classification with these features then cobine the results to calculate a liklyhood if the piece contains an barcode or not.

For your second problem (blurry image) I would suggest to calculate the 1st order derivative of the grayvalues and then detect the edges of the lines in this space. The maximum of the derivative is lower if the image is blurred but it should be detectable to a certain blurring factor.

Does this help you?

绿萝 2024-09-22 07:28:57

正如 mp 已经指出的那样,你不需要任何真正的人工智能技术。请参阅 Real World Haskell 的第 12 章。它实现了一个几乎完整的条形码识别器。示例代码是用 Haskell 编写的,但有大量解释,因此即使没有 Haskell 经验,您也可以理解其中的想法和技巧。

如果你想用人工智能解决这个问题,那么最好的选择可能是使用人工神经网络。对于给定的问题,我建议使用一种非常先进的技术,称为 HyperNEAT。请参阅我的解释(和链接)作为 SO 问题的第一个答案 神经网络网络大小...

我可能会使用两个或三个不同的网络,

  • 第一个在更大的图片上找到条形码。每个像素/像素组有一个输出神经元,如果该像素似乎是条形码的一部分,则输出值是置信度。根据结果​​,我将使用一些图像转换将其转换为“标准”格式(x*y 矩形)。
  • 如果您难以找到条形码的位置,请使用第二个。输入第一个的结果,并要求它给出两个角的坐标。然而,我不太确定进化这个会很容易。
  • 最后一个将使用标准化格式,为每行(或正方形,如果您使用可能的二维条形码)输出神经元,说明给定区域是否应被视为黑色或白色。

也许它也有助于对图像进行一些预处理,例如 RWH 中描述的那些预处理。

As mp already noted you don't necessary need any real AI technique for it. Have a look at chapter 12 of Real World Haskell. It implements an almost complete barcode recognizer. Sample code is in Haskell, but there is plenty of explanation, so you can probably understand the ideas and tricks even without Haskell experience.

If you want to solve it with AI then the best bet is probably using ANNs. For the given problem I would recommend to use a quite advanced technique called HyperNEAT. See my explanation (and links) as the first answer to the SO question Neural Network Size...

I would probably use two or three different networks,

  • The first one to find the barcode on the bigger picture. One output neuron per pixel/set of pixels, output value is the confidence if that pixel seems to be a part of a barcode. Based on the result I would use some image transformation to convert it to a "standard" format (x*y rectangle)
  • If you have difficulties with finding the location of the barcode use a second one. Feed the result of the first one, and ask it to give the coordinates of two corners. However, I'm not quite sure that it will be very easy to evolve this one.
  • Last one would work on the standardized format, output neurons for each line (or square, if you work with a possibly 2D barcode), saying if the given area should be considered black or white.

Probably it would also help to do some pre-processing of the image, e.g. those that are described in RWH.

‘画卷フ 2024-09-22 07:28:57

您不需要任何特定的人工智能或软计算技术。您需要应用图像处理技术来提高图像质量或从较大图像中分离出条形码。
您可以使用 Matlab 进行原型设计并了解有关图像处理的更多信息。

You don't need any specific AI or softcomputing technique. You need to apply image processing technique to improve the quality of the image or to isolate the barcode from a larger image.
You could use Matlab for prototyping and learnig more about image processing.

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