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

This commit is contained in:
Liang Ding 2023-01-16 15:39:31 +08:00
parent d65bce4a17
commit 5593542f73
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -42,10 +42,22 @@ var (
assetsTextsChanged = false
)
func GetAssetText(assets string) string {
func GetAssetText(asset string) string {
assetsTextsLock.Lock()
defer assetsTextsLock.Unlock()
return assetsTexts[assets]
ret, ok := assetsTexts[asset]
assetsTextsLock.Unlock()
if ok {
return ret
}
assetsPath := GetDataAssetsAbsPath()
assetAbsPath := strings.TrimPrefix(asset, "assets")
assetAbsPath = filepath.Join(assetsPath, assetAbsPath)
ret = Tesseract(assetAbsPath)
assetsTextsLock.Lock()
assetsTexts[asset] = ret
assetsTextsLock.Unlock()
return ret
}
func Tesseract(imgAbsPath string) string {