Closed rafaelfaria closed 11 years ago
You can use getWhitebalance-function in whitebalance.js for checking the "average luminance"-level in the canvas. It will return a value between 0 and 255, where 0 is pitch black and 255 is all white. So for video, you could copy the video to a canvas and check that the value is above or below a threshold:
var grayLevel = headtrackr.getWhitebalance(canvas);
if (grayLevel < 30) {
// too dark
} else if (grayLevel > 220) {
// too bright
} else {
// ok!
// do something....
}
The choice of thresholds here was a bit arbitrary, 30 is probably too dark and 220 too bright... :)
Great! thanks! :)
On Wed, Oct 17, 2012 at 10:02 AM, Audun Mathias Øygard < notifications@github.com> wrote:
You can use getWhitebalance-function in whitebalance.js for checking the "average luminance"-level in the canvas. It will return a value between 0 and 255, where 0 is pitch black and 255 is all white. So for video, you could copy the video to a canvas and check that the value is above or below a threshold:
var grayLevel = headtrackr.getWhitebalance(canvas); if (grayLevel < 30) { // too dark } else if (grayLevel > 220) { // too bright } else { // ok! // do something.... }
The choice of thresholds here was a bit arbitrary, 30 is probably too dark and 220 too bright... :)
— Reply to this email directly or view it on GitHubhttps://github.com/auduno/headtrackr/issues/4#issuecomment-9510321.
Hey mate.
Is there any way to detect if it's too dark? or too bright?!
Lets say someone is using the webcam but the lights are off, is there any way to tell there isnt too much light to use the facetrackr?
thanks