I am having a problem using the Tesseract.js libary in an React Native App (on the Android Platform). I am currently taking a picture with in the App, saving the image information in a base64 string
and trying to pass it the the worker.recognize()
function. The string passed to the function is built as followed: data:image/jpeg;base64,MY_BASE64_STRING
. I also tried passing a URL to an image and also tried using the absolute path to an image file I'm always getting the same error:
Error: Cannot create URL for blob!
Here is the code I am using for version 2.0.0-alpha.13:
const { TesseractWorker } = Tesseract
const worker = new TesseractWorker({
workerPath: '../../../node_modules/tesseract.js/dist/worker.min.js',
langPath: '../../assets/lang',
corePath: '../../../node_modules/tesseract.js-core/tesseract-core.wasm.js',
})
worker
.recognize(`data:image/jpeg;base64,${data.base64}`)
.progress(info => {
console.log(info)
})
.then(result => {
console.log(result.text)
})
I tried using Versions 1.0.19 and the alpha version 2.0.0-alpha.13
Thank you to you all! ♥
Tesseract.js doesn't support react-native according to this issue.
https://github.com/naptha/tesseract.js/issues/55
Use this library which uses native mobile modules instead. Might not work with expo though