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

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

質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top