格式 CODE_128 的条形码通过 @zxing/ngx-scanner 扫描不正确
Barcode of format CODE_128 is scanning incorrectly via @zxing/ngx-scanner
我正在使用 @zxing/ngx-scanner 扫描条形码。我可以使用我的笔记本电脑相机扫描 QR_CODE 和 DATA_MATRIX 格式的条形码。我现在想扫描 CODE_128 格式的条码。但是图书馆需要时间来扫描,当它扫描时……它扫描不正确。
有没有人遇到过类似的问题?我该如何解决这个问题?
我正在使用 Angular 7 和 ngx-scanner 2.0.1 版。
我正在 Chrome 浏览器中尝试 Windows 10。
代码:
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);
}
}
更新:
我需要扫描的条码样本
问题已解决。对于一维条码,我们需要水平握住条码才能正确扫描。
有关更多信息,我已经创建了 github 问题:https://github.com/zxing-js/ngx-scanner/issues/296
我正在使用 @zxing/ngx-scanner 扫描条形码。我可以使用我的笔记本电脑相机扫描 QR_CODE 和 DATA_MATRIX 格式的条形码。我现在想扫描 CODE_128 格式的条码。但是图书馆需要时间来扫描,当它扫描时……它扫描不正确。
有没有人遇到过类似的问题?我该如何解决这个问题?
我正在使用 Angular 7 和 ngx-scanner 2.0.1 版。 我正在 Chrome 浏览器中尝试 Windows 10。
代码:
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);
}
}
更新:
我需要扫描的条码样本
问题已解决。对于一维条码,我们需要水平握住条码才能正确扫描。
有关更多信息,我已经创建了 github 问题:https://github.com/zxing-js/ngx-scanner/issues/296