Reputation: 491
I am using Vision api for detecting QR codes. It works well on a samsung device but not on LG device. Both devices are running on version 6.0.1 and there's no error as well. Any advice?
Upvotes: 1
Views: 1229
Reputation: 845
I faced this same issue that QR not detected on Redmi and Infinix devices, here is my solution:
Zxing Library Version
implementation 'com.google.zxing:core:3.4.0'
Just pass your Bitmap in this function and this will return the string value:
public static String getQRDataFromBitmap(Bitmap bitmap) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
Reader reader = new MultiFormatReader();
try {
Result result = reader.decode(new BinaryBitmap(new HybridBinarizer(source)));
return result.getText();
} catch (NotFoundException e) {
e.printStackTrace();
return null;
} catch (ChecksumException e) {
e.printStackTrace();
return null;
} catch (FormatException e) {
e.printStackTrace();
return null;
}
}
Upvotes: 0
Reputation: 4021
Here some sample of Zxing-Library and Vision API hope it will help you.
The sample projects base on Zxing-Library
While Vision API for QR Bar Code try this
Upvotes: 1