Is there a way to capture images from a webcam with JavaScript?
If your PC has a built-in camera or a connected webcam, you can use the Camera app to take photos and videos. To find the Camera app, select Start > Camera.
Taking Pictures with your Logitech QuickCamDouble-click the Logitech QuickCam icon on your desktop to access the Logitech QuickCam software. NOTE: You can also access the Logitech QuickCam software by double-clicking the icon in your system tray. In the Logitech QuickCam menu bar, click on the Quick Capture button.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With