Taken from a MDN article about webrtc, I used this to take a photo. Once the photo has been taken I will get the dominant colour using color-thief and set the background colour with this.

The screen capture will appear in this box.

Visit our article Taking still photos with WebRTC to learn more about the technologies used here.