| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // These must match with how the video and canvas tags are declared in html. | 5 // These must match with how the video and canvas tags are declared in html. |
| 6 const VIDEO_TAG_WIDTH = 320; | 6 const VIDEO_TAG_WIDTH = 320; |
| 7 const VIDEO_TAG_HEIGHT = 240; | 7 const VIDEO_TAG_HEIGHT = 240; |
| 8 | 8 |
| 9 // Fake video capture background green is of value 135. | 9 // Fake video capture background green is of value 135. |
| 10 const COLOR_BACKGROUND_GREEN = 135; | 10 const COLOR_BACKGROUND_GREEN = 135; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 var accumulatedLuma = 0; | 203 var accumulatedLuma = 0; |
| 204 for (var i = 0; i < pixels.length; i += 4) { | 204 for (var i = 0; i < pixels.length; i += 4) { |
| 205 // Ignore the alpha channel. | 205 // Ignore the alpha channel. |
| 206 accumulatedLuma += rec702Luma_(pixels[i], pixels[i + 1], pixels[i + 2]); | 206 accumulatedLuma += rec702Luma_(pixels[i], pixels[i + 1], pixels[i + 2]); |
| 207 if (accumulatedLuma > threshold * (i / 4 + 1)) | 207 if (accumulatedLuma > threshold * (i / 4 + 1)) |
| 208 return false; | 208 return false; |
| 209 } | 209 } |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 // Checks if the given color is within 1 value away from COLOR_BACKGROUND_GREEN. |
| 214 function isAlmostBackgroundGreen(color) { |
| 215 if (Math.abs(color - COLOR_BACKGROUND_GREEN) > 1) |
| 216 return false; |
| 217 return true; |
| 218 } |
| 219 |
| 213 // Use Luma as in Rec. 709: Y′709 = 0.2126R + 0.7152G + 0.0722B; | 220 // Use Luma as in Rec. 709: Y′709 = 0.2126R + 0.7152G + 0.0722B; |
| 214 // See http://en.wikipedia.org/wiki/Rec._709. | 221 // See http://en.wikipedia.org/wiki/Rec._709. |
| 215 function rec702Luma_(r, g, b) { | 222 function rec702Luma_(r, g, b) { |
| 216 return 0.2126 * r + 0.7152 * g + 0.0722 * b; | 223 return 0.2126 * r + 0.7152 * g + 0.0722 * b; |
| 217 } | 224 } |
| 218 | 225 |
| 219 // This function matches |left| and |right| and fails the test if the | 226 // This function matches |left| and |right| and fails the test if the |
| 220 // values don't match using normal javascript equality (i.e. the hard | 227 // values don't match using normal javascript equality (i.e. the hard |
| 221 // types of the operands aren't checked). | 228 // types of the operands aren't checked). |
| 222 function assertEquals(expected, actual) { | 229 function assertEquals(expected, actual) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 239 devices.forEach(function(device) { | 246 devices.forEach(function(device) { |
| 240 if (device.kind == 'video') | 247 if (device.kind == 'video') |
| 241 hasVideoInputDevice = true; | 248 hasVideoInputDevice = true; |
| 242 }); | 249 }); |
| 243 | 250 |
| 244 if (hasVideoInputDevice) | 251 if (hasVideoInputDevice) |
| 245 sendValueToTest('has-video-input-device'); | 252 sendValueToTest('has-video-input-device'); |
| 246 else | 253 else |
| 247 sendValueToTest('no-video-input-devices'); | 254 sendValueToTest('no-video-input-devices'); |
| 248 }); | 255 }); |
| 249 } | 256 } |
| OLD | NEW |