简体   繁体   English

如何查找PDF文档的条形码

[英]How to find barcodes of a PDF document

I started searching how to create a Windows Phone 8 app to recognize barcodes inside a PDF document. 我开始搜索如何创建Windows Phone 8应用程序以识别PDF文档中的条形码。

My best guest is to following the process below: 我最好的客人是遵循以下过程:

  1. Find a lib to split PDF documents into image streams (one per page). 查找一个可将PDF文档拆分为图像流的库(每页一个)。
  2. Find a lib to recognize if there is a barcode in the image stream: 查找库以识别图像流中是否存在条形码:

    2.1. 2.1。 Try to recognize barcode in each portion of the image, ie: 尝试识别图像各部分中的条形码,即:

    try #1 (from y = 0, x = 0 to y = 100, x = 100); 尝试#1(从y = 0,x = 0到y = 100,x = 100);

    try #2 (from y = 100, x = 0 to y = 200, x = 100); 尝试#2(从y = 100,x = 0到y = 200,x = 100);

    try #3 (from y = 200, x = 0 to y = 300, x = 100); 尝试#3(从y = 200,x = 0到y = 300,x = 100);

    and so on. 等等。

I'm wondering if this is the best approach to accomplish barcode recognition in a PDF document using WP8. 我想知道这是否是使用WP8在PDF文档中完成条形码识别的最佳方法。

Another concern is about whether this process when executed by a not so good device will present an acceptable performance. 另一个问题是,当该过程由性能不佳的设备执行时,是否会表现出令人满意的性能。

Someone already did that? 已经有人做过吗? Any advice? 有什么建议吗?

UPDATE UPDATE

I want to scan ITF barcodes, ie, I need to scan the barcode in this image: 我要扫描ITF条形码,即需要扫描此图像中的条形码: 在此处输入图片说明

I'm trying to start achieving the scanning barcodes from a Image, but I'm not getting success. 我正在尝试开始实现从Image扫描条形码,但没有成功。 Below is my first try: 下面是我的第一次尝试:

        //get the assets folder for the app
        StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");

        BitmapSource bitmapSource = await GetBitmapImage(folder, "Barcode.png");
        WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapSource);

        var rgb = new RGBLuminanceSource(writeableBitmap.ToByteArray(), writeableBitmap.PixelWidth, writeableBitmap.PixelHeight);
        var hybrid = new HybridBinarizer(rgb);
        BinaryBitmap binBitmap = new BinaryBitmap(hybrid);

        Reader reader = new ITFReader();

        try
        {
            Result result = reader.decode(binBitmap);
            if (result != null)
            {
                this.textBlock.Text = result.Text;
            }
        }
        catch (Exception ex)
        {
            this.textBlock.Text = ex.Message;
        }

Unfortunately, my text box is being filled up with this Exception: 不幸的是,我的文本框中充满了以下异常:

        Exception of type 'com.google.zxing.ReaderException' was thrown.

I'm using this "lib": https://silverlightzxing.codeplex.com/ 我正在使用此“ lib”: https : //silverlightzxing.codeplex.com/

Yes, this concept actually works. 是的,这个概念确实有效。

  • Read the PDF as Image Image阅读PDF
  • after that use any external Library to detect Barcodes from image. 之后,使用任何外部库从图像中检测Barcodes (There are many libraries available to do so) (有许多可用的库来做到这一点)

And for another concern that you mentioned regarding performance of Low-End devices, it depends on many things. 对于您提到的有关低端设备性能的另一个担忧,它取决于许多因素。

  • First of all it depends on the library that you use to convert PDF to Image 首先,它取决于您用来将PDF转换为Image
  • then library that you use to detect Barcode from Image . 然后是用于从Image检测Barcode库。

though there is no certainity for Time Complexity in this Task, what i think is it will not take much time then required..! 尽管无法确定此任务中的时间复杂性,但我认为将不需要那么多时间。 It's a general process, so you can go with the scenario above. 这是一个常规过程,因此您可以使用上述方案。

Hope that helps... 希望有帮助...

I'd like to help you to implement the part 1 of the solution, render PDF to image: this blog post shows how to do it on windows phone and this lib can be used to convert PDFs to images in universal windows store apps as well as xamarin apps. 我想帮助您实施解决方案的第1部分,将PDF转换为图像: 此博客文章显示了如何在Windows Phone上执行此操作 ,该lib也可用于在通用Windows Store应用程序中将PDF转换为图像作为xamarin应用。 I personally use it in my projects and because it offers same API for all platforms it fits incredibly well. 我亲自在项目中使用它,因为它为所有平台提供了相同的API,因此非常适合。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM