Skip to content

Commit

Permalink
Provide a way to fill detected objects with their natural colors
Browse files Browse the repository at this point in the history
Provides a way to simply remove the background without changing objects' colors
  • Loading branch information
skycocker committed Aug 7, 2013
1 parent a733281 commit c609583
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Usage
* `output [string]` - id of the canvas element you want the output to be displayed on (defaults to "move")
* `width [integer]` - width of the image captured from the camera (defaults to 640 which is current biggest possibility)
* `height [integer]` - height of the image captured from the camera (defaults to 480 which is current biggest possibility)
* `humanFill [property array object]` - color you want the detected objects to be filled with (defaults to { r: 0, g: 170, b: 242 }, which gives kind of light blue)
* `humanFill [property array object]` - color you want the detected objects to be filled with. You can also set it to { natural: true }, making the objects filled with their natural colors - this way you can simply remove the background (defaults to { r: 0, g: 170, b: 242 }, which gives kind of light blue)
* `step [function]` - callback executed everytime a frame is rendered. Consider it something like a game loop - you can use it to draw something on your output canvas and/or detect its collision with human. This one does not default to anything, but you still don't have to provide it
* `limitX [integer]` - number of X axis pixels checked for motion. Useful if you want to improve performance and need just some part of the area checked for movement (defaults to width)
* `limitY [integer]` - same as above for Y axis (defaults to height)
Expand Down
16 changes: 14 additions & 2 deletions move.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ Released under the terms of GNU General Public License (version 3 or later) (htt

var current = lightnessValue(data[index], data[index+1], data[index+2]);

if(move.humanFill.natural) {
move.humanFill.r = data[index];
move.humanFill.g = data[index+1];
move.humanFill.b = data[index+2];
}

outData[rawOffset] =
(255 * lightnessHasChanged(rawOffset, current) << 24) | //a
(move.humanFill.b << 16) | //b
Expand All @@ -168,8 +174,14 @@ Released under the terms of GNU General Public License (version 3 or later) (htt
var index = rawOffset * 4;

var current = lightnessValue(data[index], data[index+1], data[index+2]);

outData[rawOffset] =

if(move.humanFill.natural) {
move.humanFill.r = data[index];
move.humanFill.g = data[index+1];
move.humanFill.b = data[index+2];
}

outData[rawOffset] =
(move.humanFill.r << 24) | //r
(move.humanFill.g << 16) | //g
(move.humanFill.b << 8) | //b
Expand Down

0 comments on commit c609583

Please sign in to comment.