捕获高分辨率视频/图像html5

前端之家收集整理的这篇文章主要介绍了捕获高分辨率视频/图像html5前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用geUserMedia()从网络摄像头 Intro捕获图像.

我得到的最佳分辨率是640 X 480,但我有高清网络摄像头
用1280 X 720录制视频,
拍照2592 X 1944.

如何拍摄高分辨率照片?

这是一个代码示例.它不关心画布大小:

<video autoplay id="vid" style="display:none;"></video>
<canvas id="canvas" width="1280" height="720" style="border:1px solid #d3d3d3;"></canvas><br>
<button onclick="snapshot()">Take Picture</button>

<script type="text/javascript">
    var video = document.querySelector("#vid");
    var canvas = document.querySelector('#canvas');
    var ctx = canvas.getContext('2d');
    var localMediaStream = null;

    var onCameraFail = function (e) {
        console.log('Camera did not work.',e);
    };

    function snapshot() {
        if (localMediaStream) {
            ctx.drawImage(video,0);
        }
    }

    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
    window.URL = window.URL || window.webkitURL;
    navigator.getUserMedia({video:true},function (stream) {
        video.src = window.URL.createObjectURL(stream);
        localMediaStream = stream;
    },onCameraFail);

</script>

解决方法

http://www.html5rocks.com/en/tutorials/getusermedia/intro/

=>设置媒体约束(分辨率,高度,宽度)

原文链接:https://www.f2er.com/html5/168153.html

猜你在找的HTML5相关文章