@@ -111,20 +111,23 @@ func (b *Blobie) DrawTrack(mat *gocv.Mat, optionalText string) {
111
111
}
112
112
113
113
// IsCrossedTheLine - Check if blob crossed the HORIZONTAL line
114
- func (b * Blobie ) IsCrossedTheLine (horizontal int , direction bool ) bool {
114
+ func (b * Blobie ) IsCrossedTheLine (vertical , leftX , rightX int , direction bool ) bool {
115
115
trackLen := len (b .Track )
116
116
if b .isStillBeingTracked == true && trackLen >= 2 && b .crossedLine == false {
117
117
prevFrame := trackLen - 2
118
118
currFrame := trackLen - 1
119
- if direction {
120
- if b .Track [prevFrame ].Y <= horizontal && b .Track [currFrame ].Y > horizontal { // TO us
121
- b .crossedLine = true
122
- return true
123
- }
124
- } else {
125
- if b .Track [prevFrame ].Y > horizontal && b .Track [currFrame ].Y <= horizontal { // FROM us
126
- b .crossedLine = true
127
- return true
119
+ if b .Track [currFrame ].X >= leftX && b .Track [currFrame ].X <= rightX {
120
+ if direction {
121
+
122
+ if b .Track [prevFrame ].Y <= vertical && b .Track [currFrame ].Y > vertical { // TO us
123
+ b .crossedLine = true
124
+ return true
125
+ }
126
+ } else {
127
+ if b .Track [prevFrame ].Y > vertical && b .Track [currFrame ].Y <= vertical { // FROM us
128
+ b .crossedLine = true
129
+ return true
130
+ }
128
131
}
129
132
}
130
133
}
@@ -133,20 +136,22 @@ func (b *Blobie) IsCrossedTheLine(horizontal int, direction bool) bool {
133
136
134
137
// IsCrossedTheLineWithShift - Check if blob crossed the HORIZONTAL line with shift along the Y-axis
135
138
// Purpose of this for "predicative" cropping when detection line very close to bottom of image
136
- func (b * Blobie ) IsCrossedTheLineWithShift (horizontal int , direction bool , shift int ) bool {
139
+ func (b * Blobie ) IsCrossedTheLineWithShift (vertical , leftX , rightX int , direction bool , shift int ) bool {
137
140
trackLen := len (b .Track )
138
141
if b .isStillBeingTracked == true && trackLen >= 2 && b .crossedLine == false {
139
142
prevFrame := trackLen - 2
140
143
currFrame := trackLen - 1
141
- if direction {
142
- if b .Track [prevFrame ].Y <= horizontal && (b .Track [currFrame ].Y + shift ) > horizontal { // TO us
143
- b .crossedLine = true
144
- return true
145
- }
146
- } else {
147
- if b .Track [prevFrame ].Y > horizontal && (b .Track [currFrame ].Y + shift ) <= horizontal { // FROM us
148
- b .crossedLine = true
149
- return true
144
+ if b .Track [currFrame ].X >= leftX && b .Track [currFrame ].X <= rightX {
145
+ if direction {
146
+ if (b .Track [prevFrame ].Y + shift ) <= vertical && (b .Track [currFrame ].Y + shift ) > vertical { // TO us
147
+ b .crossedLine = true
148
+ return true
149
+ }
150
+ } else {
151
+ if (b .Track [prevFrame ].Y + shift ) > vertical && (b .Track [currFrame ].Y + shift ) <= vertical { // FROM us
152
+ b .crossedLine = true
153
+ return true
154
+ }
150
155
}
151
156
}
152
157
}
0 commit comments