Hi,
I tried to get barcode from 2 images, using different RecognitionMode.
The first image (image1.png (607.4 KB)) has a barcode and the second (image2.png (461.1 KB)) has no barcode.
From second image the recognition returna some inexistent Code128 barcodes (with value % and 01).
I cannot find a configuration for RecognitionMode and ManualHints that allow me to:
- correctly returns the real barcode in the first image
- correctly returns no barcode for second image
Wich is the right configuration to obtain my goal?
Here’s my code sample:
findBarcodes("image1.png")
findBarcodes("image2.png")
Shared Sub findBarcodes(filePath As String)
Console.WriteLine("")
Console.WriteLine("File: " & filePath)
Console.WriteLine("")
Using reader As New BarCodeReader(filePath, DecodeType.Code128)
' Set RecognitionMode
reader.RecognitionMode = RecognitionMode.ManualHints
reader.ManualHints = ManualHint.None Or ManualHint.MedianSmoothing
Console.WriteLine("RecognitionMode: " & reader.RecognitionMode.ToString())
Console.WriteLine("ManualHints: " & reader.ManualHints.ToString())
While reader.Read()
Console.WriteLine(reader.GetCodeType().ToString + ": " + reader.GetCodeText())
End While
Console.WriteLine("")
End Using
Using reader As New BarCodeReader(filePath, DecodeType.Code128)
' Set RecognitionMode
reader.RecognitionMode = RecognitionMode.MaxBarCodes
Console.WriteLine("RecognitionMode: " & reader.RecognitionMode.ToString())
While reader.Read()
Console.WriteLine(reader.GetCodeType().ToString + ": " + reader.GetCodeText())
End While
Console.WriteLine("")
End Using
Using reader As New BarCodeReader(filePath, DecodeType.Code128)
' Set RecognitionMode
reader.RecognitionMode = RecognitionMode.MaxPerformance
Console.WriteLine("RecognitionMode: " & reader.RecognitionMode.ToString())
While reader.Read()
Console.WriteLine(reader.GetCodeType().ToString + ": " + reader.GetCodeText())
End While
Console.WriteLine("")
End Using
Using reader As New BarCodeReader(filePath, DecodeType.Code128)
' Set RecognitionMode
reader.RecognitionMode = RecognitionMode.MaxQuality
Console.WriteLine("RecognitionMode: " & reader.RecognitionMode.ToString())
While reader.Read()
Console.WriteLine(reader.GetCodeType().ToString + ": " + reader.GetCodeText())
End While
Console.WriteLine("")
End Using
Console.WriteLine("")
End Sub
And the result is:
File: image1.png
RecognitionMode: ManualHints
ManualHints: MedianSmoothing
RecognitionMode: MaxBarCodes
Code128: T400011561
RecognitionMode: MaxPerformance
Code128: T400011561
RecognitionMode: MaxQuality
Code128: T400011561
File: image2.png
RecognitionMode: ManualHints
ManualHints: MedianSmoothing
RecognitionMode: MaxBarCodes
Code128: 01
Code128: %
RecognitionMode: MaxPerformance
Code128: 01
RecognitionMode: MaxQuality
Code128: 01