Closed 1PV1 closed 1 year ago
I'm using canvas to crop the image so it has only the barcode, I tryed with the code from https://github.com/zxing-js/library#readme but I'm getting NotFoundException: No MultiFormat Readers were able to detect the code.
NotFoundException: No MultiFormat Readers were able to detect the code.
Code:
const cropedcanvas = createCanvas(384, 99); const cropedctx = cropedcanvas.getContext('2d'); cropedctx.drawImage(canvas, 0, 312, 384, 99, 0, 0, 384, 99); const hints = new Map(); hints.set(DecodeHintType.POSSIBLE_FORMATS, [BarcodeFormat.CODE_128]); const reader = new MultiFormatReader(); const luminanceSource = new RGBLuminanceSource(new Uint8ClampedArray(cropedcanvas.toBuffer()), cropedcanvas.width, cropedcanvas.height); const binaryBitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource)); const code = reader.decode(binaryBitmap, hints); console.log(code)
Image:
I'm using canvas to crop the image so it has only the barcode, I tryed with the code from https://github.com/zxing-js/library#readme but I'm getting
NotFoundException: No MultiFormat Readers were able to detect the code.
Code:
Image: