Advertisement
BrU32

Untitled

Mar 25th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <style>
  2. video{
  3. filter:contrast(24244);
  4. }
  5. canvas{
  6. filter:invert(180%);
  7. }
  8. </style>
  9. <center>
  10. <body bgcolor="black">
  11. <video id="video" width="640" height="480" autoplay></video>
  12.  
  13. <canvas id="canvas" width="640" height="480"></canvas>
  14. <script>
  15. alert('Move The Mouse Around Inside Of The Webcam Image To Check If A Person/Animal Is Visible!!');
  16. document.addEventListener("DOMContentLoaded", function() {
  17. var canvas = document.getElementById('canvas');
  18. var context = canvas.getContext('2d');
  19. var video = document.getElementById('video');
  20. var mediaConfig = { video: true,audio:false};
  21. var errBack = function(e) {
  22. console.log('An error has occurred!', e)
  23. };
  24. if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  25. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  26. video.src = window.URL.createObjectURL(stream);
  27. video.play();
  28.  
  29. });
  30. }
  31. else if(navigator.getUserMedia) {
  32. navigator.getUserMedia(mediaConfig, function(stream) {
  33. video.src = stream;
  34. video.play();
  35.  
  36. }, errBack);
  37. } else if(navigator.webkitGetUserMedia) {
  38. navigator.webkitGetUserMedia(mediaConfig, function(stream){
  39. video.src = window.webkitURL.createObjectURL(stream);
  40. video.play();
  41. }, errBack);
  42. } else if(navigator.mozGetUserMedia) {
  43. navigator.GetUserMedia(mediaConfig, function(stream){
  44. video.src = window.URL.createObjectURL(stream);
  45. video.play();
  46. }, errBack);
  47. }
  48. var cct=getBase64Image(video)
  49. var ctt=getBase64Image(video);
  50. document.addEventListener('keydown', function() {
  51.  
  52.  
  53. ctt=getBase64Image(video);
  54.  
  55.  
  56.  
  57.  
  58. if(ctt>539909){
  59. context.drawImage(video, 0, 0, 640, 480);
  60. }else{
  61. alert('Person In Frame!!');
  62. }
  63.  
  64.  
  65. });
  66. }, false);
  67. function getBase64Image(img) {
  68.  
  69. var canvas = document.createElement("canvas");
  70. canvas.width = img.width;
  71. canvas.height = img.height;
  72.  
  73. var ctx = canvas.getContext("2d");
  74. ctx.drawImage(img, 0, 0);
  75.  
  76. var dataURL = canvas.toDataURL("image/png");
  77.  
  78. return dataURL.length;
  79. }
  80. </script>
  81.  
  82.  
  83. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement