Capture image from camera video feed into a canvas element, a Context2D instance, or an instance of ImageData

StackOverflow https://stackoverflow.com/questions/22290479

Question

I'm having trouble finding an example of how to capture an image from a camera video feed that works.

I've found this great example and this great one that gets me most of the way, but the image capture part fails.

How can an image be grabbed from a webcam video feed and placed in a canvas element, a Context2D instance, or an instance of ImageData?

Était-ce utile?

La solution

You can use the canvas element. Try the code below:

var video = document.getElementById('myVideo');
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);

This article might help.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top