微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Tesseract.js 一遍又一遍地识别相同的图像

如何解决Tesseract.js 一遍又一遍地识别相同的图像

我正在测试 tesseract.js 以上传多个图像并将它们转换为文本。我似乎无法在识别后正确保存并停止该过程以显示它。

以下是我使用的代码

 const textConverison = async () => {
        var i;
        for (i = 0; i < listofImages.length; i++) {
            await worker.load();
            await worker.loadLanguage('eng');
            await worker.initialize('eng');
            worker._currentJob = null;
            const { data: { text } } = await worker.recognize(listofImages[i].default);
            setocr(text);
        }
    };

JSX 代码

 <div className="text-slide-container">
                        <div className="row">
                            { listofImages && listofImages.map(image => (
                                <div className="col-3">
                                    <div className="slide-preview-item">
                                        <div className="img-wrap no-margin overflow-hide option-display txt-display" key={image.id}>
                                            <div>{ ocr }</div>
                                        </div>
                                    </div>
                                </div>
                            )) }
                        </div>
</div>

我想以卡片格式显示已转换为文本的上传图像。但它总是循环更新其他图像。

希望有人能帮助我。我真的很感激。谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。