LEADTOOLS v18多平台条码识别(代码示例)

LEADTOOLS v18即LEADTOOLS Anywhere)将其世界领先的成像技术扩展到了WinRT、iOS、Android、Windows Phone和Linux等平台。不仅如此,用户还可以在所有流行平台中实现查看、注释和标记、OCR、条形码、PDF、图像格式、压缩和图像处理等功能。

LEADTOOLS在每个开发平台上面都提供了一组非常相似的开发库,这是LEADTOOLS的一个非常明显的优势,让开发者既能够开发原生的应用程序,又不用花费太多的时间进行完全的代码重写。

LEADTOOLS Anywhere功能

  • 提供了专门针对.NET, HTML5, WinRT, Windows Phone, iOS, OS X和Android的图像查看器;
  • 支持加载、转换和保存超过150种图像格式;
  • 支持条形码读写,包括:QR码,PDF417,二维码,UPC/EAN等;
  • OCR将图像转换为可搜索的文本,PDF,DOC;
  • 全面的注释和标记,包括几何形状,便条,编校,亮点和橡皮图章;
  • 拥有超过200多种图像处理功能,如图像增强,图像纠偏等

接下来,我们就一起展示一下LEADTOOLS Anywhere如何在每个平台上面读取条形码。

.NET

System.Drawing.Bitmap bitmap = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.FromImage(bitmap);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.Reader.ReadBarcode(rasterImage,
LogicalRectangle.Empty, BarcodeSymbology.Unknown);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Console.WriteLine("Symbology:{0}", barcodeData.Symbology);
Console.WriteLine("Location:{0},{1},{2},{3}", barcodeData.Bounds.X,
barcodeData.Bounds.Y, barcodeData.Bounds.Width, barcodeData.Bounds.Height);
Console.WriteLine("Value:{0}", barcodeData.Value);
} else {
Console.WriteLine("No barcodes found");
}

LEADTOOLS v18多平台条码识别代码示例

WinRT & Windows Phone

Windows.UI.Xaml.Media.ImageSource imageSource = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.ConvertFromImageSource(
imageSource, ConvertFromImageOptions.None);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.Reader.ReadBarcode(rasterImage,
LogicalRectangle.Empty, BarcodeSymbology.Unknown);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Console.WriteLine("Symbology:{0}", barcodeData.Symbology);
Console.WriteLine("Location:{0},{1},{2},{3}", barcodeData.Bounds.X,
barcodeData.Bounds.Y, barcodeData.Bounds.Width, barcodeData.Bounds.Height);
Console.WriteLine("Value:{0}", barcodeData.Value);
} else {
Console.WriteLine("No barcodes found");
}

LEADTOOLS v18多平台条码识别代码示例

iOS & OS X

UIImage* uiImage = ... //
// Get a LEADTOOLS RasterImage from the platform image
LTRasterImage* rasterImage = [LTRasterImageConverter convertFromImage:uiImage
options:LTConvertFromImageOptions_None error:nil];
// Create a LEADTOOLS Barcode Engine instance
LTBarcodeEngine* barcodeEngine = [LTBarcodeEngine new];
// Read the first barcode found in the image
LTBarcodeData* barcodeData = [barcodeEngine.reader readBarcode:rasterImage
searchBounds:LeadRect_Empty() symbologies:nil symbologiesCount:0 error:nil];
// For this example, simply retrieve the barcode type, location and data
if(barcodeData != nil) {
NSLog(@"Symbology:%u", barcodeData.symbology);
NSLog(@"Location:%u,%u,%u,%u", barcodeData.bounds.x, barcodeData.bounds.y,
barcodeData.bounds.width, barcodeData.bounds.height);
NSLog(@"Value:%@", barcodeData.value);
} else {
NSLog(@"No barcodes found");
}

LEADTOOLS v18多平台条码识别代码示例

Android

android.graphics.Bitmap bitmap = ... //
// Get a LEADTOOLS RasterImage from the platform image
RasterImage rasterImage = RasterImageConverter.convertFromBitmap(
bitmap, ConvertFromImageOptions.NONE);
// Create a LEADTOOLS Barcode Engine instance
private BarcodeEngine barcodeEngine = new BarcodeEngine();
// Read the first barcode found in the image
BarcodeData barcodeData = barcodeEngine.getReader().readBarcode(
rasterImage, LeadRect.getEmpty(), BarcodeSymbology.UNKNOWN);
// For this example, simply output the barcode type, location and data in the console
if (barcodeData != null) {
Log.i("LEADTOOLS.BarcodeDemo", String.format("Symbology:%s", barcodeData.getSymbology()));
Log.i("LEADTOOLS.BarcodeDemo", String.format("Location:%1$s,%2$s,%3$s,%4$s",
barcodeData.getBounds().getX(), barcodeData.getBounds().getY(),
barcodeData.getBounds().getWidth(), barcodeData.getBounds().getHeight()));
Log.i("LEADTOOLS.BarcodeDemo", String.format("Value:%s", barcodeData.getValue()));
} else {
Log.i("LEADTOOLS.BarcodeDemo", "No barcodes found");
}

你可能感兴趣的:(LEADTOOLS,条码识别)