markusfisch / BinaryEye

Yet another barcode scanner for Android
https://play.google.com/store/apps/details?id=de.markusfisch.android.binaryeye
MIT License
1.52k stars 121 forks source link

MaxiCode support? #77

Open ravilov opened 5 years ago

ravilov commented 5 years ago

ZXing lib claims to support MaxiCode (yes, the weird UPS thing), however I can't seem to get BinaryEye to scan any that I tried. Is that a limitation of BE or ZX or something else?

Using BinaryEye 1.15.0 from F-Droid.

markusfisch commented 5 years ago

Good question. All the samples are failing for me too. My first guess is there's something wrong with ZXing because Binary Eye just gives an image to ZXing. On the other hand, ZXing has tests for MaxiCode 🤔

markusfisch commented 4 years ago

Well, finally found out that ZXing (in version 3.3.3, the last version we can use for Android apps that should run below Android 7.0 Nougat, see here) can only read MaxiCodes if it's in PURE_BARCODE mode.

PURE_BARCODE means the barcode is expected to be unrotated and not skewed in the input image. Of course, this isn't usually true for a camera frame.

From MaxiCodeReader.java:

  @Override
  public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
      throws NotFoundException, ChecksumException, FormatException {
    DecoderResult decoderResult;
    if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
      BitMatrix bits = extractPureBits(image.getBlackMatrix());
      decoderResult = decoder.decode(bits, hints);
    } else {
      throw NotFoundException.getNotFoundInstance();
    }
    ....

Unfortunately, the docs are silent on this 😞

Now, I've did a couple of tests and indeed could read a couple of MaxiCodes when PURE_BARCODE is set. Of course, setting PURE_BARCODE makes reading other barcodes much worse (like QR Codes and DataMatrix and probably others as well) 😬

So the only solution I see would be to have a special MaxiCode Reader "mode", which would be rather ugly, of course.

Alternatively, it would also be possible to scan every other frame with PURE_BARCODE set but that also would make performance for all other codes a bit worse 🤔

ravilov commented 4 years ago

Thank you for the reply. At least now we know what's going on! I agree having an option to switch "modes" sounds ugly. What do you think about doing a second pass on the same image data with the said PURE_BARCODE option set in case the first (normal) pass finds nothing? Or would that slow down the scanning too much?

markusfisch commented 4 years ago

Unfortunately, yes, doing an extra pass would slow down scanning. Especially on low end devices. So I rather wouldn't do it by default.

ravilov commented 4 years ago

Not by default, but I feel here's where a checkbox setting would come in handy. Switch between faster but less broad and slower but with more codes supported.

aleksandrs-ledovskis commented 1 year ago

Could the PURE_BARCODE be auto-enabled when "Restrict format" is set to MAXICODE?