So i followed googles tutorial for their barcode scanner (this one) and the qr scanning works like a charm. The only problem is that i don't need qr codes but rather bar codes. But they don't work. It doesn't detect anything. I tried multiple online bar codes and ones from around the house but none got recognised as a barcode.
this is the code in my activity that handles the image and scanner:
public void btnClick(View v) {
Intent imageTakeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(imageTakeIntent.resolveActivity(getPackageManager())!=null){
startActivityForResult(imageTakeIntent, 101);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==101 && resultCode==RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(imageBitmap);
image = InputImage.fromBitmap(imageBitmap, 0);
barCodeScanning();
}
}
public void barCodeScanning(){
BarcodeScannerOptions options =
new BarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_CODE_128,
Barcode.FORMAT_CODE_93,
Barcode.FORMAT_CODE_93,
Barcode.FORMAT_CODABAR,
Barcode.FORMAT_EAN_13,
Barcode.FORMAT_EAN_8,
Barcode.FORMAT_ITF,
Barcode.FORMAT_UPC_A,
Barcode.FORMAT_UPC_E,
Barcode.FORMAT_PDF417,
Barcode.FORMAT_DATA_MATRIX,
Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_AZTEC)
.build();
BarcodeScanner scanner = BarcodeScanning.getClient();
Task<List<Barcode>> result = scanner.process(image)
.addOnSuccessListener(new OnSuccessListener<List<Barcode>>() {
@Override
public void onSuccess(List<Barcode> barcodes) {
System.out.println(barcodes.size());
for (Barcode barcode: barcodes) {
Rect bounds = barcode.getBoundingBox();
Point[] corners = barcode.getCornerPoints();
String rawValue = barcode.getRawValue();
System.out.println(rawValue);
int valueType = barcode.getValueType();
System.out.println(valueType);
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
e.printStackTrace();
}
});
}
The console looks fine to me except the line E/libc: Access denied finding property "ro.hardware.chipname"
which is marked red but didn't turn up any helpful results on google.
This is the complete console output:
02/26 18:29:10: Launching 'app' on HMD Global Nokia 5.3.
Install successfully finished in 2 s 230 ms.
$ adb shell am start -n "com.project.kuecheninventar/com.project.kuecheninventar.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 28314 on device 'hmd_global-nokia_5_3-N0AA003687KA2700363'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/Perf: Connecting to perf service.
W/kuecheninventa: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
I/AdrenoGLES: QUALCOMM build : cfd6c90, Id60e6598a1
Build Date : 01/27/20
OpenGL ES Shader Compiler Version: EV031.27.05.03
Local Branch : mybranchea40f85b-21cb-f1fb-b0c0-5cb90179c3e0
Remote Branch : quic/gfx-adreno.lnx.1.0.r91-rel
Remote Branch : NONE
Reconstruct Branch : NOTHING
Build Config : S P 8.0.12 AArch64
I/AdrenoGLES: PFP: 0x016ee187, ME: 0x00000000
W/Gralloc3: mapper 3.x is not supported
D/TransportRuntime.JobInfoScheduler: Scheduling upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) with jobId=-1883559869 in 86400000ms(Backend next call timestamp 0). Attempt 1
I/DynamiteModule: Considering local module com.google.mlkit.dynamite.barcode:10000 and remote module com.google.mlkit.dynamite.barcode:0
Selected local version of com.google.mlkit.dynamite.barcode
I/tflite: Initialized TensorFlow Lite runtime.
I/native: barcode_detector_client.cc:239 Not using NNAPI
E/libc: Access denied finding property "ro.hardware.chipname"
D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
I/System.out: 0
D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
D/TransportRuntime.SQLiteEventStore: Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler: Upload for context TransportContext(cct, VERY_LOW, MSRodHRwczovL2ZpcmViYXNlbG9nZ2luZy5nb29nbGVhcGlzLmNvbS92MGNjL2xvZy9iYXRjaD9mb3JtYXQ9anNvbl9wcm90bzNc) is already scheduled. Returning...
The line System.out.println(barcodes.size());
just prints 0 which means the barcode list is empty. Did i do something wrong or why does the qr code regognize but no bar code?