Skip to content

Instantly share code, notes, and snippets.

@elvismetaphor
Created July 12, 2018 16:42
Show Gist options
  • Save elvismetaphor/d3cb255d6aea01494bc5f2f1bf796d99 to your computer and use it in GitHub Desktop.
Save elvismetaphor/d3cb255d6aea01494bc5f2f1bf796d99 to your computer and use it in GitHub Desktop.
Add on-device text recognition (Android)
public void runTextRecognition(Bitmap selectedImage) {
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage);
FirebaseVisionTextDetector detector = FirebaseVision.getInstance().getVisionTextDetector();
detector.detectInImage(image)
.addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
@Override
public void onSuccess(FirebaseVisionText text) {
processTextRecognitionResult(text);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
e.printStackTrace();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment