Advertisement
BrU32

JS Webcam FLIR Check If Person Is In Frame SRC FINAL V5!!!!!

Feb 1st, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <style>
  2. body{
  3. overflow: visible;
  4. position:center;
  5.  
  6. filter:invert(0.9);
  7. }
  8. .container{
  9. position: center;
  10. width: Math.random()*5vmax+1vmax;
  11. height: Math.random()*15vmax+10vmax;
  12.  
  13. }
  14. </style>
  15. <center>
  16. <body bgcolor="black" onchange="setInterval(snapshot,33);">
  17. <video id="video" width="640" height="640" autoplay></video>
  18. <button id="snapshot" class="Button" onclick="snapshot">Snapshot Image</button>
  19. <canvas id="canvas" width="640" height="640"></canvas>
  20. <script>
  21. window.addEventListener("DOMContentLoaded", function() {
  22. var canvas = document.getElementById('canvas');
  23. var context = canvas.getContext('2d');
  24. var video = document.getElementById('video');
  25. var mediaConfig = { video: true,audio:false};
  26. var errBack = function(e) {
  27. console.log('An error has occurred!', e)
  28. };
  29. if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  30. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  31. video.src = window.URL.createObjectURL(stream);
  32. video.play();
  33.  
  34.  
  35. });
  36. }
  37. else if(navigator.getUserMedia) {
  38. navigator.getUserMedia(mediaConfig, function(stream) {
  39. video.src = stream;
  40. video.play();
  41. video.src = window.URL.createObjectURL(stream);
  42. video.play();
  43. ctt=getBase64Image(video);
  44.  
  45. }, errBack);
  46. }
  47. document.getElementById('snapshot').addEventListener('mouseup', function() {
  48. var cct=getBase64Image(video)
  49. var ctt=getBase64Image(video);
  50.  
  51. context.drawImage(video, 0, 0, 640, 640);
  52. ctt=getBase64Image(video);
  53. if(ctt<=599999){
  54. alert("Person Is Hidden!!")
  55. }else{
  56. alert('Person is Visible!!')
  57. }
  58. });
  59. }, false);
  60. function getBase64Image(img) {
  61. var canvas = document.createElement("canvas");
  62. canvas.width = img.width;
  63. canvas.height = img.height;
  64. var ctx = canvas.getContext("2d");
  65. ctx.drawImage(img, 0, 0);
  66. var dataURL = canvas.toDataURL("image/png");
  67. return dataURL.length-4000;
  68. }
  69.  
  70. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement