【问题标题】:How to add webcam selection to official mediapipe face detection solution?如何将网络摄像头选择添加到官方 mediapipe 人脸检测解决方案?
【发布时间】:2021-10-24 13:47:33
【问题描述】:

https://google.github.io/mediapipe/solutions/face_detection#javascript-solution-api

这是通过 Google 使用 mediapipeface detection 添加到网站上的网络摄像头提要的最简单方法。

我的笔记本电脑也有inbuilt webcam 和一台OBS virtual webcam。当我在笔记本电脑上尝试此示例代码时,有时虚拟网络摄像头会被我的网页随机拾取。

如何将网络摄像头选择添加到此示例代码中,以避免自动选择虚拟网络摄像头?

【问题讨论】:

    标签: 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-22
      • 2014-08-23
      • 1970-01-01
      • 2014-05-29
      • 2017-10-07
      • 1970-01-01
      • 2012-11-06
      • 2019-11-11
      相关资源
      最近更新 更多