From 99bcbcd5917ffacf97d9e1fb112a463d8d9a6425 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 11 Mar 2019 10:26:58 -0400 Subject: [PATCH] move GetText() func code --- robotgo.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/robotgo.go b/robotgo.go index c08ee97..316be87 100644 --- a/robotgo.go +++ b/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)