我正在尝试使用 ZXing .Net 解码从相机拍摄的图像中的条形码,但它不适用于我尝试的任何图像。
这是我目前正在使用的代码:
protected void ReadBarcodeZXing(string imagePath)
{
BarcodeReader reader = new BarcodeReader()
{
Options =
{
TryHarder = true,
ReturnCodabarStartEnd = false,
PureBarcode = false
}
};
Bitmap barcodeBitmap = (Bitmap)Bitmap.FromFile(imagePath);
var result = reader.Decode(barcodeBitmap);
if (result != null)
lblResult.Text = result.BarcodeFormat.ToString() + "<br />" + result.Text;
else
lblResult.Text = "No barcodes found in image";
barcodeBitmap.Dispose();
}
我尝试过将 AutoRotate 和 TryInverted 设置为 true,并且尝试过使用 PossibleFormats。
以下是我尝试解码的一些条形码图像:
2:https ://imgur.com/bNKzh73 (#1特写)
5:https ://imgur.com/e8JbpmV (#4特写)
#6 和 #7 是GitHub 项目上提供的示例图像。有更多的样本不起作用,但其中许多确实起作用。
谁能帮我让它正常工作?或者帮助我理解为什么它不适用于我自己的图像?