Search
 
SCRIPT & CODE EXAMPLE
 

HTML

capture webcam js

<button id="start-camera">Start Camera</button>
<video id="video" width="320" height="240" autoplay></video>
<button id="click-photo">Click Photo</button>
<canvas id="canvas" width="320" height="240"></canvas>
<script>
let camera_button = document.querySelector("#start-camera");
let video = document.querySelector("#video");
let click_button = document.querySelector("#click-photo");
let canvas = document.querySelector("#canvas");

camera_button.addEventListener('click', async function() {
   	let stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: false });
	video.srcObject = stream;
});

click_button.addEventListener('click', function() {
   	canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
   	let image_data_url = canvas.toDataURL('image/jpeg');

   	// data url of the image
   	console.log(image_data_url);
});>
</script>
Comment

PREVIOUS NEXT
Code Example
Html :: como añadir bootstrap a html 
Html :: differences between html and xhtml 
Html :: how to save time writing html 
Html :: tailwind resize none 
Html :: html redirect after alert 
Html :: links html 
Html :: align div in html 
Html :: html table title 
Html :: how to create an html button that acts like a link 
Html :: gradient background css for all browsers 
Html :: how to innerhtml is empty 
Html :: html upload image accept only few types 
Html :: bootstrap input 
Html :: html video player 
Html :: input type text inside select option 
Html :: placeholder text html 
Html :: html table basics 
Html :: html img src background 
Html :: html code for writing text 
Html :: table bootstrap with scrool 
Html :: how to add text on top of an image 
Html :: html basic website 
Html :: convert gene id to gene symbol in R 
Html :: tailwind negative margin 
Html :: chrome input autocomplete not working 
Html :: how to highlight text in html 
Html :: vuejs v-on 
Html :: label input html 
Html :: input field with add button that creates another input 
Html :: bold text in html 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =