Open albertytau opened 2 years ago
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,
}
just installed on my project I don't get this error. It works fine.
LOG Running "AwesomeTSProject" with {"rootTag":1,"initialProps":{}}
LOG init
LOG result {"assets": [{"fileName": "38174CCE-48D8-4C1C-A66A-CA604333FAD9.jpg", "fileSize": 21566, "height": 235, "type": "image/jpg", "uri": "file:///var/mobile/Containers/Data/Application/03EBD078-97DE-4FA8-83A8-266FB9C8DCBD/tmp/38174CCE-48D8-4C1C-A66A-CA604333FAD9.jpg", "width": 215}]}
LOG resultFromUri [{"bounding": {"height": 16, "left": 28, "top": 13, "width": 67}, "cornerPoints": [[Object], [Object], [Object], [Object]], "lines": [[Object]], "text": "ONGSHIM"}, {"bounding": {"height": 20, "left": 103, "top": 144, "width": 81}, "cornerPoints": [[Object], [Object], [Object], [Object]], "lines": [[Object], [Object]], "text": "SHIN RAMYUN
NOGDLE SOLE"}]
LOG Finished processing file.
However, I get type error.
I've tried, reinstalling and restarting ts server and restarting vs code. none of them worked.
Could not find a declaration file for module 'react-native-mlkit-ocr'. '/Users/yj/projects/aquadesk/AwesomeTSProject/node_modules/react-native-mlkit-ocr/lib/commonjs/index.js' implicitly has an 'any' type.
[Contribute a translation for #7016](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
https://github.com/agoldis/react-native-mlkit-ocr/pull/39 this could possibly related.
I have both problems as well.
Cannot read property 'detectFromFile' of null
and type declaration. Any news?
Bump on this - same error. I'm in a .js vs .ts Expo managed project. Any help getting up and running?
I was getting this error on Expo Go. Switched to development build and it appears to be working now.
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