【发布时间】:2014-09-22 20:13:24
【问题描述】:
我正在使用 .NET 的 ZXing 库,但我无法从提供的图像中获得结果。
在倒数第二行之后,result 设置为 null,因为 BarcodeReader 未检测到图像中的任何条形码。
关于如何设置 BarcodeReader,我有什么遗漏吗?
BarcodeReader reader = new BarcodeReader()
{
AutoRotate = true,
TryInverted = true,
Options = new DecodingOptions
{
TryHarder = true,
PureBarcode = true,
PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.CODE_39 }
}
};
LuminanceSource source = new ZXing.BitmapLuminanceSource(bitmapImage);
Result result = reader.Decode(source);
Console.WriteLine(result == null ? "Nothing" : result.Text);
【问题讨论】:
-
您是否已逐步查看结果的值被设置为什么或何时收到错误?
-
@developerIntern53718 我已经通过了,它没有给我任何异常,唯一的“错误”是在图像中没有检测到条形码。在倒数第二行之后,
result为空。 -
嗯,那就是错误......您是否尝试了多个条形码来排除条形码本身的问题?
-
我建议尝试使用计算机生成的条形码图像,而不是扫描。可能只是图像质量。
-
@Blorgbeard 第二张图片效果很好。从网站生成。有没有办法在 ZXing 中对图像进行二值化?也许这会帮助它在扫描的文档中找到条形码。