Skip to content

Commit

Permalink
move GetText() func code
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed Mar 11, 2019
1 parent e0dd579 commit 99bcbcd
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 99bcbcd

Please sign in to comment.