ImageCapture 未定义
ImageCapture is not defined
我正在尝试执行这段代码:
const canvas = document.querySelector('canvas');
var interval;
var track;
navigator.mediaDevices.getUserMedia({video: true})
.then(gotMedia)
.catch(err => console.error('getUserMedia() failed: ', err));
function gotMedia(mediastream) {
track = mediastream.getVideoTracks()[0];
var imageCapture = new ImageCapture(track);
interval = setInterval(function () {
imageCapture.grabFrame()
.then(processFrame)
.catch(err => console.error('grabFrame() failed: ', err));
}, 1000);
}
function processFrame(imgData) {
canvas.width = imgData.width;
canvas.height = imgData.height;
canvas.getContext('2d').drawImage(imgData, 0, 0);
}
function stopGrabFrame(e) {
clearInterval(interval);
track.stop();
}
从我的网络摄像头拍摄实时视频的快照,但它失败了,浏览器的控制台显示以下内容:
getUserMedia() 失败:ReferenceError:ImageCapture 未在 gotMedia
处定义
这是否意味着我的网络浏览器 (Google Chrome) 不支持 ImageCapture?我可以修复它吗?
ImageCapture specification is not implemented in any browser yet, except behind a flag.
我正在尝试执行这段代码:
const canvas = document.querySelector('canvas');
var interval;
var track;
navigator.mediaDevices.getUserMedia({video: true})
.then(gotMedia)
.catch(err => console.error('getUserMedia() failed: ', err));
function gotMedia(mediastream) {
track = mediastream.getVideoTracks()[0];
var imageCapture = new ImageCapture(track);
interval = setInterval(function () {
imageCapture.grabFrame()
.then(processFrame)
.catch(err => console.error('grabFrame() failed: ', err));
}, 1000);
}
function processFrame(imgData) {
canvas.width = imgData.width;
canvas.height = imgData.height;
canvas.getContext('2d').drawImage(imgData, 0, 0);
}
function stopGrabFrame(e) {
clearInterval(interval);
track.stop();
}
从我的网络摄像头拍摄实时视频的快照,但它失败了,浏览器的控制台显示以下内容:
getUserMedia() 失败:ReferenceError:ImageCapture 未在 gotMedia
处定义这是否意味着我的网络浏览器 (Google Chrome) 不支持 ImageCapture?我可以修复它吗?
ImageCapture specification is not implemented in any browser yet, except behind a flag.