如何读取多个条码reader?
How to read multiple barcode reader?
我想扫描图像中的所有一维条形码。
我正在使用@zxingjs/library,我可以扫描 1 个条形码但不是全部。
我如何用 nodejs 做到这一点?
我知道有一个接口 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 代码:
我想扫描图像中的所有一维条形码。 我正在使用@zxingjs/library,我可以扫描 1 个条形码但不是全部。 我如何用 nodejs 做到这一点? 我知道有一个接口 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 代码: