Skip to content

Commit 695684f

Browse files
committed
Adds a maxDimension feature to ColorTracker. mergeRectangle returns rectangles that satisfy minDimension and maxDimension requirement
1 parent 5688e2e commit 695684f

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/trackers/ColorTracker.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@
142142
return this.minDimension;
143143
};
144144

145+
/**
146+
* Sets the maximum dimension to classify a rectangle.
147+
* @param {number} maxDimension
148+
*/
149+
tracking.ColorTracker.prototype.getMaxDimension = function() {
150+
return this.maxDimension;
151+
}
152+
145153
/**
146154
* Gets the minimum group size to be classified as a rectangle.
147155
* @return {number}
@@ -187,6 +195,8 @@
187195
var intersects;
188196
var results = [];
189197
var minDimension = this.getMinDimension();
198+
var maxDimension = this.getMaxDimension();
199+
190200
for (var r = 0; r < rects.length; r++) {
191201
var r1 = rects[r];
192202
intersects = true;
@@ -205,12 +215,16 @@
205215
break;
206216
}
207217
}
218+
208219
if (intersects) {
209220
if (r1.width >= minDimension && r1.height >= minDimension) {
210-
results.push(r1);
221+
if (r1.width <= maxDimension && r1.height <= maxDimension) {
222+
results.push(r1);
223+
}
211224
}
212225
}
213226
}
227+
214228
return results;
215229
};
216230

@@ -230,6 +244,14 @@
230244
this.minDimension = minDimension;
231245
};
232246

247+
/**
248+
* Sets the maximum dimension to classify a rectangle.
249+
* @return {number}
250+
*/
251+
tracking.ColorTracker.prototype.setMaxDimension = function(maxDimension) {
252+
this.maxDimension = maxDimension;
253+
}
254+
233255
/**
234256
* Sets the minimum group size to be classified as a rectangle.
235257
* @param {number} minGroupSize

0 commit comments

Comments
 (0)