Skip to content

Commit

Permalink
tap_cv supports WithDataScope
Browse files Browse the repository at this point in the history
  • Loading branch information
bbx-winner committed Jun 28, 2023
1 parent cd730a1 commit 030a739
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hrp/internal/version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.3.3.2306151200
v4.3.3.2306281303
2 changes: 1 addition & 1 deletion hrp/pkg/uixt/algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (dExt *DriverExt) FindDetectUIRectInUIKit(uiTypes []string, options ...Data
return 0, 0, 0, 0, err
}
var rect image.Rectangle
rect, err = service.FindUI(uiTypes, bufSource.Bytes())
rect, err = service.FindUI(uiTypes, bufSource.Bytes(), options...)
if err != nil {
return 0, 0, 0, 0, err
}
Expand Down
21 changes: 18 additions & 3 deletions hrp/pkg/uixt/ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,15 +614,30 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
return fmt.Errorf("invalid %s params: %v", ACTION_TapByOCR, action.Params)
case ACTION_TapByCV:
if imagePath, ok := action.Params.(string); ok {
return dExt.TapByCV(imagePath, WithDataIdentifier(action.Identifier), WithDataIgnoreNotFoundError(action.IgnoreNotFoundError), WithDataIndex(action.Index))
return dExt.TapByCV(
imagePath,
WithDataIdentifier(action.Identifier),
WithDataIgnoreNotFoundError(action.IgnoreNotFoundError),
WithDataIndex(action.Index),
WithDataScope(dExt.getAbsScope(action.Scope[0], action.Scope[1], action.Scope[2], action.Scope[3])),
)
}
if uiParams, ok := action.Params.([]interface{}); ok {
var uiTypes []string
for _, uiParam := range uiParams {
uiType, _ := uiParam.(string)
uiType, ok := uiParam.(string)
if !ok {
continue
}
uiTypes = append(uiTypes, uiType)
}
return dExt.TapByUIDetection(uiTypes, WithDataIdentifier(action.Identifier), WithDataIgnoreNotFoundError(action.IgnoreNotFoundError), WithDataIndex(action.Index))
return dExt.TapByUIDetection(
uiTypes,
WithDataIdentifier(action.Identifier),
WithDataIgnoreNotFoundError(action.IgnoreNotFoundError),
WithDataIndex(action.Index),
WithDataScope(dExt.getAbsScope(action.Scope[0], action.Scope[1], action.Scope[2], action.Scope[3])),
)
}
return fmt.Errorf("invalid %s params: %v", ACTION_TapByCV, action.Params)
case ACTION_DoubleTapXY:
Expand Down
1 change: 0 additions & 1 deletion hrp/pkg/uixt/ui_vedem.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func (s *veDEMUIService) FindUI(uiTypes []string, byteSource []byte, options ...
var rects []image.Rectangle
for _, box := range uiResult {
rect = image.Rectangle{
// cvResult.Points 顺序:左上 -> 右上 -> 右下 -> 左下
Min: image.Point{
X: int(box.Point.X),
Y: int(box.Point.Y),
Expand Down

0 comments on commit 030a739

Please sign in to comment.