【问题标题】:Barcode of format CODE_128 is scanning incorrectly via @zxing/ngx-scannerCODE_128 格式的条码通过@zxing/ngx-scanner 扫描不正确
【发布时间】:2020-04-29 09:14:10
【问题描述】:

我正在使用@zxing/ngx-scanner 扫描条形码。我可以使用笔记本电脑的摄像头扫描 QR_CODE 和 DATA_MATRIX 格式的条形码。我现在想扫描 CODE_128 格式的条码。但是图书馆需要时间来扫描,当它扫描时......它扫描不正确。

有没有人遇到过类似的问题?我该如何解决这个问题?

我正在使用 Angular 7 和 ngx-scanner 版本 2.0.1。 我正在 Windows 10 上的 Chrome 浏览器中尝试。

代码:

In HTML:
<zxing-scanner #scanner start="true" (scanSuccess)="myFn($event)" [formats]="['QR_CODE', 'EAN_13', 'CODE_128', 'DATA_MATRIX']"></zxing-scanner>
In ts:
import { ZXingScannerComponent } from '@zxing/ngx-scanner';

export class myClass implements OnInit {
 @ViewChild('scanner') scanner: ZXingScannerComponent;
 hasDevices: boolean = false;
 hasPermission: boolean;
 availableDevices: MediaDeviceInfo[] = [];
 currentDevice: MediaDeviceInfo;

 constructor(private zone: NgZone) {
  window['angularComponentReference'] = {
    zone: this.zone,
    componentFn: (searchcontent: any) =>
      window['scannerOutput'](searchcontent),
      component: this,
  };
 }

 ngOnInit() {
  this.scanner.camerasFound.subscribe((devices: MediaDeviceInfo[]) => {
     this.hasDevices = true;
     this.availableDevices = devices;
  });
  this.scanner.camerasNotFound.subscribe(() => {
     this.hasDevices = false;
  });
  this.scanner.scanComplete.subscribe((result: Result) => {
     this.qrResult = result;
     this.hasPermission = false;
  });
  this.scanner.permissionResponse.subscribe((perm: boolean) => {
    this.hasPermission = perm;
  });
 }

 myFn(resultString) {
   console.log(resultString);
 }

}

更新: 我需要扫描的条形码样本

【问题讨论】:

  • 您确定它是 CODE_128 条码吗?一维条码有多种类型。
  • @ChrisBD 不能 100% 确定.. 但收到的样本似乎是 CODE_128... 附上我需要扫描的样本条码。

标签: angular angular7 zxing barcode-scanner


【解决方案1】:

问题已解决。对于一维条码,我们需要水平握住条码才能正确扫描。

有关更多信息,我已经为相同的问题创建了 github 问题:https://github.com/zxing-js/ngx-scanner/issues/296

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    相关资源
    最近更新 更多