Pure Javascript OCR for more than 100 Languages 📖🎉🖥
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
886 B

/**
*
* Node worker implementation
*
* @fileoverview Node worker implementation
* @author Kevin Kwok <antimatter15@gmail.com>
* @author Guillermo Webster <gui@mit.edu>
* @author Jerome Wu <jeromewus@gmail.com>
*/
const check = require('check-types');
const workerUtils = require('../common/workerUtils');
let TesseractCore = null;
/*
* register message handler
*/
process.on('message', (packet) => {
workerUtils.dispatchHandlers(packet, obj => process.send(obj));
});
8 years ago
/*
* getCore is a sync function to load and return
* TesseractCore.
*/
workerUtils.setAdapter({
6 years ago
getCore: (corePath, res) => {
if (check.null(TesseractCore)) {
6 years ago
res.progress({ status: 'loading tesseract core', progress: 0 });
TesseractCore = require('tesseract.js-core');
6 years ago
res.progress({ status: 'loaded tesseract core', progress: 1 });
}
return TesseractCore;
},
});