🎨 OCR 结果剔除不可见字符

This commit is contained in:
Liang Ding 2023-01-18 00:39:42 +08:00
parent ca2a27c964
commit 6d4aa07bc7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -89,9 +89,7 @@ func Tesseract(imgAbsPath string) string {
} }
ret := string(output) ret := string(output)
ret = strings.ReplaceAll(ret, "\r", "") ret = gulu.Str.RemoveInvisible(ret)
ret = strings.ReplaceAll(ret, "\n", "")
ret = strings.ReplaceAll(ret, "\t", " ")
reg := regexp.MustCompile("\\s{2,}") reg := regexp.MustCompile("\\s{2,}")
ret = reg.ReplaceAllString(ret, " ") ret = reg.ReplaceAllString(ret, " ")
msg := fmt.Sprintf("OCR [%s] [%s]", info.Name(), ret) msg := fmt.Sprintf("OCR [%s] [%s]", info.Name(), ret)