开发者

Is there a way to capture images from Webcam?

开发者_Python百科Is there a way to capture images from a webcam with JavaScript?


Nope - think of the security implications!

It is possible with Flash, but the user will see a popup requesting access to their webcam.


If the webcam had a web interface, then in theory it would be possible to just slap an image tag into a page somewhere and point it directly at the cam's snapshot interface:

<img src="http://address.of.webcam.example.com/webcam/capture" />

But otherwise, no. Standard Javascript has no API for accessing a webcam. There's no

var wc = new WebCam();
img = wc.capture();

type calls you can do.


The situation has changed from when this question was originally posted. The getUserMedia API was introduced to allow things like capturing webcam images. You can find tutorials and plugins demonstrating it.

But MDN now says the Navigator.getUserMedia API is deprecated in favour of the experimental API MediaDevices.getUserMedia. The getUserMedia tutorials and plugins don't work on iOS devices - they just don't support it.

The answer at the moment seems to be that there is an HTML API for it, but browser support is patchy and the API is possibly on its way out. You can only use it in Firefox and IE Edge, and in Chrome only from an https domain.

I would like to revive this question and ask if anyone knows of any web API that will successfully capture webcam images in all major browsers and devices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜