0

嗨,我正在研究 springMVC。在我的项目中,我想使用 html5 通过网络摄像头拍摄图像,但我得到了图像,但是我对此做了什么,我不知道这意味着我想将此图像上传到 google app blobstore 我该怎么做任何人帮助我请检查我的示例代码

<video autoplay id="vid" style="display:none;"></video>


拍照片

<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, 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);

4

0 回答 0