相关文章推荐
仗义的羽毛球  ·  python ...·  6 月前    · 
有情有义的汤圆  ·  Get exclusive jobs on ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams const fs = require("fs"); const multer = require('multer'); const { createWorker } = require("tesseract.js"); const worker = createWorker(); //Storage const storage = multer.diskStorage({ destination: (req,file,cb) => { cb(null, "./uploads"); filename: (req,file,cb) => { cb(null, file.originalname); const upload = multer({storage: storage}).single("avatar"); app.set('view engine', 'ejs'); //route app.get('/',(req,res)=>{ res.render('index'); app.post('/upload',(req,res) => { upload(req,res, err => { fs.readFile(`./uploads/${req.file.originalname}`,(err,data) => { if(err) return console.log('This is your error',err); worker .recognize(data, "eng", {tessjs_create_pdf: '1'}) .progress(progress => { console.log(progress); .then(result => { res.send(result.text); .finally(() => worker.terminate()) //Start Up our server const PORT = 5000 || process.env.PORT; app.listen(PORT, () => console.log(`Hey I am running on port ${PORT}`));

the error I get is this

     D:\ML\OCR\app.js:34
                    .progress(progress => {
    TypeError: worker.recognize(...).progress is not a function
        at D:\ML\OCR\app.js:34:18

I know worker.recognize/.progress is decapitated but can someone please correct this code. Thank you.

I am trying to create an OCR using tesseract.js . watching this video: https://www.youtube.com/watch?v=a1I3tcALTlc

But I am not able to find a solution.

I think the issue is that the code is out of date.

Try this

            async function getTextFromImage() {
            await worker.load()
            await worker.loadLanguage('eng')
            await worker.initialize('eng')
            const { data: { text } } = await worker.recognize(data);
            res.send(text);
            console.log(text);
            await worker.terminate()
            getTextFromImage();
                This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
– Cyrus Raoufi
                Aug 26, 2022 at 18:32
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.