feat: tap random point in ocr text rect

This commit is contained in:
lilong.129
2025-03-17 15:36:35 +08:00
parent 7f69052be6
commit b34a2218fe
6 changed files with 36 additions and 3 deletions

View File

@@ -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) {