Created
April 26, 2015 16:07
-
-
Save Javvadilakshman/87faed8d5a610a9d7ad0 to your computer and use it in GitHub Desktop.
HTML Snippts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HTML Snippts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!--Based on Code from http://blog.teamtreehouse.com/accessing-the-device-camera-with-getusermedia--> | |
| <title>Basic Webcam Video Stream to Canvas - with Effects - FX</title> | |
| <style> | |
| body { | |
| background: #F7F7F7; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| #video-container { | |
| margin: 2em auto 0; | |
| width: 500px; | |
| padding: 2em; | |
| background: white; | |
| -webkit-box-shadow: 0 1px 10px #D9D9D9; | |
| -moz-box-shadow: 0 1px 10px #D9D9D9; | |
| -ms-box-shadow: 0 1px 10px #D9D9D9; | |
| -o-box-shadow: 0 1px 10px #D9D9D9; | |
| box-shadow: 0 1px 10px #D9D9D9; | |
| } | |
| #camera-stream { | |
| //-webkit-filter: sepia(1); | |
| //-webkit-filter: blur(3px); | |
| //-webkit-filter: grayscale(1); | |
| //-webkit-filter: sepia(1); | |
| //-webkit-filter: brightness(2.5); | |
| //-webkit-filter: contrast(5); | |
| //-webkit-filter: hue-rotate(125deg); | |
| //-webkit-filter: invert(1); | |
| //-webkit-filter: saturate(3); | |
| //-webkit-filter: opacity(0.3); | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="video-container"> | |
| <video id="camera-stream" width="500" autoplay></video> | |
| </div> | |
| <script> | |
| window.onload = function() { | |
| // Normalize the various vendor prefixed versions of getUserMedia. | |
| navigator.getUserMedia = (navigator.getUserMedia || | |
| navigator.webkitGetUserMedia || | |
| navigator.mozGetUserMedia || | |
| navigator.msGetUserMedia); | |
| if (navigator.getUserMedia) { | |
| // Request the camera. | |
| navigator.getUserMedia( | |
| // Constraints | |
| { | |
| video: true | |
| }, | |
| // Success Callback | |
| function(localMediaStream) { | |
| // Get a reference to the video element on the page. | |
| var vid = document.getElementById('camera-stream'); | |
| // Create an object URL for the video stream and use this | |
| // to set the video source. | |
| vid.src = window.URL.createObjectURL(localMediaStream); | |
| }, | |
| // Error Callback | |
| function(err) { | |
| // Log the error to the console. | |
| console.log('The following error occurred when trying to use getUserMedia: ' + err); | |
| } | |
| ); | |
| } else { | |
| alert('Sorry, your browser does not support getUserMedia'); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment