Skip to content

Commit 925ba46

Browse files
committed
setter/getter custom props
1 parent b42b9ad commit 925ba46

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

v2/blob/blob.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type Blobie interface {
1818
GetDiagonal() float64
1919
GetClassID() int
2020
GetClassName() string
21+
GetPropetry(key string) (interface{}, bool)
22+
SetPropetry(key string, value interface{})
2123
Exists() bool
2224
NoMatchTimes() int
2325
IncrementNoMatchTimes()

v2/blob/kalman_blob.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ type KalmanBlobie struct {
3131
noMatchTimes int
3232
PredictedNextPosition image.Point
3333

34-
classID int
35-
className string
34+
classID int
35+
className string
36+
customProperties map[string]interface{}
3637

3738
// Kalman filter wrapping
3839
pointTracker *kf.PointTracker
@@ -213,6 +214,15 @@ func (b *KalmanBlobie) GetClassName() string {
213214
return b.className
214215
}
215216

217+
func (b *KalmanBlobie) GetPropetry(key string) (interface{}, bool) {
218+
v, ok := b.customProperties[key]
219+
return v, ok
220+
}
221+
222+
func (b *KalmanBlobie) SetPropetry(key string, value interface{}) {
223+
b.customProperties[key] = value
224+
}
225+
216226
// SetDraw Sets options for drawing [KalmanBlobie]
217227
func (b *KalmanBlobie) SetDraw(drawOptions *DrawOptions) {
218228
b.drawingOptions = drawOptions

v2/blob/simple_blob.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ type SimpleBlobie struct {
2626
noMatchTimes int
2727
PredictedNextPosition image.Point
2828

29-
classID int
30-
className string
29+
classID int
30+
className string
31+
customProperties map[string]interface{}
3132

3233
// For array tracker
3334
drawingOptions *DrawOptions
@@ -201,6 +202,15 @@ func (b *SimpleBlobie) GetClassName() string {
201202
return b.className
202203
}
203204

205+
func (b *SimpleBlobie) GetPropetry(key string) (interface{}, bool) {
206+
v, ok := b.customProperties[key]
207+
return v, ok
208+
}
209+
210+
func (b *SimpleBlobie) SetPropetry(key string, value interface{}) {
211+
b.customProperties[key] = value
212+
}
213+
204214
// SetDraw Sets options for drawing [SimpleBlobie]
205215
func (b *SimpleBlobie) SetDraw(drawOptions *DrawOptions) {
206216
b.drawingOptions = drawOptions

0 commit comments

Comments
 (0)