Taking still photos with getUserMedia() - Web APIs | MDN

This article shows how to use navigator.mediaDevices.getUserMedia() to access the camera on a computer or mobile phone with getUserMedia() support and take a photo with it.