Javascript 如何实现图像轨迹设置

Javascript 如何实现图像轨迹设置,javascript,html,webcam,Javascript,Html,Webcam,在这里有一个叫做“图像轨迹属性”的部分。我该如何调整这些设置 当我运行navigator.mediaDevices.getSupportedConstraints()时,我得到以下信息: { "aspectRatio": true, "brightness": true, "channelCount": true, "colorTemperature": true, "contrast": true, "depthFar": true, "depthNear": tr

在这里有一个叫做“图像轨迹属性”的部分。我该如何调整这些设置

当我运行navigator.mediaDevices.getSupportedConstraints()时,我得到以下信息:

{
  "aspectRatio": true,
  "brightness": true,
  "channelCount": true,
  "colorTemperature": true,
  "contrast": true,
  "depthFar": true,
  "depthNear": true,
  "deviceId": true,
  "echoCancellation": true,
  "exposureCompensation": true,
  "exposureMode": true,
  "facingMode": true,
  "focalLengthX": true,
  "focalLengthY": true,
  "focusMode": true,
  "frameRate": true,
  "groupId": true,
  "height": true,
  "iso": true,
  "latency": true,
  "pointsOfInterest": true,
  "sampleRate": true,
  "sampleSize": true,
  "saturation": true,
  "sharpness": true,
  "torch": true,
  "videoKind": true,
  "volume": true,
  "whiteBalanceMode": true,
  "width": true,
  "zoom": true
}
我可以在
video

navigator.mediaDevices.getUserMedia({
  video: {
    aspectRatio: 1.5,
    width: 1280,
  },
})

但我不知道如何调整属性,如
focalLength x
exposureCompensation
。我应该在哪里进行调整?

在MDN中,我找到了一些描述流程的文档。基本上,您可以使用每个约束的最小值和最大值来指定最小值和最大可接受值。将仅更改添加到约束选项对象的值

  const constraints = {
  width: {min: 640, ideal: 1280, max: 1920},
  height: {min: 480, ideal: 720}
};

navigator.mediaDevices.getUserMedia({ video: true })
.then(mediaStream => {
  const track = mediaStream.getVideoTracks()[0];
  track.applyConstraints(constraints)
  .then(() => {
    // Do something with the track such as using the Image Capture API.
  }
  .catch(e => {
    // The constraints could not be satisfied by the available devices.
  }
}

您是否尝试过在传递给
.getUserMedia()
的对象上设置属性和值?