I’m having trouble getting the Aspose Barcode Recognition engine to actually recognize any barcodes.
I’m fairly certain the barcode on the attached document is either EAN128 or Code128 but when I search for those specific types - no barcodes are found. When I search for AllSupportedTypes, a DivideByZero exception is thrown by the Aspose Barcode Recognition engine.
I’ve attached a sample document with barcode to this post and below is my code for a quick windows forms application that uses the Aspose Barcode Recognition logic.
I’ve also tried a variety of the RecognitionHints, but to no avail. Is there something I’m missing here?
Thank you for your response.
Imports Aspose.BarCodeRecognition
Imports System.Text
Public Class Form1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
‘set the BarCode license
Dim license As New Aspose.BarCode.License()
license.SetLicense(“Aspose.BarCode.lic”)
‘set the BarCodeRecognition license
Dim license2 As New Aspose.BarCodeRecognition.License()
license2.SetLicense(“Aspose.BarCode.lic”)
End Sub
Private Sub btnSelectFile_Click(sender As System.Object, e As System.EventArgs) Handles btnSelectFile.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK AndAlso Not String.IsNullOrEmpty(OpenFileDialog1.FileName) Then
txtFilename.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub btnScan_Click(sender As System.Object, e As System.EventArgs) Handles btnScan.Click
Dim reader As BarCodeReader
‘target barcode is Code128 or EAN128 types of barcode
reader = New BarCodeReader(txtFilename.Text, BarCodeReadType.AllSupportedTypes)
‘reader.SetHints(RecognitionHints.ScanStrengthHints.Strong)
’ reader.SetHints(RecognitionHints.ImageBinarizationHints.Grayscale)
’ reader.SetHints(RecognitionHints.ImageBinarizationHints.HLS)
’ reader.SetHints(RecognitionHints.ImageBinarizationHints.MedianSmoothing)
’ reader.SetHints(RecognitionHints.ThresholdHints.AutoCalculateByLine)
Dim results As New StringBuilder
Do While reader.Read()
results.AppendLine("Code Text: " & reader.GetCodeText())
results.AppendLine("Symbology Type: " & reader.GetReadType().ToString())
Loop
reader.Close()
results.AppendLine(“Done”)
txtResults.Text = results.ToString()
End Sub
End Class