2

Here is my code, I can recognize only one image using tesseract.js (i.e filepath1), I want to recognize both images (filepath1 and filepath2), how to achieve that?

app.post("/",(req,res)=>{

const form = formidable({multiples:true});
form.parse(req,(err,fields,files)=>{

 const filepath1 = files.file1.filepath;
 const filepath2 = files.file2.filepath;

 const worker = createWorker({
  logger: m => console.log(m)

});

(async () => {
  await worker.load();
  await worker.loadLanguage('eng');
  await worker.initialize('eng');

  const { data: { text } } = await worker.recognize(filepath1);
  const replacedtext1 = text.replace(/[^a-zA-Z ]/g, "");
  const wordextract1 = replacedtext1.match(/\w+/g);

   fileextract1.push(wordextract1);
  console.log(wordextract1);
  await worker.terminate();
})();
 });
});
tetar
  • 682
  • 1
  • 10
  • 25
  • 1
    do you need to use tesseract.js ? with node-tesseract-ocr you can do it. (i m working on it ) – tetar Sep 05 '22 at 12:28

0 Answers0