How can I get the webcam video on the left to be in the same format as the right where the image is drawn?

Had this problem for a while and can't figure it out!

[![enter image description here](https://i.stack.imgur.com/NDvXz.png)](https://i.stack.imgur.com/NDvXz.png)

here's the code:

```
document.getElementById('capture').addEventListener('click', function() {
    var w = video.videoWidth;
    var h = video.videoHeight;
    canvas.width = w;
    canvas.height = h;
    context.drawImage(video,0,0,w,h);
    canvas.style.display='block';

});

```