【问题标题】:How to add webcam selection to official mediapipe face detection solution?如何将网络摄像头选择添加到官方 mediapipe 人脸检测解决方案?
【发布时间】:2021-10-24 13:47:33
【问题描述】:
【问题讨论】:
标签:
javascript
face-detection
mediapipe
obs
virtual-webcam
【解决方案1】:
请试试这个(提供完整文章的链接)
const video = document.getElementById('video');
const button = document.getElementById('button');
const select = document.getElementById('select');
function gotDevices(mediaDevices) {
select.innerHTML = '';
select.appendChild(document.createElement('option'));
let count = 1;
mediaDevices.forEach(mediaDevice => {
if (mediaDevice.kind === 'videoinput') {
const option = document.createElement('option');
option.value = mediaDevice.deviceId;
const label = mediaDevice.label || `Camera ${count++}`;
const textNode = document.createTextNode(label);
option.appendChild(textNode);
select.appendChild(option);
}
});
}
来源:Select Camera Javascript Mediapipe