use of com.google.mlkit.vision.barcode.BarcodeScanner in project react-native-camera by lwansbrough.
the class BarcodeDetectorAsyncTask method doInBackground.
@Override
protected Void doInBackground(Void... ignored) {
if (isCancelled() || mDelegate == null || mBarcodeDetector == null) {
return null;
}
InputImage image = InputImage.fromByteArray(mImageData, mWidth, mHeight, getFirebaseRotation(), InputImage.IMAGE_FORMAT_YV12);
BarcodeScanner barcode = mBarcodeDetector.getDetector();
barcode.process(image).addOnSuccessListener(new OnSuccessListener<List<Barcode>>() {
@Override
public void onSuccess(List<Barcode> barcodes) {
WritableArray serializedBarcodes = serializeEventData(barcodes);
mDelegate.onBarcodesDetected(serializedBarcodes, mWidth, mHeight, mImageData);
mDelegate.onBarcodeDetectingTaskCompleted();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e(TAG, "Text recognition task failed" + e);
mDelegate.onBarcodeDetectingTaskCompleted();
}
});
return null;
}
Aggregations