Closed dllz closed 3 years ago
oh shoot
Any updates on this issue ?
@Nilesh8451 You can use detectFromUri
with file paths. See the below extract from the ML Kit docs.
To create an InputImage object from a file URI, pass the app context and file URI to InputImage.fromFilePath(). This is useful when you use an ACTION_GET_CONTENT intent to prompt the user to select an image from their gallery app.
Inspecting detectFromUri
shows that it uses InputImage.fromFilePath
as expected:
@ReactMethod
fun detectFromUri(uri: String, promise: Promise) {
val image: InputImage;
try {
image = InputImage.fromFilePath(reactApplicationContext, Uri.parse(uri));
val recognizer = TextRecognition.getClient();
recognizer.process(image).addOnSuccessListener { visionText ->
promise.resolve(getDataAsArray(visionText))
}.addOnFailureListener { e ->
promise.reject(e);
e.printStackTrace();
}
} catch (e: Exception) {
promise.reject(e);
e.printStackTrace();
}
}
TLDR: I believe detectFromFile would be an alias for the detectFromUri function for Android.
Hey, using the latest version 0.2.2 and it seems detectFromFile is not implemented in the android project just detectFromUri.
00:10:27 | WARN | Failed to do text recognition MlkitOcr.detectFromFile is not a function. (In 'MlkitOcr.detectFromFile(path)', 'MlkitOcr.detectFromFile' is undefined)