GetDefaultOptions Method (original) (raw)

Summary

Gets the default read options for a specified symbology.

Syntax

C#

Objective-C

C++/CLI

Java

Python

- (LTBarcodeReadOptions *)defaultOptionsForSymbology:(LTBarcodeSymbology)symbology; 
public BarcodeReadOptions getDefaultOptions(BarcodeSymbology symbology) 

Parameters

symbology
An BarcodeSymbology enumeration member that specifies the barcode symbology (or type) to get its options.

Return Value

The BarcodeReadOptions derived object used by this BarcodeReader as the default read options to use when reading barcodes of the type specified in symbology.

Example

This example shows how to get the default options used when reading standard linear 1D barcodes (UPC-A, UPC-E, etc) and changes them before reading the barcodes

using Leadtools; using Leadtools.Codecs; using Leadtools.Barcode; using Leadtools.ImageProcessing; public void BarcodeReader_GetDefaultOptionsExample() { string imageFileName = Path.Combine(LEAD_VARS.ImagesDir, "Barcode1.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()) { using (RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) { // Rotate the image by 90, so default option of reading horizonal barcodes will not work Console.WriteLine("Rotating the image by 90 degrees"); RotateCommand rotate = new RotateCommand(90 * 100, RotateCommandFlags.Resize, RasterColor.FromKnownColor(RasterKnownColor.White)); rotate.Run(image); // Read a UPCA barcode from the image using default options Console.WriteLine("Reading barcodes using default options"); BarcodeData barcode = reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.UPCA); // Show its location and data if found // This will print out "Not found" if (barcode != null) { Console.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value); } else { Console.WriteLine("Not found"); } // Now set the default options for reading 1D barcodes to search for vertical barcodes and try again OneDBarcodeReadOptions oneDReadOptions = reader.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeReadOptions; oneDReadOptions.SearchDirection = BarcodeSearchDirection.Vertical; // Read again Console.WriteLine("Reading barcodes using new options"); barcode = reader.ReadBarcode(image, LeadRect.Empty, BarcodeSymbology.UPCA); // Show its location and data if found // This will find the barcode and print its information now if (barcode != null) { Console.WriteLine("Found a {0} barcode at {1}, data:\n{2}", barcode.Symbology, barcode.Bounds, barcode.Value); } else { Console.WriteLine("Not found"); } } } } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }