googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

No barcode scanning on Samsung Galaxy Tab2 - Android 4.4.2 #140

Open mayuricmarix opened 8 years ago

mayuricmarix commented 8 years ago

No Barcode scanning on: Galaxy Tab 2 - (but working on MI and Moto)

On some phones (e.g. Galaxy Tab 2), it didn't detect barcode .

alexzaitsev commented 8 years ago

Affirmative. Doesn't detect on 4.1.2 devices: Samsung Galaxy Young Duos GT-S6312 - 2023, Samsung S3 Mini (GT-I8190) - 2088, Sony XPERIA P - 2015 as well. Vision versions tested: 9.2.0, 9.4.0

pchx-zz commented 8 years ago

Does adb logcat return anything interesting when you attempt to use the Barcode API?

Specifically, any messages with the "Vision" tag, like: Vision: Supported ABIS: [...]

alexzaitsev commented 8 years ago

@pchx As side effect the preview is slightly stretched on these devices. I investigated how it works on these devices and I discovered that it actually scans but not all QR codes.

I have 2 QR codes. This one is original QR code This one is original QR code. And this is the same but generated with [http://www.qr-code-generator.com/](this generator) (Text -> "EAAAAAZGXSV98XJMOijICTUjAg5%2FfPwYnrgtQ%2BrBtO%2Ba9M9TCdDD8GQ38cFaxZyVOdXSxw%3D%3D||ST1477" without quotes). generated one.

Both of them are successfully recognized on Nexus 5 and other high end devices. format: 256 displayValue:EAAAAAZGXSV98XJMOijICTUjAg5%2FfPwYnrgtQ%2BrBtO%2Ba9M9TCdDD8GQ38cFaxZyVOdXSxw%3D%3D||ST1477

But on the devices listed above it doesn't recognize the original qrcode but recognizes the generated one. I see that they differ however I cannot instantiate what's the difference because Nexus 5 shows that they have the same format (256).

Also I logged this method to be sure that it's called.

@Override
            public void receiveDetections(Detector.Detections<Barcode> detections) {
                final SparseArray<Barcode> barcodes = detections.getDetectedItems();
                Log.d("qrcode", "detector is operational: " + detections.detectorIsOperational());
                Log.d("qrcode", "metadata: " + (detections.getFrameMetadata() == null ? "null" :
                        (detections.getFrameMetadata().getId() +  " " + detections.getFrameMetadata().getFormat()+
                        " " + detections.getFrameMetadata().getWidth() +
                        "x" + detections.getFrameMetadata().getHeight())));
                if (barcodes.size() != 0) {
                    Log.d("qrcode", "barcodes size: " + barcodes.size());

I'm able to see the logs on the devices where the original qr code cannot be scanned:

11-01 10:48:50.121 12702-13233/com.talk D/qrcode: detector is operational: true
11-01 10:48:50.121 12702-13233/com.talk D/qrcode: metadata: 263 -1 240x320

however barcodes.size() is 0.

And if I scan generated one:

11-01 11:23:31.159 28282-31184/com.talk D/qrcode: detector is operational: true
11-01 11:23:31.159 28282-31184/com.talk D/qrcode: metadata: 394 -1 720x960
11-01 11:23:31.159 28282-31184/com.talk D/qrcode: barcodes size: 1
11-01 11:23:31.710 28282-28282/com.talk D/qrcode: format: 256 value:EAAAAAZGXSV98XJMOijICTUjAg5%2FfPwYnrgtQ%2BrBtO%2Ba9M9TCdDD8GQ38cFaxZyVOdXSxw%3D%3D||ST1477

It's definitely the library problem because the same code recognized correctly on the Nexus 5. Please give me some advice what to do. Also please note the existing of the stretch effect.

pchx-zz commented 8 years ago

The preview frames returned by the Nexus 5 are 720x960 (691200 px^2) while the other device you tested on only returns 240x320 (76800 px^2). In other words, the Nexus 5 gives us 9x the number of pixels -- this doesn't make a difference on a clean image (such as the version you generated), but it does when the QR code is printed on a small receipt.

Basically, the Barcode API requires a higher resolution image to properly read QR codes that are of low quality or are damaged.

alexzaitsev commented 8 years ago

@pchx in this way we should have some error callback which is called in such situation. It's better to show at least error message to user than not to react for his actions at all. If it's possibly to detect such situation of course. Thank you for explanation.

pchx-zz commented 8 years ago

In this case, the QR code probably wasn't detected at all. It's very unlikely that an error callback would provide any useful information in such a situation.

alexzaitsev commented 8 years ago

Yes, it's an actual behavior. But it's confusing. On high-end devices it recognises QR code as expected but on low-end ones it doesn't work. I see that it's really hard to do anything with this.