Alex Martian
Alex Martian

Reputation: 3812

Barcode decoding rotated codes - how to use zxing for Android

I want my app to scan barcodes and found zxing (https://github.com/zxing/zxing) as best open source library for it. If I use it standard intent way, it only detects and decodes when code is aligned with blinking guideline.

However, in java code it says e.g. in https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/pdf417/detector/Detector.java

"Encapsulates logic that can detect a PDF417 Code in an image, even if the * PDF417 Code is rotated or skewed, or partially obscured."

"@param multiple if true, then the image is searched for multiple codes."

So I guess Zxing library can be used to scan rotated images and decode multiple barcodes from one page. How to do that?

Upvotes: 1

Views: 3405

Answers (2)

shimon smilowitz
shimon smilowitz

Reputation: 1

in order to read the barcode in any orientation, you need to add to your code

    Hashtable<DecodeHintType, Object> decodeHints = new Hashtable<DecodeHintType, Object>();
        decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
    Result result = new UPCAReader().decode(bitmap, decodeHints);

Upvotes: 0

ilyamuromets
ilyamuromets

Reputation: 413

Use Barcode Scanner API in Google Play services:
https://android-developers.googleblog.com/2015/08/barcode-detection-in-google-play.html

Upvotes: 1

Related Questions