react-native-mlkit-ocr icon indicating copy to clipboard operation
react-native-mlkit-ocr copied to clipboard

MlkitOcr.detectFromUri is null

Open albertytau opened this issue 1 year ago • 6 comments

HI there,

We try to use running expo sdk 45 and rn 0.69

import MlkitOcr, { MlkitOcrResult } from 'react-native-mlkit-ocr';

const sample_image = "data:image/jpeg;base64,/9j/4QF ............." const text = await MlkitOcr.detectFromUri(sample_image);

we catch the error is MlkitOcr.detectFromUri is null

It seems MlkitOcr is not well defined in the package react-native-mlkit-ocr

Kindly point out the mistakes we have made, many thanks

Albert

albertytau avatar Jul 25 '22 09:07 albertytau

bump, same issue

i call it like:

 let response = await ImagePicker.launchImageLibraryAsync(
    {
      mediaType: 'photo',
    });
await MlkitOcr.detectFromUri(response.uri);

and error is:

[Unhandled promise rejection: TypeError: null is not an object (evaluating 'MlkitOcr.detectFromUri')]
at node_modules/react-native-mlkit-ocr/src/index.tsx:68:30 in <global>
at node_modules/react-native-mlkit-ocr/src/index.tsx:69:15 in <global>

and response is like (so it does catches something):

Object {
  "assetId": null,
  "base64": null,
  "cancelled": false,
  "exif": null,
  "height": 1920,
  "type": "image",
  "uri": "file:///data/user/0/host.exp.exponent/cache/ImagePicker/79f43782-0251-4131-802a-994d714d1a81.png",
  "width": 1080,
}

nicramu avatar Sep 20 '22 15:09 nicramu