I want to scan all barcode 1D in an image. I'm using @zxingjs/library, i can scan 1 barcode but not all. How i can do it with nodejs? I know that there is an interface MUltipleBarcodeReader with 2 methods, but I don't know how to use it in my prototype.
This is 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[];
}
This is my prototype:
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)
When I run my prototype, it gaves me this errors:
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
Thanks
It is not possible to decode multiple 1D barcodes according to this issue on their github Multiple Codes in one image #346. That issue is recent, so consider reacting there in that issue with a thumbs up emoji to show you want that feature. That TS type you found I think is a sign that they planned to implement it at one point.
However, you can decode multiple PDF417 codes using that library: