feat: get ocr position by given recognition area

This commit is contained in:
xucong.053
2022-10-15 23:50:31 +08:00
parent a413197ae6
commit 70ade716eb
5 changed files with 116 additions and 36 deletions

View File

@@ -28,8 +28,8 @@ func (dExt *DriverExt) TapXY(x, y float64, identifier string) error {
return dExt.TapAbsXY(x, y, identifier)
}
func (dExt *DriverExt) GetTextXY(ocrText string, index ...int) (point PointF, err error) {
x, y, width, height, err := dExt.FindTextByOCR(ocrText, index...)
func (dExt *DriverExt) GetTextXY(ocrText string, recognitionArea []float64, index ...int) (point PointF, err error) {
x, y, width, height, err := dExt.FindTextByOCR(ocrText, recognitionArea, index...)
if err != nil {
return PointF{}, err
}
@@ -41,8 +41,8 @@ func (dExt *DriverExt) GetTextXY(ocrText string, index ...int) (point PointF, er
return point, nil
}
func (dExt *DriverExt) GetTextXYs(ocrText []string) (points []PointF, err error) {
ps, err := dExt.FindTextsByOCR(ocrText)
func (dExt *DriverExt) GetTextXYs(ocrText []string, recognitionArea []float64) (points []PointF, err error) {
ps, err := dExt.FindTextsByOCR(ocrText, recognitionArea)
if err != nil {
return nil, err
}
@@ -71,8 +71,8 @@ func (dExt *DriverExt) GetImageXY(imagePath string, index ...int) (point PointF,
return point, nil
}
func (dExt *DriverExt) TapByOCR(ocrText string, identifier string, ignoreNotFoundError bool, index ...int) error {
point, err := dExt.GetTextXY(ocrText, index...)
func (dExt *DriverExt) TapByOCR(ocrText string, identifier string, ignoreNotFoundError bool, recognitionArea []float64, index ...int) error {
point, err := dExt.GetTextXY(ocrText, recognitionArea, index...)
if err != nil {
if ignoreNotFoundError {
return nil