Home : Barcodes : Improving barcode reading speed/accuracy
Q10438 - HOWTO: Improving barcode reading speed/accuracy

This article discusses some settings and techniques you can use to improve barcode reading.

The first and most obvious advise is making sure you have a clean, deskewed, and bitonal (black and white) image to barcode. We have that BinarizeCommand to gracefully threshold an image to black and white. Once it is Pixel1bppIndexed you can use the AutoDeskewCommand to deskew it. If you have noisy images the DocumentDespeckleCommand will remove small specks. The MorphoDocumentCommand can be used to close small gaps or lighten dark areas.

When you run in to issues barcoding I would recommend saving the images out (after any processing) and inspecting them visually. If the barcode is blurry or lines run together or is otherwise hard for you to see then it will be hard for the barcoding to recognize it as well.

Example:
if
(image.PixelFormat != PixelFormat.Pixel1bppIndexed)
{
  
BinarizeCommand bc = new BinarizeCommand(BinarizeMethod.AdaptiveThreshold);
  
AtalaImage bwImage = bc.Apply(image).Image;

   if(!bc.InPlaceProcessing)
   {
      image.Dispose();
      image = bwImage;
   }
}

AutoDeskewCommand adc = new AutoDeskewCommand();
AtalaImage deskewed = adc.Apply(image).Image;
if (!adc.InPlaceProcessing)
{
   image.Dispose();
   image = deskewed;
}

The second is using the ScanInterval setting on the ReadOpts object. The barcode reader scans across a line looking for barcode content. Setting the ScanInterval higher means it ends up having to check fewer lines which will speed up overall processing.

Example:
BarCodeReader reader = new BarCodeReader(image);
ReadOpts opts = new ReadOpts();
opts.ScanInterval = 10;
BarCode[] codes = reader.ReadBars(opts);

The last suggestion is that if you know what region a page a given barcode will be you can set the RectOfInterest property on the ReadOpts object to only check a smaller area. This will have a significant impact on your processing speed. The fewer pixels the barcode reader needs to check the faster it will be. If you know a barcode will even be roughly the upper/leftquarter of an image and can set the RectOfInterest = new Rectangle(0, 0, img.Width / 2, img.Height / 2) that will mean the barcode reader is doing 1/4 of the work (meaning it will take roughly 1/4 of the time) while only skipping areas you already know won't have barcodes.

Example:
BarCodeReader reader = new BarCodeReader(image);
ReadOpts opts = new ReadOpts();
opts.RectOfInterest = new Rectangle(0, 0, image.Width / 2, image.Height / 2); //example only. Your barcode may not be in the top/left quadrant.
BarCode[] codes = reader.ReadBars(opts);

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved