mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
feat: tap random point in ocr text rect
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"image"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"regexp"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -96,6 +97,17 @@ func (t OCRText) Center() PointF {
|
||||
return point
|
||||
}
|
||||
|
||||
func (t OCRText) RandomPoint() PointF {
|
||||
rect := t.Rect
|
||||
x, y := float64(rect.Min.X), float64(rect.Min.Y)
|
||||
width, height := float64(rect.Dx()), float64(rect.Dy())
|
||||
point := PointF{
|
||||
X: x + width*rand.Float64(),
|
||||
Y: y + height*rand.Float64(),
|
||||
}
|
||||
return point
|
||||
}
|
||||
|
||||
type OCRTexts []OCRText
|
||||
|
||||
func (t OCRTexts) texts() (texts []string) {
|
||||
|
||||
Reference in New Issue
Block a user