Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Barcode.Net won't recognize any scanned barcodes regardless of file type

Last post 02-05-2010, 10:08 AM by saqib.razzaq. 7 replies.
Sort Posts: Previous Next
  •  02-02-2010, 1:44 PM 220327

    Barcode.Net won't recognize any scanned barcodes regardless of file type .NET

    Attachment: Present (inaccessible)

    I have tried the barcode recognition on DOZENS of scanned images with no success. I have changed the dpi and color scheme of the scanner, more than once. I have tried tif and jpg files both in multiple resolutions. Is there any reason this should not succeed? Is this a limitation of the library? I have tried DataMatrix, PDF417, and Aztec, nothing works.

    After about, oh, 4 hours or so, I created a quick barcode creator page and saved documents to the directory of the other files. I saved them in both tif and jpg formats. These files had no problem at all recognizing the barcodes. Quick, easy, perfect....as expected.

    I did have MINIMAL success with barcodes on a page that had 6 DataMatrix codes about 1inch x 1inch minimum. The recognition picked up 2 at first, then about an hour later decided to pick up 4 of them.

    What can I do? I really would like this library to work because I really like how it should work, but with this success rate there is no way I can pay for the library without a significant change. Help!

    I have tried about everything. I tried the suggested code from Aspose for reading multi-page tif files, then dumbed it down to read jpgs and single-page tif files.

    Attached are samples of the barcodes in PDF417. The "ScanX" files fail, and the "PC_GeneratedX" succeed. What now?

    Kiel

     
  •  02-02-2010, 2:27 PM 220340 in reply to 220327

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type

    An update with mild success. I chaned the setting on the scanner of the "original file type" and set it to use OCR. I have since been able to sucessfully detect datamatrix barcodes on multipage and single page scanned documents (tif file type) at 600x600 dpi in monochrome. Will continue to troubleshoot and post updates if I make another "breakthrough"

     
  •  02-02-2010, 3:11 PM 220344 in reply to 220340

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type .NET

    Hi Kiel,

    Could you please try the following code for recognition? I tested it with all 4 images (both tif and jpg) and it worked with all of them.

    BarCodeReader reader = new BarCodeReader("scan1.tif", BarCodeReadType.Pdf417);
                        reader.SetHints(RecognitionHints.ImageBinarizationHints.MedianSmoothing);
                        while (reader.Read() == true)
                        {
                            Console.WriteLine("Codetext: " + reader.GetCodeText() +
                                " Symbology: " + reader.GetReadType().ToString());
                        }
                        reader.Close();

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
  •  02-03-2010, 2:20 PM 220601 in reply to 220344

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type

    I ended up being able to recognize the barcodes eventually. I tried  your "mediansmoothing" suggestion and it also worked. The biggest change that helped was the way in which they were scanned, in a "OCR" mode of the scanner. First hurdle, done.

     

    Now, I am mostly intested in scanning through multipage documents for barcodes. I can successfully do so, but it takes SOOOOOOO long. Literally up to 1-2 minutes for an 11 page document (598KB, 2550x3300). There are only 3 barcodes within, why is this taking so long??? I am using code equivalent to the code you posted so I dont think posting it will necesarily help.

    Thank you for the first reply.

     
  •  02-03-2010, 10:11 PM 220631 in reply to 220601

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type

    Attachment: Present (inaccessible)

    Hi,

    Thank you for your post.

    Could you please attach your project and images for analysis?

    The MedianSmoothing hint can improve the recognition for some images with "white noise", but it will need more time for completing the smoothing process.

     

    Dean Deng
    Lead Developer, Aspose Guangzhou Team
    http://www.aspose.com
    Your File Format Experts
     
  •  02-04-2010, 10:28 AM 220776 in reply to 220631

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type

    Attachment: Present (inaccessible)

    The code I am using is below. I will try to add comments so that it makes more sense so you dont have to try to pick things apart. It is about 90% your code with minor modifications to suit my application. Thanks for taking a look. As I mentioned before, an 11 page document (described in previous post) will take almost 2 minutes with this code.

     

    string FullFilePath = "this is retreived from a grid";

    string FileName = "this is retrieved from a grid also";

    //Calculate the pages count

    System.Drawing.Image img = System.Drawing.Image.FromFile(FullFilePath);

    Guid guid = img.FrameDimensionsList[0];

    FrameDimension dimension = new FrameDimension(guid);

    int totalFrame = img.GetFrameCount(dimension);

    BarCodeReader rd = null;

    //This array "codepages" is used to keep track of where barcodes are found
    //within the multi-page documents. Ex: [001001001] implies there are 3 barcodes and
    //thus 3 separate documents

    int[] codepages = new int[totalFrame];

    //Feed the pages to BarCodeReader one by one
    for (int i = 0; i < totalFrame; i++){

    codepages[i] = 0;

    // Set the active page and feed it to the BarCodeReader
    img.SelectActiveFrame(dimension, i);

    rd = new BarCodeReader(new Bitmap(img), BarCodeReadType.DataMatrix);
    rd.SetHints(
    RecognitionHints.ImageBinarizationHints.MedianSmoothing);
    while (rd.Read())
    {
       codepages[i] =
    1;
    }

    }

     

    I apologize for not attaching a full file, but the file I am using is actual data from business and I shouldn't send that exact one. I will, however, attach an actual barcode page from one of those pages.

    Thank you,
    Kiel

     
  •  02-04-2010, 12:16 PM 220802 in reply to 220776

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type

    Is it not possible to search for barcodes directly in a pdf file? That would save me TONS of work and file conversions and so on. Is there an add-on for that, or will  barcode.net do that by itself?
     
  •  02-05-2010, 10:08 AM 221000 in reply to 220802

    Re: Barcode.Net won't recognize any scanned barcodes regardless of file type .NET

    Hi,

    Regarding detecting the barcodes directly from pdf file, it is possible with the help of Aspose.Pdf.Kit for .NET component. It can extract images from the pdf file and pass these images to Aspose.BarCode component, which can then detect barcodes from the extracted images.

    Sample code to read barcode from pdf file:

    try
    {
          // bind the pdf
          PdfExtractor extractor = new PdfExtractor();
          extractor.BindPdf(@"test.pdf");
          // set page range for image extraction
          extractor.StartPage = 1;
          extractor.EndPage = 1;
          // extract the images
          Console.WriteLine("Extracting images.....");
          extractor.ExtractImage();
          int i = 1;
          // save images to stream in a loop
          while (extractor.HasNextImage())
          {
                Console.WriteLine("Getting next image....");
                // save to stream
                MemoryStream stream = new MemoryStream();
                extractor.GetNextImage(stream);
                Bitmap bmp = new Bitmap(stream);
                stream.Position = 0;
                Console.WriteLine("Recognizing barcode....");
                // recognize the barcode from the image stream above
                BarCodeReader reader = new BarCodeReader(new Bitmap(stream), BarCodeReadType.Code128);
                while (reader.Read())
                {
                      Console.WriteLine("Codetext: " + reader.GetCodeText());
                }
                reader.Close();
          }
    }
    catch (Exception ex)
    {
          Console.WriteLine(ex.Message);
    }

    Best Regards,
    Saqib Razzaq
    Support Developer, Aspose Sialkot Team
    http://www.aspose.com
    Your File Format Experts
     
View as RSS news feed in XML