|
|
|
@ -57,22 +57,19 @@ function handleInit(req, res){
@@ -57,22 +57,19 @@ function handleInit(req, res){
|
|
|
|
|
TesseractProgress(percent){ |
|
|
|
|
latestJob.progress({ status: 'recognizing text', progress: Math.max(0, (percent-30)/70) }); |
|
|
|
|
}, |
|
|
|
|
onRuntimeInitialized() {} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Module.FS_createPath("/", "tessdata", true, true); |
|
|
|
|
base = new Module.TessBaseAPI(); |
|
|
|
|
res.progress({ status: 'initializing tesseract', progress: 1 }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function setImage(Module, base, image) { |
|
|
|
|
var imgbin = desaturate(image), |
|
|
|
|
width = image.width, |
|
|
|
|
height = image.height; |
|
|
|
|
const imgbin = desaturate(image); |
|
|
|
|
const { width, height } = image; |
|
|
|
|
|
|
|
|
|
var ptr = Module.allocate(imgbin, 'i8', Module.ALLOC_NORMAL); |
|
|
|
|
base.SetImage(Module.wrapPointer(ptr), width, height, 1, width); |
|
|
|
|
const ptr = Module._malloc(imgbin.length, Uint8Array.BYTES_PER_ELEMENT); |
|
|
|
|
Module.HEAPU8.set(imgbin, ptr); |
|
|
|
|
base.SetImage(ptr, width, height, Uint8Array.BYTES_PER_ELEMENT, width); |
|
|
|
|
base.SetRectangle(0, 0, width, height); |
|
|
|
|
return ptr; |
|
|
|
|
} |
|
|
|
@ -86,7 +83,7 @@ function loadLanguage(req, res, cb){
@@ -86,7 +83,7 @@ function loadLanguage(req, res, cb){
|
|
|
|
|
|
|
|
|
|
adapter.getLanguageData(req, res, function(data){ |
|
|
|
|
res.progress({ status: 'loading ' + langFile, progress: 0 }); |
|
|
|
|
Module.FS_createDataFile('tessdata', langFile, data, true, false); |
|
|
|
|
Module.FS.writeFile(langFile, data); |
|
|
|
|
Module._loadedLanguages[lang] = true; |
|
|
|
|
res.progress({ status: 'loading ' + langFile, progress: 1 }); |
|
|
|
|
cb(); |
|
|
|
|