library icon indicating copy to clipboard operation
library copied to clipboard

Unable to scan PDF_417 codes...

Open rlyle opened this issue 2 years ago • 17 comments

Hi, trying to scan the back of a drivers license, the picture is certainly clear and large enough, but it does nothing but dump this error into the logs...

index.js:1 deocdeFromVideoDevice error: ChecksumException at ChecksumException.getChecksumInstance (http://localhost:3000/static/js/vendors~main.chunk.js:91679:12) at PDF417ScanningDecoder.createDecoderResultFromAmbiguousValues (http://localhost:3000/static/js/vendors~main.chunk.js:116280:70) at PDF417ScanningDecoder.createDecoderResult (http://localhost:3000/static/js/vendors~main.chunk.js:116219:34) at PDF417ScanningDecoder.decode (http://localhost:3000/static/js/vendors~main.chunk.js:115963:34) at PDF417Reader.decode (http://localhost:3000/static/js/vendors~main.chunk.js:112829:100) at PDF417Reader.decode (http://localhost:3000/static/js/vendors~main.chunk.js:112776:31) at BrowserCodeReader.decodeBitmap (http://localhost:3000/static/js/vendors~main.chunk.js:86999:24) at BrowserCodeReader.decodeFromCanvas (http://localhost:3000/static/js/vendors~main.chunk.js:87008:17) at loop (http://localhost:3000/static/js/vendors~main.chunk.js:87775:28)

I've been trying for hours to scan a PDF_417 off the back of my license, I don't think it's a blurry image or anything like that, just simply think something is wrong with the checksum calculations for this bar code format.

Can anyone else scan a PDF_417 with this library?

rlyle avatar Jul 13 '22 20:07 rlyle

P.S. none of the sample PDF_417 in the live demo are working either..

image

rlyle avatar Jul 13 '22 20:07 rlyle

P.S. I did see this other type of error pop up as well, while trying to scan..

index.js:1 deocdeFromVideoDevice error: NotFoundException at NotFoundException.getNotFoundInstance (http://localhost:3000/static/js/vendors~main.chunk.js:93051:12) at PDF417ScanningDecoder.adjustCodewordCount (http://localhost:3000/static/js/vendors~main.chunk.js:116158:74) at PDF417ScanningDecoder.createDecoderResult (http://localhost:3000/static/js/vendors~main.chunk.js:116179:27) at PDF417ScanningDecoder.decode (http://localhost:3000/static/js/vendors~main.chunk.js:115963:34) at PDF417Reader.decode (http://localhost:3000/static/js/vendors~main.chunk.js:112829:100) at PDF417Reader.decode (http://localhost:3000/static/js/vendors~main.chunk.js:112776:31) at BrowserCodeReader.decodeBitmap (http://localhost:3000/static/js/vendors~main.chunk.js:86999:24) at BrowserCodeReader.decodeFromCanvas (http://localhost:3000/static/js/vendors~main.chunk.js:87008:17) at loop (http://localhost:3000/static/js/vendors~main.chunk.js:87775:28)

rlyle avatar Jul 13 '22 20:07 rlyle

I have the same issue.

I would also like to use this PDF417 scan via the camera and not just an image. Is this possible?

Thank you so much for a great library!

ozzmaster avatar Jul 29 '22 12:07 ozzmaster

The PDF417 bar code scanner is working, but another bar code I am trying to scan is encrypted. Is it possible to retrieve the raw data from the scan, instead of letting zxing decode the data to JSON? I have a different library that can decrypt the data.

ozzmaster avatar Aug 08 '22 07:08 ozzmaster

I have the same problem. I made it work unencrypted with this code:

const fs     = require('fs');
const jpeg    = require('jpeg-js');
const { MultiFormatReader, BarcodeFormat, RGBLuminanceSource, BinaryBitmap, HybridBinarizer, DecodeHintType, PDF417Reader } = require('@zxing/library');

async function ServiceTest(req, res) {

  var path = '{your file's path}/test01.png';
  
  let pathData = await fs.readFileSync(path);
  let decoded;

  let rawImageData = await jpeg.decode(pathData) ;
  
  const hints = new Map();
  const formats = [BarcodeFormat.PDF_417];
  hints.set(DecodeHintType.POSSIBLE_FORMATS, formats);
  hints.set(DecodeHintType.TRY_HARDER, true);
  hints.set(DecodeHintType.PURE_BARCODE, true);
  hints.set(DecodeHintType.PURE_BARCODE, true);
  const reader = new PDF417Reader(hints);

  const len = rawImageData.width * rawImageData.height

  const luminancesUint8Array = new Uint8ClampedArray(len);

  for (let i = 0; i < len; i++) {
    luminancesUint8Array[i] = ((rawImageData.data[i * 4] + rawImageData.data[i * 4 + 1] * 2 + rawImageData.data[i * 4 + 2]) / 4) & 0xff;
  }

  const luminanceSource = new RGBLuminanceSource(luminancesUint8Array, rawImageData.width, rawImageData.height);
  const binaryBitmap    = new BinaryBitmap(new HybridBinarizer(luminanceSource));
  
  const detection = reader.decode(binaryBitmap);
  
  console.log(detection.getText());
  console.log(detection.getBarcodeFormat());
  console.log(detection.putAllMetadata());
}

However, when I try to read an encrypted PDF417, I get some errors.

If i use "PDF417Reader": image

If i use "MultiFormatReader": image

Did you find a solution?

bea314 avatar Sep 01 '22 22:09 bea314

@rlyle - Were you ever able to get the back of drivers license scan working?

I have the same use case and am getting the same error. I've tried all the way up to 600dpi quality scan in both black and white and color using the ZXing.BrowserPDF417Reader or the ZXing.MultiFormatReader

WhatTheChad avatar Sep 29 '22 20:09 WhatTheChad

I was having the same issue and this suggested workaround got me going.

drborges avatar Mar 10 '23 22:03 drborges

@rlyle - Were you ever able to get the back of drivers license scan working?

I have the same use case and am getting the same error. I've tried all the way up to 600dpi quality scan in both black and white and color using the ZXing.BrowserPDF417Reader or the ZXing.MultiFormatReader

Nope, we just gave up on supporting PC scanning.. which was ok for us, as our primary users are on iOS and android.

rlyle avatar Mar 10 '23 22:03 rlyle

For me the reason it was not working was that I was passing a UInt8ClampedArray. Apparently, it only works with Int32Array so the workaround was doing new Int32Array(clampedArray.buffer)

matias-facenote avatar May 10 '23 13:05 matias-facenote

Stale issue message

github-actions[bot] avatar Apr 29 '24 10:04 github-actions[bot]