我正在使用ZXing.Net从网络扫描仪生成的图像中提取条形码。
但是,ZXing有时会将文本的一部分检测为条形码。
这是一个例子:
红线是(大约)检测到的条形码(通过ResultingPoints
方法返回的DecodeMultiple
的提取)。
在此示例中,检测到以下条形码:0
,Marqueur de debut de scan
和07493835
。应该是前两个,但不是最后一个(07493835
)。
有什么办法可以解决此问题?
仅供参考,这是我叫图书馆的方式:
public static BarCodeInfo[] ScanBarCode(Bitmap source)
{
var barcodeReader = new BarcodeReader();
barcodeReader.Options.TryHarder = true;
var result = barcodeReader.DecodeMultiple(source);
if (result != null)
{
return result.Select(r =>new BarCodeInfo(r.Text, r.ResultPoints)).ToArray();
}
else
{
Debug.WriteLine("No barcode found");
return new BarCodeInfo[0];
}
}
public class BarCodeInfo
{
private string m_Text;
private ResultPoint[] m_ResultPoints;
public BarCodeInfo(string text, ResultPoint[] resultPoints)
{
this.m_Text = text;
this.m_ResultPoints = resultPoints;
}
public string Text => m_Text;
public ResultPoint[] ResultPoints => m_ResultPoints;
}
在未将TryHarder
设置为true的情况下,在我的图像(实际上是A4页面)中找不到条形码。