@@ -3,6 +3,7 @@ package blob
33import (
44 "image"
55 "math"
6+ "time"
67
78 uuid "github.com/satori/go.uuid"
89 "gocv.io/x/gocv"
@@ -17,6 +18,7 @@ type Blobie struct {
1718 Diagonal float64
1819 AspectRatio float64
1920 Track []image.Point
21+ TrackTime []time.Time
2022 maxPointsInTrack int
2123 isExists bool
2224 isStillBeingTracked bool
@@ -43,6 +45,7 @@ func NewBlobie(rect image.Rectangle, maxPointsInTrack, classID int, className st
4345 Diagonal : math .Sqrt (math .Pow (width , 2 ) + math .Pow (height , 2 )),
4446 AspectRatio : width / height ,
4547 Track : []image.Point {center },
48+ TrackTime : []time.Time {time .Now ()},
4649 maxPointsInTrack : maxPointsInTrack ,
4750 isExists : true ,
4851 isStillBeingTracked : true ,
@@ -70,6 +73,7 @@ func NewBlobieDefaults(rect image.Rectangle) *Blobie {
7073 Diagonal : math .Sqrt (math .Pow (width , 2 ) + math .Pow (height , 2 )),
7174 AspectRatio : width / height ,
7275 Track : []image.Point {center },
76+ TrackTime : []time.Time {time .Now ()},
7377 maxPointsInTrack : 10 ,
7478 isExists : true ,
7579 isStillBeingTracked : true ,
@@ -128,6 +132,7 @@ func (b *Blobie) Update(newb Blobie) {
128132 b .isExists = true
129133 // Append new point to track
130134 b .Track = append (b .Track , newb .Center )
135+ b .TrackTime = append (b .TrackTime , newb .TrackTime [len (newb .TrackTime )- 1 ])
131136 // Restrict number of points in track (shift to the left)
132137 if len (b .Track ) > b .maxPointsInTrack {
133138 b .Track = b .Track [1 :]
0 commit comments