CamView icon indicating copy to clipboard operation
CamView copied to clipboard

Set ScannerLiveView to Only Responds to QR Code

Open Jayvd opened this issue 9 years ago • 6 comments

Hello, thanks for providing this CRAZY SIMPLE libray!!!

I have a little problem though.

  1. How do you detect only QR Codes? I tried to scan other type of barcodes and the App BEEP. How do I make it to beep or responds only when a QR Code is scanned??

  2. What is the purpose of setScanAreaPercent? (I am sorry for these newbie question)

    ZXDecoder decoder=new ZXDecoder();
    decoder.setScanAreaPercent(0.5);
    scannerLiveView = (ScannerLiveView) findViewById(R.id.scannerLiveView);
    scannerLiveView.setDecoder(decoder);
    
  3. How do we make the Camera preview to square? I am tried to set it to square but the preview ended up distorted.

And thanks again for providing this great library for everyone!!!!

Jayvd avatar Feb 16 '16 10:02 Jayvd

Hi ! Detectable codes management is a planned feature for the ScannerLiveView. Sadly I was very busy past weeks, but I hope to complete and push the outstanding issues for the new release during the coming weekend, so this one should be added too.

Will post here more info once it ready

livotov avatar Feb 17 '16 08:02 livotov

@livotov I ended up creating a new custom decoder class derived from ZXDecoder and set the POSSIBLE_FORMATS to QR_CODE only.

Thank you for responding!!

Jayvd avatar Feb 17 '16 14:02 Jayvd

@Jayvd I'm just having the same issue. Do you have a short sample how you did setup ZXDecoder?

hohl avatar Feb 23 '16 15:02 hohl

@Jayvd Hi. Could you show us how to set the possible formats to QR code only? Please. That would be a big help for me! Thanks!

GermanMontejo avatar Mar 31 '16 10:03 GermanMontejo

@GermanMontejo @hohl @livotov

What I did was, I copied the ZXDecoder.java file and name it something else. In this case I named it CustomDecoder Change the constructor content of the ZXDecoder

Original ZXDecoder.java constructor

public ZXDecoder()
{
    reader = new MultiFormatReader();

    hints.put(DecodeHintType.POSSIBLE_FORMATS, EnumSet.allOf(BarcodeFormat.class));
    hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
    hints.put(DecodeHintType.TRY_HARDER, true);

    reader.setHints(hints);
}

_ Modified class _

  public CustomDecoder()
{
    reader = new MultiFormatReader();

    Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
    Collection<BarcodeFormat> decodeFormats = EnumSet.of(BarcodeFormat.QR_CODE);
    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

    hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
    hints.put(DecodeHintType.TRY_HARDER, true);

    reader.setHints(hints);
}

Jayvd avatar Mar 31 '16 10:03 Jayvd

it should have an option that exposes as an API from decode to set decoding type.

jjhesk avatar May 14 '16 14:05 jjhesk