gpt4 book ai didi

javascript - VSt上带有Node.js的“Error: Failed to detect OS”

转载 作者:行者123 更新时间:2023-12-03 08:41:07 25 4
gpt4 key购买 nike

我正在使用tesseract.js进行OCR,但是当我更改exampleImage时,出现此错误。我根本找不到有关此错误的任何信息。先感谢您。

app.js

const exampleImage = 'https://d1q6f0aelx0por.cloudfront.net/product-logos/5431a80b-9ab9-486c-906a-e3d4b5ccaa96-hello-world.png';
const Tesseract=require('tesseract.js');
const worker = Tesseract.createWorker({
logger: m => console.log(m)
});
Tesseract.setLogging(true);
work();

async function work() {
await worker.load();
await worker.loadLanguage('eng');
await worker.initialize('eng');

let result = await worker.detect(exampleImage);
console.log(result.data);

result = await worker.recognize(exampleImage);
console.log(result.data);

await worker.terminate();
}

Console.log
Error: Failed to detect OS
at ChildProcess.<anonymous> (c:\Users\jorda\AppData\Local\Programs\Microsoft VS Code\bin\Example\node_modules\tesseract.js\src\createWorker.js:173:15)
at ChildProcess.emit (events.js:311:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)

最佳答案

您的用法及其文档使用案例不匹配您是否检查了其文档?

  • https://github.com/naptha/tesseract.js/blob/master/docs/examples.md

  • 例如,尝试像他们一样写作;
    const { createWorker } = require('tesseract.js');
    const exampleImage = 'https://d1q6f0aelx0por.cloudfront.net/product-logos/5431a80b-9ab9-486c-906a-e3d4b5ccaa96-hello-world.png';

    const worker = createWorker({
    logger: m => console.log(m), // Add logger here
    });

    (async () => {
    await worker.load();
    await worker.loadLanguage('eng');
    await worker.initialize('eng');
    const { data: { text } } = await worker.recognize(exampleImage);
    console.log(text);
    await worker.terminate();
    })();

    关于javascript - VSt上带有Node.js的“Error: Failed to detect OS”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61416624/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com