Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何选择qrscan摄像机_Html_Api_Camera - Fatal编程技术网

Html 如何选择qrscan摄像机

Html 如何选择qrscan摄像机,html,api,camera,Html,Api,Camera,选择相机进行qrcode扫描的最佳策略是什么? 目前,现代设备很少有后置摄像头。 例如,华为mate 20有4个摄像头(3个物理摄像头和1个基于物理摄像头的虚拟摄像头) 目前我的算法只是选择第一个标签上有“back”的相机。 有没有更好的策略来提高二维码的可读性 这是我的密码: this.qrScannerComponent.getMediaDevices().then(devices => { // this.info = devices.map((dev, i) => `$

选择相机进行qrcode扫描的最佳策略是什么? 目前,现代设备很少有后置摄像头。 例如,华为mate 20有4个摄像头(3个物理摄像头和1个基于物理摄像头的虚拟摄像头) 目前我的算法只是选择第一个标签上有“back”的相机。 有没有更好的策略来提高二维码的可读性

这是我的密码:

this.qrScannerComponent.getMediaDevices().then(devices => {
  // this.info = devices.map((dev, i) => `${i}. ${dev.label}`).join('\n');

  const videoDevices: MediaDeviceInfo[] = [];
  for (const device of devices) {
    if (device.kind.toString() === 'videoinput') {
        videoDevices.push(device);
    }
  }
  if (videoDevices.length > 0) {
    let choosenDev;
    for (const dev of videoDevices) {
      if (dev.label.includes('back')) {
        choosenDev = dev;
        break;
      }
    }
    if (choosenDev) {
      this.qrScannerComponent.chooseCamera.next(choosenDev);
    } else {
      this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
    }
  }
});