Skip to content

Instantly share code, notes, and snippets.

@elvismetaphor
Created July 12, 2018 16:44
Show Gist options
  • Save elvismetaphor/495b2b2b3da1286f07deeed85a2b6b4c to your computer and use it in GitHub Desktop.
Save elvismetaphor/495b2b2b3da1286f07deeed85a2b6b4c to your computer and use it in GitHub Desktop.
Add cloud text recognition (Android)
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