@@ -219,7 +219,7 @@ func (b *KalmanBlobie) SetDraw(drawOptions *DrawOptions) {
219219}
220220
221221// DrawTrack Draws blob's track [KalmanBlobie]
222- func (b * KalmanBlobie ) DrawTrack (mat * gocv.Mat , optionalText string ) {
222+ func (b * KalmanBlobie ) DrawTrack (mat * gocv.Mat , optionalText ... string ) {
223223 if b .drawingOptions == nil {
224224 b .drawingOptions = NewDrawOptionsDefault ()
225225 }
@@ -228,12 +228,16 @@ func (b *KalmanBlobie) DrawTrack(mat *gocv.Mat, optionalText string) {
228228 for i := range b .Track {
229229 gocv .Circle (mat , b .Track [i ], b .drawingOptions .CentroidColor .Radius , b .drawingOptions .CentroidColor .Color , b .drawingOptions .CentroidColor .Thickness )
230230 }
231- if optionalText != "" {
232- pt := image .Pt (b .CurrentRect .Min .X , b .CurrentRect .Min .Y )
233- textSize := gocv .GetTextSize (optionalText , b .drawingOptions .TextColor .Font , b .drawingOptions .TextColor .Scale , b .drawingOptions .TextColor .Thickness )
234- textRect := image.Rectangle {Min : image.Point {X : pt .X , Y : pt .Y - textSize .Y }, Max : image.Point {X : pt .X + textSize .X , Y : pt .Y }}
235- gocv .Rectangle (mat , textRect , b .drawingOptions .BBoxColor .Color , b .drawingOptions .BBoxColor .Thickness )
236- gocv .PutText (mat , optionalText , pt , b .drawingOptions .TextColor .Font , b .drawingOptions .TextColor .Scale , b .drawingOptions .TextColor .Color , b .drawingOptions .TextColor .Thickness )
231+ shiftTextY := 10
232+ for i := len (optionalText ) - 1 ; i >= 0 ; i -- {
233+ text := optionalText [i ]
234+ if text != "" {
235+ anchor := image .Pt (b .CurrentRect .Min .X , b .CurrentRect .Min .Y - i * shiftTextY )
236+ textSize := gocv .GetTextSize (text , b .drawingOptions .TextColor .Font , b .drawingOptions .TextColor .Scale , b .drawingOptions .TextColor .Thickness )
237+ textRect := image.Rectangle {Min : image.Point {X : anchor .X , Y : anchor .Y - textSize .Y }, Max : image.Point {X : anchor .X + textSize .X , Y : anchor .Y }}
238+ gocv .Rectangle (mat , textRect , b .drawingOptions .BBoxColor .Color , b .drawingOptions .BBoxColor .Thickness )
239+ gocv .PutText (mat , text , anchor , b .drawingOptions .TextColor .Font , b .drawingOptions .TextColor .Scale , b .drawingOptions .TextColor .Color , b .drawingOptions .TextColor .Thickness )
240+ }
237241 }
238242 }
239243}
0 commit comments