🎨 桌面端支持搜索图片 OCR 文本 https://github.com/siyuan-note/siyuan/issues/3470

This commit is contained in:
Liang Ding 2023-01-17 10:24:47 +08:00
parent c7809a7403
commit 57f947468c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 47 additions and 2 deletions

View file

@ -74,7 +74,6 @@ func Tesseract(imgAbsPath string) string {
ctx, cancel := context.WithTimeout(context.Background(), 7*time.Second)
defer cancel()
now := time.Now()
cmd := exec.CommandContext(ctx, "tesseract", "-c", "debug_file=/dev/null", imgAbsPath, "stdout", "-l", strings.Join(TesseractLangs, "+"))
gulu.CmdAttr(cmd)
output, err := cmd.CombinedOutput()
@ -94,7 +93,6 @@ func Tesseract(imgAbsPath string) string {
ret = strings.ReplaceAll(ret, "\t", " ")
reg := regexp.MustCompile("\\s{2,}")
ret = reg.ReplaceAllString(ret, " ")
logging.LogInfof("tesseract [path=%s, size=%d, text=%s, elapsed=%dms]", imgAbsPath, info.Size(), ret, time.Since(now).Milliseconds())
msg := fmt.Sprintf("OCR [%s] [%s]", info.Name(), ret)
PushStatusBar(msg)
return ret