微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何读取多个条形码阅读器?

如何解决如何读取多个条形码阅读器?

我想扫描图像中的所有条形码1D。 我正在使用@ zxingjs / library,我可以扫描1条条形码,但不是全部。 我如何使用Node.js? 我知道有一个带有2种方法的MUltipleBarcodeReader接口,但是我不知道如何在原型中使用它。

这是MultipleBarcodeReader

import BinaryBitmap from '../BinaryBitmap';
import DecodeHintType from '../DecodeHintType';
import Result from '../Result';
/**
 * Implementation of this interface attempt to read several barcodes from one image.
 *
 * @see com.google.zxing.Reader
 * @author Sean Owen
 */
export default interface MultipleBarcodeReader {
    /**
     * @throws NotFoundException
     */
    decodeMultiple(image: BinaryBitmap): Result[];
    /**
     * @throws NotFoundException
     */
    decodeMultiple(image: BinaryBitmap,hints: Map<DecodeHintType,any>): Result[];
}

这是我的原型:

const {MultipleBarcodeReader} = require('@zxing/library/esm/core/multi/MultipleBarcodeReader');

//I read image with fs and decode it
//hints

const multipleBarcodeReader = new MultipleBarcodeReader();
multipleBarcodeReader.setHints(hints);
const multipleResult = multipleBarcodeReader.decodeMultiple(binaryBitmap)

当我运行原型时,它给了我这个错误

const multipleBarcodeReader = new MultipleBarcodeReader();
                              ^

TypeError: MultipleBarcodeReader is not a constructor
    at Object.<anonymous> (C:\Users\awais.ahmed\Desktop\ZXing\index.js:27:31)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

谢谢

解决方法

根据此问题,无法在其github Multiple Codes in one image #346上解码多个一维条形码。该问题是新近出现的,因此请考虑对该问题做出回应,并以表情符号竖起大拇指,以表明您想要该功能。我认为您发现的TS类型表明他们计划一次实施它。

但是,您可以使用该库解码多个PDF417代码:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。