←Select platform

Reader Property

Summary
Gets the instance of the BarcodeReader class associated with this barcode engine that can be used to read barcodes from an image.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public BarcodeReader Reader { get; } 
@property (nonatomic, strong, readonly) LTBarcodeReader *reader; 
public BarcodeReader getReader() 
public: 
property BarcodeReader^ Reader { 
   BarcodeReader^ get(); 
} 
Reader # get  (BarcodeEngine) 

Property Value

The instance of the BarcodeReader class associated with this barcode engine that can be used to read barcodes from an image.

Remarks

The BarcodeReader class is used to read one or more barcodes from an image. You cannot create an instance of BarcodeReader directly, instead, use the instance created inside BarcodeEngine which is accessed through BarcodeEngine.Reader.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Barcode; 
using Leadtools.ImageProcessing; 
 
 
public void BarcodeReader_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(); 
 
   // Get the Barcode reader instance 
   BarcodeReader reader = engine.Reader; 
 
   // 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 = 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:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
import java.util.*; 
import java.util.concurrent.ExecutorService; 
import java.util.concurrent.Executors; 
 
import org.junit.*; 
import org.junit.Test; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.barcode.*; 
import leadtools.codecs.*; 
import leadtools.imageprocessing.*; 
import leadtools.internal.ManualResetEvent; 
 
 
public void barcodeReaderExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String imageFileName = combine(LEAD_VARS_IMAGES_DIR, "barcode1.tif"); 
 
   // Create a Barcode engine 
   BarcodeEngine engine = new BarcodeEngine(); 
 
   // Get the Barcode reader instance 
   BarcodeReader reader = engine.getReader(); 
 
   // Load the image 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.load(imageFileName, 0, CodecsLoadByteOrder.BGR_OR_GRAY, 1, 1); 
 
   // Read all the barcodes in this image 
   BarcodeData[] barcodes = reader.readBarcodes(image, LeadRect.getEmpty(), 0, null); 
 
   // Print out the barcodes we found 
   int index = 0; 
   System.out.printf("%1s contains %2s barcodes%n", imageFileName, barcodes.length); 
 
   for (int i = 0; i < barcodes.length; i++) { 
      BarcodeData barcode = barcodes[i]; 
      System.out.printf("  %1s - %2s - %3s%n", i + 1, barcode.getSymbology(), barcode.getValue()); 
      index = i; 
   } 
 
   assertTrue("Not all barcodes are present", index == barcodes.length - 1); 
   System.out.println("All barcodes have been accounted for"); 
   System.out.println("-----------------"); 
} 
Requirements

Target Platforms

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

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