Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在使用批量OCR的时候,使用命令行来开始任务,提示“Calling "ocrStart" in main thread.”,识别在主线程中执行,那有没有办法监听程序什么时候执行完呢? #688

Open
1 task done
521Peter opened this issue Oct 15, 2024 · 4 comments

Comments

@521Peter
Copy link

Issues

  • I have browsed through the Issues. 我已浏览过Issues,确定没有重复的建议。

Expected behavior 预期的功能

企业微信截图_17289574077892

Approximate reference (optional) 近似的参考(可选)

No response

@hiroi-sora
Copy link
Owner

如果想细粒度的操作OCR过程,建议使用HTTP接口。可以自己控制传输每一张图片,获取结果,写入文件。

@521Peter
Copy link
Author

好的,感谢

@521Peter
Copy link
Author

521Peter commented Oct 17, 2024

我是发现批量ocr,最终会输出包含识别结果的txt文件,然后我找到了源码,改成识别完成后,输出一个finish.txt文件,写个程序持续监听文件输出,有文件输出则表示识别完成了。然后我发现好像有个bug,

for (let it of paths) {
      const params = it.map((p) => `\\"${p.replace(/\\/g, "/")}\\"`).join(",");
      await exec(
        [
          `.\\${this.exeName}`,
          `--call_qml`,
          `BatchOCR`,
          `--func`,
          `addImages`,
          `"[${params}]"`,
        ].join(" "),
        this.exeDir
      );
    }

    await exec(
      [
        `.\\${this.exeName}`,
        `--call_qml`,
        `BatchOCR`,
        `--func`,
        `ocrStart`,
      ].join(" "),
      this.exeDir
    ); 

如果批量添加图片,之后执行ocr操作,有概率部分图片没能添加到列表中

@hiroi-sora
Copy link
Owner

如果批量添加图片,之后执行ocr操作,有概率部分图片没能添加到列表中

可能你程序的操作太快了。Umi添加图片的时候会进行一些检测,需要一点点时间。如果一次性添加大量图片然后立刻开始OCR,可能后面的图片来不及添加到任务列表里。

你的代码,两次 exec 之间 sleep 0.5秒 应该就可以避免了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants