I have a simple function which draws a video image on a canvas, like this:
setInterval(function() {
localCanvas.getContext('2d').drawImage(localVideo, 0, 0, 250, 150);
}, 0);
However, the images on the canvas, while streaming smoothly, appears slightly blurry. It's even more blurry if the canvas goes to fullscreen. The dimensions are correct, so I know that the dimensions are not the problem (I've tried many different dimensions - all blurry). I've also tried:
localCanvas.getContext('2d').imageSmoothingEnabled = false;
But that give a weird pixelated result. Is there any way to get images on the canvas that look as good as the original video?
Here's the HTML for the objects:
<div id="container" style="box-sizing:border-box;display:flex;flex-direction:row;">
<div style="width:400px;height:300px;">
<video id="localVideo" style="width:90%;height:90%;" autoplay playsinline muted controls></video>
</div>
<div id="canvasContainer" style="position:relative;width:400px;height:300px;">
<canvas id="localCanvas" style="width:100%;height:100%;"></canvas>
<div id="myDiv" style="position:absolute;top:0;left:0;width:100%;height:100%;background:transparent;border:2px solid purple;">
<div style="width:100%;height:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;">
<div style="color:yellow;">test</div>
</div>
</div>
<div style="box-sizing:border-box;display:flex;flex-direction:row;justify-content:space-around;align-items:center;">
<button id="fullscreenButton" onclick="var cvs = document.getElementById('localCanvas'); if(cvs.webkitRequestFullScreen) {cvs.webkitRequestFullScreen();} else {cvs.mozRequestFullScreen();}; return;">Fullscreen</button>
</div>
</div>
</div>