[C#]
// read code39 barcode from image
string image = "code39Extended.jpg";
BarCodeReader reader = new BarCodeReader(image, BarCodeReadType.Code39Standard);
// try to recognize all possible barcodes in the image
while (reader.Read()) {
// get the region information
BarCodeRegion region = reader.GetRegion();
if (region != null)
{
// display x and y coordinates of barcode detected
System.Drawing.Point[] point = region.Points;
Console.WriteLine("Top left coordinates: X = " + point[0].X + ", Y = " + point[0].Y);
Console.WriteLine("Bottom left coordinates: X = " + point[1].X + ", Y = " + point[1].Y);
Console.WriteLine("Bottom right coordinates: X = " + point[2].X + ", Y = " + point[2].Y);
Console.WriteLine("Top right coordinates: X = " + point[3].X + ", Y = " + point[3].Y);
}
Console.WriteLine("Codetext: " + reader.GetCodeText());
}
// close reader
reader.Close();
[VB.NET]
' read code39 barcode from image
Dim image As String = "code39Extended.jpg"
Dim reader As New BarCodeReader(image, BarCodeReadType.Code39Standard)
' try to recognize all possible barcodes in the image
While reader.Read()
' get the region information
Dim region As BarCodeRegion = reader.GetRegion()
If region IsNot Nothing Then
' display x and y coordinates of barcode detected
Dim point As System.Drawing.Point() = region.Points
Console.WriteLine("Top left coordinates: X = " & point(0).X & ", Y = " & point(0).Y)
Console.WriteLine("Bottom left coordinates: X = " & point(1).X & ", Y = " & point(1).Y)
Console.WriteLine("Bottom right coordinates: X = " & point(2).X & ", Y = " & point(2).Y)
Console.WriteLine("Top right coordinates: X = " & point(3).X & ", Y = " & point(3).Y)
End If
Console.WriteLine("Codetext: " & reader.GetCodeText())
End While
' close reader
reader.Close()