@@ -3,6 +3,7 @@ package blob
3
3
import (
4
4
"image"
5
5
"math"
6
+ "time"
6
7
7
8
uuid "github.com/satori/go.uuid"
8
9
"gocv.io/x/gocv"
@@ -17,6 +18,7 @@ type Blobie struct {
17
18
Diagonal float64
18
19
AspectRatio float64
19
20
Track []image.Point
21
+ TrackTime []time.Time
20
22
maxPointsInTrack int
21
23
isExists bool
22
24
isStillBeingTracked bool
@@ -43,6 +45,7 @@ func NewBlobie(rect image.Rectangle, maxPointsInTrack, classID int, className st
43
45
Diagonal : math .Sqrt (math .Pow (width , 2 ) + math .Pow (height , 2 )),
44
46
AspectRatio : width / height ,
45
47
Track : []image.Point {center },
48
+ TrackTime : []time.Time {time .Now ()},
46
49
maxPointsInTrack : maxPointsInTrack ,
47
50
isExists : true ,
48
51
isStillBeingTracked : true ,
@@ -70,6 +73,7 @@ func NewBlobieDefaults(rect image.Rectangle) *Blobie {
70
73
Diagonal : math .Sqrt (math .Pow (width , 2 ) + math .Pow (height , 2 )),
71
74
AspectRatio : width / height ,
72
75
Track : []image.Point {center },
76
+ TrackTime : []time.Time {time .Now ()},
73
77
maxPointsInTrack : 10 ,
74
78
isExists : true ,
75
79
isStillBeingTracked : true ,
@@ -128,6 +132,7 @@ func (b *Blobie) Update(newb Blobie) {
128
132
b .isExists = true
129
133
// Append new point to track
130
134
b .Track = append (b .Track , newb .Center )
135
+ b .TrackTime = append (b .TrackTime , newb .TrackTime [len (newb .TrackTime )- 1 ])
131
136
// Restrict number of points in track (shift to the left)
132
137
if len (b .Track ) > b .maxPointsInTrack {
133
138
b .Track = b .Track [1 :]
0 commit comments