ByteScout Barcode Suite - C# - Image preprocessing filters with barcode reader sdk - ByteScout

ByteScout Barcode Suite – C# – Image preprocessing filters with barcode reader sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Barcode Suite – C# – Image preprocessing filters with barcode reader sdk

image preprocessing filters with barcode reader sdk in C# and ByteScout Barcode Suite

image preprocessing filters with barcode reader sdk in C#

This page helps you to learn from code samples for programming in C#. ByteScout Barcode Suite was created to assist image preprocessing filters with barcode reader sdk in C#. ByteScout Barcode Suite is the set that includes three different SDK products to generate barcodes, read barcodes and read and write spreadsheets: Barcode SDK, Barcode Reader SDK and Spreadsheet SDK.

This rich and prolific sample source code in C# for ByteScout Barcode Suite contains various functions and options you should do calling the API to implement image preprocessing filters with barcode reader sdk. If you want to implement this functionality, you should copy and paste code below into your app using code editor. Then compile and run your application. Check these C# sample code examples to see if they acknowledge to your needs and requirements for the project.

ByteScout Barcode Suite is available as a free trial. You may get it from our website along with all other source code samples for C# applications.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using Bytescout.BarCodeReader; namespace ImagePreprocessingFilters { /// <summary> /// This exmaple demonstrates the use of image filters to improve the decoding or speed. /// </summary> class Program { static void Main() { using (Reader reader = new Reader("demo", "demo")) { // Set barcode type to find reader.BarcodeTypesToFind.Code128 = true; // WORKING WITH LOW CONTRAST BARCODE IMAGES // Add contrast adjustment for low-contrast image reader.ImagePreprocessingFilters.AddContrast(40); Console.WriteLine("Image {0}", "low-contrast-barcode.png"); FoundBarcode[] barcodes = reader.ReadFrom("low-contrast-barcode.png"); if (barcodes.Length == 0) Console.WriteLine("No barcode found!"); else foreach (FoundBarcode barcode in barcodes) Console.WriteLine("Found barcode {0} with value '{1}'", barcode.Type, barcode.Value); reader.ImagePreprocessingFilters.Clear(); Console.WriteLine(); // WORKING WITH NOISY BARCODE IMAGES // Add the median filter to lower the noise reader.ImagePreprocessingFilters.AddMedian(); Console.WriteLine("Image {0}", "noisy-barcode.png"); /* ----------------------------------------------------------------------- NOTE: We can read barcodes from specific page to increase performance. For sample please refer to "Decoding barcodes from PDF by pages" program. ----------------------------------------------------------------------- */ barcodes = reader.ReadFrom("noisy-barcode.png"); if (barcodes.Length == 0) Console.WriteLine("No barcode found!"); else foreach (FoundBarcode barcode in barcodes) Console.WriteLine("Found barcode {0} with value '{1}'", barcode.Type, barcode.Value); reader.ImagePreprocessingFilters.Clear(); Console.WriteLine(); // WORKING WITH DENSE AND ILLEGIBLE BARCODES // Add the scale filter to enlarge the barcode to make gaps between bars more distinguishable reader.ImagePreprocessingFilters.AddScale(2d); // enlarge twice Console.WriteLine("Image {0}", "too-dense-barcode.png"); barcodes = reader.ReadFrom("too-dense-barcode.png"); if (barcodes.Length == 0) Console.WriteLine("No barcode found!"); else foreach (FoundBarcode barcode in barcodes) Console.WriteLine("Found barcode {0} with value '{1}'", barcode.Type, barcode.Value); reader.ImagePreprocessingFilters.Clear(); Console.WriteLine(); // REMOVE EMPTY MARGINS FROM IMAGE TO SPEED UP THE PROCESSING // Add the crop filter to cut off empty margins from the image. // This will not improve the recognition quality but may speed up the processing // if you enabled multiple barcode types to search. reader.ImagePreprocessingFilters.AddCropDark(); Console.WriteLine("Image {0}", "barcode-with-large-margins.png"); barcodes = reader.ReadFrom("barcode-with-large-margins.png"); if (barcodes.Length == 0) Console.WriteLine("No barcode found!"); else foreach (FoundBarcode barcode in barcodes) Console.WriteLine("Found barcode {0} with value '{1}'", barcode.Type, barcode.Value); reader.ImagePreprocessingFilters.Clear(); Console.WriteLine(); } Console.WriteLine("Press any key to exit.."); Console.ReadKey(); } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Barcode Suite Home Page

Explore ByteScout Barcode Suite Documentation

Explore Samples

Sign Up for ByteScout Barcode Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next