简体   繁体   中英

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.

My best guest is to following the process below:

  1. Find a lib to split PDF documents into image streams (one per page).
  2. Find a lib to recognize if there is a barcode in the image stream:

    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);

    try #2 (from y = 100, x = 0 to y = 200, x = 100);

    try #3 (from y = 200, x = 0 to 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.

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

I want to scan ITF barcodes, ie, I need to scan the barcode in this image: 在此处输入图片说明

I'm trying to start achieving the scanning barcodes from a Image, but I'm not getting success. 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/

Yes, this concept actually works.

  • Read the PDF as Image
  • after that use any external Library to detect Barcodes from image. (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
  • then library that you use to detect Barcode from Image .

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. I personally use it in my projects and because it offers same API for all platforms it fits incredibly well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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