I have created a project with vue-service-cli. After trying to use tesseract OCR but I can't load lang.traineddata locally and remotely. I have tried examples (they work) from tesseract.js repo and other many ways but with no result. When I try to load them I see standard error:
Error opening data file ./eng.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'eng'
Tesseract couldn't load any languages!
AdaptedTemplates != nullptr:Error:Assert failed:in file /src/src/classify/adaptmatch.cpp, line 196
trap!
I suspect this is a problem by .asar archive format ( from vue-cli-plugin-electron-builder ), which is in "/node_modules/electron/dist/resources/electron.asar". I can load files from ./public but I was read languages files have to are in the process directory - I don't know if it's true. Some configuration can't work together.
My code
const data = await Tesseract.recognize(
"https://tesseract.projectnaptha.com/img/eng_bw.png",
"eng",
{
logger: console.log,
corePath: window.location.origin + "/tesseract/tesseract-core.wasm.js",
workerPath: window.location.origin + "/tesseract/worker.min.js",
langPath: window.location.origin + "/tesseract/tessdata"
//or
langPath: path.join(__dirname, "tessdata")
}
My dependencies
"dependencies": {
"core-js": "^3.4.4",
"electron": "5.0.0",
"semantic-ui-css": "^2.4.1",
"tesseract.js": "2.0.2",
"vue": "^2.6.10",
"vue-class-component": "^7.0.2",
"vue-property-decorator": "^8.3.0",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-typescript": "^4.1.0",
"@vue/cli-plugin-vuex": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"@vue/eslint-config-prettier": "^5.0.0",
"@vue/eslint-config-typescript": "^4.0.0",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.12.0",
"prettier": "^1.19.1",
"pug": "^2.0.4",
"pug-plain-loader": "^1.0.0",
"sass-loader": "^8.0.0",
"typescript": "~3.5.3",
"vue-cli-plugin-electron-builder": "^1.4.4",
"vue-template-compiler": "^2.6.10"
}
EDIT: I noticed that https://github.com/auth0-blog/electron-vue project working fine with Tesseract.js. That project uses Vue but without vue-vli-service which means it doesn't have vue-cli-plugin-electron-builder which confirms the above thesis. I'm still looking for a solution with the use vue-cli