mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 06:33:56 +00:00
move GetText() func code
This commit is contained in:
parent
e0dd579aaa
commit
99bcbcd591
42
robotgo.go
42
robotgo.go
@ -748,6 +748,27 @@ func SetKeyboardDelay(delay int) {
|
||||
|______/ |__| |__| |__| |__| /__/ \__\ | _|
|
||||
*/
|
||||
|
||||
// GetText get the image text by tesseract ocr
|
||||
//
|
||||
// robotgo.GetText(imgPath, lang string)
|
||||
func GetText(imgPath string, args ...string) (string, error) {
|
||||
var lang = "eng"
|
||||
|
||||
if len(args) > 0 {
|
||||
lang = args[0]
|
||||
if lang == "zh" {
|
||||
lang = "chi_sim"
|
||||
}
|
||||
}
|
||||
|
||||
body, err := exec.Command("tesseract", imgPath,
|
||||
"stdout", "-l", lang).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
|
||||
// ToBitmap trans C.MMBitmapRef to Bitmap
|
||||
func ToBitmap(bit C.MMBitmapRef) Bitmap {
|
||||
bitmap := Bitmap{
|
||||
@ -793,27 +814,6 @@ func TocharBitmap(bit C.MMBitmapRef) *C.char {
|
||||
return strBit
|
||||
}
|
||||
|
||||
// GetText get the image text by tesseract ocr
|
||||
//
|
||||
// robotgo.GetText(imgPath, lang string)
|
||||
func GetText(imgPath string, args ...string) (string, error) {
|
||||
var lang = "eng"
|
||||
|
||||
if len(args) > 0 {
|
||||
lang = args[0]
|
||||
if lang == "zh" {
|
||||
lang = "chi_sim"
|
||||
}
|
||||
}
|
||||
|
||||
body, err := exec.Command("tesseract", imgPath,
|
||||
"stdout", "-l", lang).Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(body), nil
|
||||
}
|
||||
|
||||
func internalFindBitmap(bit, sbit C.MMBitmapRef, tolerance float64) (int, int) {
|
||||
pos := C.find_bitmap(bit, sbit, C.float(tolerance))
|
||||
// fmt.Println("pos----", pos)
|
||||
|
Loading…
Reference in New Issue
Block a user