【发布时间】:2017-04-21 00:49:11
【问题描述】:
我目前正在开发一个 UWP 应用程序,其中一个步骤是使用相机扫描以 code39 编码的条形码。
对于我在商店中找到的其他 (UWP-) 应用程序,我的示例代码确实被正确识别为 code39 编码(因此我认为它是有效代码)。
我查看了来自microsoft uwp samples on github 的 BarcodeScanner 样本 (我还查看了最近从 github 中删除的 CameraBarcodeScanner 示例)
当我使用来自Windows.Devices.PointOfService 的BarcodeScanner 和ClaimedBarcodeScanner 类时,其他条形码(EAN8 或EAN13)会被正确识别。 (所以我假设条形码识别是这样的)
我尝试使用SetActiveSymbologiesAsync 使扫描仪能够找到code39 条码。每当我在列表中没有 BarcodeSymbologies.Ean8 的情况下调用它时,就会引发异常:
"A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)"
当我在列表中使用BarcodeSymbologies.Ean8 调用它时,将相机对准code39 条形码时,它会错误地识别出EAN8 代码。
这是我的代码:
private void OnScannerDataReceived(ClaimedBarcodeScanner sender, BarcodeScannerDataReceivedEventArgs args)
{
var dataLabel = string.Format("{0}", Encoding.UTF8.GetString(args.Report.ScanData));
var symbol = BarcodeSymbologies.GetName(args.Report.ScanDataType);
Debug.WriteLine($"LABEL: {dataLabel} | BARCODE: {symbol}.");
BarcodeReceived?.Invoke(this, dataLabel);
}
【问题讨论】:
-
能否提供您的硬件信息?我们需要一些细节供参考。
-
我已经在以下设备上试用过:* Sony Vaio VPCSB2(内置网络摄像头)* Dell XPS15(内置摄像头)* Panasonic FZ-G1(内置摄像头)* 以上所有设备均使用 Microsoft HD3000 USB-Webcam 由于没有配置可以检测到我的 code39 条形码,我认为问题与软件有关。
标签: c# .net uwp windows-10-universal barcode-scanner