问题描述
我想扫描图像中的所有条形码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代码: