Created
July 12, 2018 16:44
-
-
Save elvismetaphor/495b2b2b3da1286f07deeed85a2b6b4c to your computer and use it in GitHub Desktop.
Add cloud 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 runCloudTextRecognition(Bitmap selectedImage) { | |
FirebaseVisionCloudDetectorOptions options = new FirebaseVisionCloudDetectorOptions.Builder() | |
.setModelType(FirebaseVisionCloudDetectorOptions.LATEST_MODEL) | |
.setMaxResults(15) | |
.build(); | |
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(selectedImage); | |
FirebaseVisionCloudDocumentTextDetector detector = FirebaseVision.getInstance() | |
.getVisionCloudDocumentTextDetector(options); | |
detector.detectInImage(image) | |
.addOnSuccessListener(new OnSuccessListener<FirebaseVisionCloudText>() { | |
@Override | |
public void onSuccess(FirebaseVisionCloudText text) { | |
processCloudTextRecognitionResult(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