mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
🎨 Add OCR-related operations to the picture menu https://github.com/siyuan-note/siyuan/issues/7203
This commit is contained in:
parent
c6b3083a24
commit
9461cc3f95
3 changed files with 51 additions and 5 deletions
|
|
@ -44,21 +44,31 @@ var (
|
|||
TesseractLangs []string
|
||||
)
|
||||
|
||||
func GetAssetText(asset string) string {
|
||||
func SetAssetText(asset, text string) {
|
||||
AssetsTextsLock.Lock()
|
||||
ret, ok := AssetsTexts[asset]
|
||||
AssetsTexts[asset] = text
|
||||
AssetsTextsLock.Unlock()
|
||||
if ok {
|
||||
return ret
|
||||
AssetsTextsChanged = true
|
||||
}
|
||||
|
||||
func GetAssetText(asset string, force bool) string {
|
||||
if !force {
|
||||
AssetsTextsLock.Lock()
|
||||
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)
|
||||
ret := Tesseract(assetAbsPath)
|
||||
AssetsTextsLock.Lock()
|
||||
AssetsTexts[asset] = ret
|
||||
AssetsTextsLock.Unlock()
|
||||
AssetsTextsChanged = true
|
||||
return ret
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue