我正在尝试使用ImageCapture API使用 4k Logitech Brio Stream网络摄像头捕获快照。
一切都在我的 Mac 的内置摄像头上运行良好,或者使用网络摄像头的默认视频约束,尽管尝试以更高的分辨率捕获失败,但使用非常通用的platform error
. 我发现的唯一参考来自源代码,这里和这里。
这些链接分别建议capabilities.is_null()
或建议photo_state.is_null()
,尽管我一直无法找到可能导致其中任何一个的原因。
这是我的(略微精简)实现:
// N.B. self is scoped within the code file, and works as it should
const videoConstraints = {
video: {
width: { min: 1280, ideal: 3840, max: 3840 },
height: { min: 720, ideal: 2160, max: 2160 }
}
}
navigator.mediaDevices.getUserMedia(videoConstraints)
.then(function(stream) {
self.imageCapture = new ImageCapture(stream.getVideoTracks()[0]);
})
self.imageCapture.takePhoto()
.then(function(blob) { self.doSomethingWithThe(blob); }) // never gets here because...
.catch(function(e) { console.log(e); }); // here the error is thrown
这适用于内置摄像头,同时切换视频约束以使其{ video: true }
与网络摄像头一起使用,尽管分辨率较低 720 x 1280 分辨率(指定的最小值)。没有自定义更高的分辨率适用于此。
使用 Chrome 作为浏览器。
有谁知道如何开始takePhoto()
拍摄 4k 图像?
我发现很少描述 API 的问题,因此欢迎任何建议或帮助。让我知道问题中是否缺少任何细节。提前致谢。