Closed CorpOnThron closed 3 years ago
@CorpOnThron have you checked your app permissions?
@jonathanpalma those are permissions I have
All of them are allowed.
More of the background, I have OpenCV integration in this project, if it does change anything.
The same issue. How to fix this?
@luan-cs no fix that I found yet.
Still haven't been able to replicate it, can you please share the full stack trace?
@jonathanpalma Sorry for the late reply, here is what I get:
reactConsoleErrorHandler | @ | D:\GitHubRep\veritas…tionsManager.js:179 | |
---|---|---|---|
n | @ | D:\GitHubRep\veritas…\dist\backend.js:32 | |
registerError | @ | D:\GitHubRep\veritas…ogBox\LogBox.js:148 | |
errorImpl | @ | D:\GitHubRep\veritas…LogBox\LogBox.js:59 | |
console.error | @ | D:\GitHubRep\veritas…LogBox\LogBox.js:33 | |
_callee$ | @ | D:\GitHubRep\veritas…\CameraScreen.js:88 | |
tryCatch | @ | D:\GitHubRep\veritas…ntime\runtime.js:63 | |
invoke | @ | D:\GitHubRep\veritas…time\runtime.js:293 | |
(anonymous) | @ | D:\GitHubRep\veritas…time\runtime.js:118 | |
tryCatch | @ | D:\GitHubRep\veritas…ntime\runtime.js:63 | |
invoke | @ | D:\GitHubRep\veritas…time\runtime.js:154 | |
(anonymous) | @ | D:\GitHubRep\veritas…time\runtime.js:166 | |
tryCallOne | @ | D:\GitHubRep\veritas…mmediate\core.js:37 | |
(anonymous) | @ | D:\GitHubRep\veritas…mediate\core.js:123 | |
(anonymous) | @ | D:\GitHubRep\veritas…ers\JSTimers.js:274 | |
_callTimer | @ | D:\GitHubRep\veritas…ers\JSTimers.js:130 | |
_callImmediatesPass | @ | D:\GitHubRep\veritas…ers\JSTimers.js:181 | |
callImmediates | @ | D:\GitHubRep\veritas…ers\JSTimers.js:441 | |
__callImmediates | @ | D:\GitHubRep\veritas…MessageQueue.js:387 | |
(anonymous) | @ | D:\GitHubRep\veritas…MessageQueue.js:135 | |
__guard | @ | D:\GitHubRep\veritas…MessageQueue.js:364 | |
flushedQueue | @ | D:\GitHubRep\veritas…MessageQueue.js:134 | |
invokeCallbackAndReturnFlushedQueue | @ | D:\GitHubRep\veritas…MessageQueue.js:130 | |
(anonymous) | @ | debuggerWorker.cff11639.js:4 |
same problem with my app, with app permissions enabled
guys have you got solutions?
I am facing the same issue :(
I'm running into the same issue. However, in my case it runs flawlessly without any errors through the emulator, but when I build the .apk and install it on my phone I'm met with this error. Permissions have been granted. Very strange.
I am facing the same issue :(
Have anyone got solutions?
I'm have the same issue.... Anyone already find solutions?
Hi everyone! I've been busy during the last weeks and haven't had enough time to work on this, but I would appreciate if anyone can take a look, will try to follow up in the upcoming weeks
I'm have the same issue. Anyone find solutions?
This library have a strong dependency with react-native-image-crop-picker, I think it's related to a missing permission request that is already handled by the crop library. I finally fixed it by using react-native-image-crop-picker instead of using direcly RNCamera.
Another line of investigation : Files created by crop library are located under : file:///storage/emulated/0/Pictures/... Files created by RNCamera are located under : file:///data/user/0/com.cvroom/cache/Camera/...
@AmineZAMANI can u explain to us more details? what you changed in the source code? Thank youu
I fixed the problem following this steps :
1) Adding this dependency in the package.json :
"react-native-image-crop-picker": "^0.25.0"
2) Intercepting the picture using this library (react-native-image-crop-picker) :
import ImagePicker from 'react-native-image-crop-picker';
...
const getImageFromCamera = async (options = defaultPickerOptions) => {
try {
const image = await ImagePicker.openCamera(options);
return image.path;
} catch (err) {
if (err.message !== 'User cancelled image selection') {
console.error(err);
}
}
};
3) Processing the captured image using OCR library :
getImageFromCamera().then((path) => {
console.log(path);
this.processDocument(path).then((result) => {
this.setState({
result: result,
loading: false,
});
});
...
processDocument = async (localPath) => {
ocrService.setLocalPath(localPath);
return ocrService.process();
};
Good luck !
I was facing same issues. These steps helped me to fix bugs:
1. In Android Folder, open AndroidMenifest file and add android:requestLegacyExternalStorage <manifest ... >
<application
android:requestLegacyExternalStorage="true"
... >
...
</application>
2. Check that you have language.traineddata (for example eng.traineddata for English language) in android/app/main/assets/tessdata/ ? if not create assets/tessdata folders. Download your required language's traineddata file from here https://github.com/tesseract-ocr/tessdata and paste in android/app/main/assets/tessdata/
These steps helped me to fix. If it works for you then like my comments. So, others can refer this positively
I was facing same issues. These steps helped me to fix bugs:
1. In Android Folder, open AndroidMenifest file and add android:requestLegacyExternalStorage <manifest ... >
<application android:requestLegacyExternalStorage="true" ... > ...
2. Check that you have language.traineddata (for example eng.traineddata for English language) in android/app/main/assets/tessdata/ ? if not create assets/tessdata folders. Download your required language's traineddata file from here https://github.com/tesseract-ocr/tessdata and paste in android/app/main/assets/tessdata/
These steps helped me to fix. If it works for you then like my comments. So, others can refer this positively
Thank you so much, i was trying fix this problem for 2 weeks. This solve is worked
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I was facing same issues. These steps helped me to fix bugs:
1. In Android Folder, open AndroidMenifest file and add android:requestLegacyExternalStorage <manifest ... >
<application android:requestLegacyExternalStorage="true" ... > ...
2. Check that you have language.traineddata (for example eng.traineddata for English language) in android/app/main/assets/tessdata/ ? if not create assets/tessdata folders. Download your required language's traineddata file from here https://github.com/tesseract-ocr/tessdata and paste in android/app/main/assets/tessdata/
These steps helped me to fix. If it works for you then like my comments. So, others can refer this positively
i was following step by step, but it's still showing java.io.IOException: Could not create directory.
I'm also having the same issues despite following the recommended steps. The changes I've made are displayed below:
I am having this issue only on real device. The library works really well on emulator
After looking into this issue, I found that the library is trying to create a folder under app
Path: /storage/emulated/0/com.xxx/tessdata]
Is this path included in WRITE_EXTERNAL_STORAGE
?
This problem only happened when running the app in mobile. So I think that after the update this path will no longer included in WRITE_EXTERNAL_STORAGE
. We need to choose a different path.
It will be greet if we could have an option where we specify the path to TESS_FILES_PATH
this way we would not need to have the files under assets
and the library would not have to copy it from there.
Optional change TESS_FILES_PATH
to a valid path where its permission is included in `WRITE_EXTERNAL_STORAGE
And please try to open this issue agen.
Anybody who find soluting facing same issue
Anybody who find soluting facing same issue
facing the same issue 🤦♂️
Facing the same issue, I've tried everything. it works perfectly on emulator but not at all on real device [Error: java.io.IOException: Could not create directory] I even tried with the exemple code (by taking only the code in app.js) same issue 😕 I also checked proposed solutions but nothing seems to work.
I know this repo is kinda old, anyone knows an alternative for react native ocr ? Or maybe someone found a solution ? It would be very helpful !
By using this package your mobile app size will increase. So better to go with a third-party online service if your app has access to the internet connection of the device.
Thats really interesting, @HipppB I am using an alternative react-native-text-detector which is even less maintained but provides support for iOS, and I'm facing the exact same problem over there. The simulator is working fine but the real mobile is constantly crashing once tessdata is use.
@Macilias I am going to look to change. I have worked on the problem for hours now and I think I am on something to make this library work, I lack skills to make it work for the moment but I will explain here what I think is the issue
This package is using File instructions to create folders, and modify them and uses Environment.getExternalStorageDirectory() to get a place to create files. It seems it is working fine on my virtual devices because I used android 7, 8 and 9 to test my code, but my real device is under android 10, which is android API 29 In API 29 the method Environment.getExternalStorageDirectory() seems to be depreciated (For privacy reasons)
I tested with a VM on android 10 using API 29 and I finally succeed to reproduce the error... That is also why changing permissions in android manifest does not work, it is just blocked by android.
I found this https://stackify.dev/852015-how-to-read-or-write-file-as-getexternalstoragedirectory-is-deprecated-in-api-29 If someone that knows java and how to update a package is willing to update this one it would be awesome If not, I will try to do it myself (but I have a lot to learn before so it's not for now 😕)
For your crash while using tessdata @Macilias you may check if you don't run multiple worker at once (it makes the app crash), I had to create a queue system to avoid that in my app, the problem may be the same in react-native-text-detector.
By using this package your mobile app size will increase. So better to go with a third-party online service if your app has access to the internet connection of the device.
Unfortunately my app as to run offline for privacy reasons 😔
Describe the bug When picture URL is passed to recognize the method![photo_2020-08-10_02-47-05](https://user-images.githubusercontent.com/39676808/89757736-19339200-dab4-11ea-84ae-3ea505ca10a1.jpg)
Dependencies (please complete the following information):
Code
async takePicture() { if (this.camera) { const options = { quality: 0.5, base64: true }; const data = await this.camera.takePictureAsync(options); console.log("Before take: ", data); await this.recognizeTextFromImage(data.uri); //...... } } recognizeTextFromImage = async (path) => { console.log(TesseractOcr); try { const tesseractOptions = {}; const recognizedText = await TesseractOcr.recognize( path, LANG_ENGLISH, tesseractOptions, ); console.log("text", recognizedText); this.setState({text:recognizedText}); } catch (err) { console.error(err); this.setState({text:""}); }
};