Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Liang Ding9788cce4b0e6
diff --git a/kernel/model/assets.go b/kernel/model/assets.go
index 61e3636218..d3f8204778 100644
--- a/kernel/model/assets.go
+++ b/kernel/model/assets.go
@@ -636,11 +636,18 @@ func UnusedAssets() (ret []string) {
}
}
- // 排除文件注解和对应文件
var toRemoves []string
for asset, _ := range assetsPathMap {
if strings.HasSuffix(asset, ".sya") {
+ // 排除文件注解和对应文件
toRemoves = append(toRemoves, asset, strings.TrimSuffix(asset, ".sya"))
+ continue
+ }
+
+ if strings.HasSuffix(asset, "ocr-texts.json") {
+ // 排除 OCR 结果文本
+ toRemoves = append(toRemoves, asset)
+ continue
}
}
for _, toRemove := range toRemoves {
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go
index b5d9f353f9..0f3d8318b6 100644
--- a/kernel/util/ocr.go
+++ b/kernel/util/ocr.go
@@ -259,6 +259,10 @@ func getTesseractVer() (ret string) {
cmd := exec.Command("tesseract", "--version")
gulu.CmdAttr(cmd)
data, err := cmd.CombinedOutput()
+ if nil != err {
+ logging.LogWarnf("tesseract-ocr not found: %s", err)
+ }
+ logging.LogWarnf("tesseract --version: %s", string(data))
if nil == err && strings.HasPrefix(string(data), "tesseract v") {
parts := bytes.Split(data, []byte("\n"))
if 0 < len(parts) {