如何使用Barcode Reader SDK for .NET识别图片中的条码

作者:控件中国网   出处:控件中国网   2015-09-15 14:35:37   阅读:16

Barcode Reader SDK for .NET可以帮助开发人员创建一个条码识别应用程序,可以从图片中识别常用的一维和2维条形码,下面的图片中包含了EAN-13和Code-128条码,然后可以通过Barcode Reader SDK for .NET提供的条码识别功能,快速读取图片中的这两种条形码,具体代码如下:

barcode_sample.jpg

//Create a BarcodeReader object

BarcodeReader myReader = new BarcodeReader();

//Add the barcode symbologies to be recognized

myReader.Symbology.Add(Symbology.Ean13);

myReader.Symbology.Add(Symbology.Code128);

//Set max num of barcode symbols to be detected

myReader.Hints.MaxNumOfBarcodes = 2;

//Scan the source image and get result

List<BarcodeScanResult> results = myReader.Scan(@"c:\barcode_sample.jpg");

//Display scan result

foreach (BarcodeScanResult result in results)

{

    Console.WriteLine("Barcode Type: " + result.Symbology.ToString());

    Console.WriteLine("Barcode Data: " + result.Text);

    Console.WriteLine("=============");

}

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat