Skip to content

Commit

Permalink
fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nb857 committed Nov 24, 2021
1 parent 2c37899 commit bedc33c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ require (
github.com/go-ole/go-ole v1.2.5
github.com/pkg/errors v0.9.1
github.com/rogeecn/draw v1.0.4
github.com/sirupsen/logrus v1.8.1 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand All @@ -8,11 +9,16 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogeecn/draw v1.0.4 h1:BkoAaFoz+Hghk6ndl+mFEitm5xX01UCcaRaMme560hE=
github.com/rogeecn/draw v1.0.4/go.mod h1:vyJltYp7CjUAZjbh+7m7/4FnPHzE5+BwdEmrqfTCqqM=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 h1:7TYNF4UdlohbFwpNH04CoPMp1cHUZgO1Ebq5r2hIjfo=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
9 changes: 5 additions & 4 deletions ocr.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/rogeecn/draw"
"github.com/rogeecn/gdm/color"
"github.com/rogeecn/gdm/utils"
log "github.com/sirupsen/logrus"
"strings"
)

Expand Down Expand Up @@ -38,18 +39,18 @@ func (com *DmSoft) FindStr(r *draw.Rect, str []string, colors *color.Colors, sim
y := ole.NewVariant(ole.VT_I4, 0)
ret, _ := com.dm.CallMethod("FindStr", r.Left(), r.Top(), r.Right(), r.Bottom(), strings.Join(str, "|"), colors.String(), sim, &x, &y)

var pt *draw.Point
pt.X = int(x.Val)
pt.Y = int(y.Val)
ptX := int(x.Val)
ptY := int(y.Val)

x.Clear()
y.Clear()

return pt, utils.IsFindStrOK(ret.Val)
return draw.NewPoint(ptX, ptY), utils.IsFindStrOK(ret.Val)
}

func (com *DmSoft) FindStrE(r *draw.Rect, str []string, colors *color.Colors, sim float32) *utils.FindItemResult {
ret, _ := com.dm.CallMethod("FindStrE", r.Left(), r.Top(), r.Right(), r.Bottom(), strings.Join(str, "|"), colors.String(), sim)
log.Debugf("FindStrE result: %s", ret.ToString())
return utils.NewFindItemResult(str, ret.ToString())
}

Expand Down
8 changes: 8 additions & 0 deletions utils/word.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"fmt"
"github.com/rogeecn/draw"
log "github.com/sirupsen/logrus"
"strconv"
"strings"
)
Expand Down Expand Up @@ -40,6 +41,8 @@ type FindItemResult struct {
}

func NewFindItemResult(words []string, ret string) *FindItemResult {
log.Debugf("NewFindItemResult Parse Result words(%+v), ret: %s", words, ret)

f := &FindItemResult{}
if len(ret) == 0 {
return f
Expand All @@ -48,14 +51,19 @@ func NewFindItemResult(words []string, ret string) *FindItemResult {
rets := strings.Split(ret, "|")
f.Index, _ = strconv.Atoi(rets[0])
if f.Index == -1 {
log.Debugf("NewFindItemResult got index: %d", f.Index)

return f
}
if f.Index > len(words) {
f.Index = -1
return f
}
log.Debugf("NewFindItemResult got index: %d", f.Index)

f.Item = words[f.Index]
f.Point = draw.NewPoint(-1, -1)

f.Point.X, _ = strconv.Atoi(rets[1])
f.Point.Y, _ = strconv.Atoi(rets[2])

Expand Down

0 comments on commit bedc33c

Please sign in to comment.