Created
July 12, 2018 16:42
-
-
Save elvismetaphor/d3cb255d6aea01494bc5f2f1bf796d99 to your computer and use it in GitHub Desktop.
Add on-device text recognition (Android)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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