Skip to content

Commit 0bdf684

Browse files
committed
adding yellow to color module
1 parent 54de660 commit 0bdf684

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

examples/hello_world.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
var t1 = videoCamera.track({
3333
type: 'color',
34-
color: 'magenta',
34+
color: 'yellow',
3535
onFound: function(track) {
3636
console.log(track.x + track.y + track.z);
3737
},

src/tracker/color/color.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@
4343
return Math.sqrt(dx*dx + dy*dy + dz*dz) < 140;
4444
},
4545

46+
yellow: function(r, g, b) {
47+
var threshold = 50,
48+
dx = r-255,
49+
dy = g-255,
50+
dz = b-0;
51+
52+
if ((r - g) >= threshold && (b - g) >= threshold) {
53+
return true;
54+
}
55+
56+
return Math.sqrt(dx*dx + dy*dy + dz*dz) < 100;
57+
},
58+
4659
findCoordinates_: function(pixels, total) {
4760
var instance = this,
4861
dx = 0,

0 commit comments

Comments
 (0)