←Select platform

BarcodeEngine Class

Summary
Main class for the LEADTOOLS support for reading and writing barcodes.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class BarcodeEngine 
@interface LTBarcodeEngine : NSObject 
public class BarcodeEngine 
public ref class BarcodeEngine  
class BarcodeEngine: 
Remarks

The BarcodeEngine class is the main entry point for LEADTOOLS support for barcode reading and writing.

This class contains the following members:

This class also contains the following helper static (Shared in VB) methods:

To start using LEADTOOLS barcode support, first create an instance of BarcodeEngine. This will automatically create the BarcodeReader and BarcodeWriter objects for you. You can then access those objects through BarcodeEngine.Reader and BarcodeEngine.Writer to start reading or writing barcodes.

All these objects are thread-safe and you can pass the same BarcodeEngine, BarcodeReader or BarcodeWriter object to multiple threads. Additionally, you may read or write barcodes at the same time from/to different images and also create a separate BarcodeEngine for each thread if required. The BarcodeReader.ReadBarcodes(RasterImage image, LeadRect searchBounds, int maximumBarcodes, BarcodeSymbology[] symbologies, BarcodeReadOptions[] options) example shows how to create two threads: One for reading horizontal barcodes and one for reading vertical barcodes. It will then use the same BarcodeReader to try and read all the barcodes from an image using both threads.

For a list of the barcode symbologies supported by LEADTOOLS, refer to Supported Barcode Symbologies.

For a tutorial, refer to one of the Extract Barcodes Tutorials

Example

This example creates a new BarcodeEngine and reads all the barcodes in an image. For an example on writing barcodes, refer to BarcodeWriter.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeEngine_Example() 
{ 
   string[] imageFileNames = 
   { 
   Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.tif"), 
   Path.Combine(LEAD_VARS.ImagesDir, "Barcode2.tif") 
 }; 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Load the image 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      foreach (string imageFileName in imageFileNames) 
      { 
         using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
         { 
            // Read all the barcodes in this image 
            BarcodeData[] barcodes = engine.Reader.ReadBarcodes(image, LeadRect.Empty, 0, null); 
 
            // Print out the barcodes we found 
            Console.WriteLine("{0} contains {1} barcodes", imageFileName, barcodes.Length); 
            for (int i = 0; i < barcodes.Length; i++) 
            { 
               BarcodeData barcode = barcodes[i]; 
               Console.WriteLine("  {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value); 
            } 
            Console.WriteLine("-----------------"); 
         } 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Barcode Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.