public bool EnableReturnFourPoints { get; set; }
EnableReturnFourPoints # get and set (BarcodeReader)
true to enable return of four corners. Otherwise, false. The default value is false.
When calling ReadBarcode or ReadBarcodes with the EnableReturnFourPoints property set to true, BarcodeData.Bounds member will be updated with the coordinates of the four corners of the barcode rather than the coordinates of the bounding rectangle. These coordinates are encoded values and must be decoded before they can be used. The following example shows how to decode the four-point corner values:
// Code goes here
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.Common;
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];
Point[] fourPoints = new Point[4];
fourPoints[0].X = ((int)barcode.Bounds.Left & 0xffff); fourPoints[0].Y = ((int)barcode.Bounds.Left >> 16);
fourPoints[1].X = ((int)barcode.Bounds.Top & 0xffff); fourPoints[1].Y = ((int)barcode.Bounds.Top >> 16);
fourPoints[2].X = ((int)barcode.Bounds.Width & 0xffff); fourPoints[2].Y = ((int)barcode.Bounds.Width >> 16);
fourPoints[3].X = ((int)barcode.Bounds.Height & 0xffff); fourPoints[3].Y = ((int)barcode.Bounds.Height >> 16);
Console.WriteLine(" {0} - {1} - {2}", i + 1, barcode.Symbology, barcode.Value);
for(int j = 1; j <=4; j++)
{
Console.WriteLine("Corner #{0} (x,y) : {1},{2} ", j, fourPoints[j].X, fourPoints[j].Y);
}
}
Console.WriteLine("-----------------");
}
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document