gpt4 book ai didi

javascript - 我将如何实现图像轨道设置

转载 作者:技术小花猫 更新时间:2023-10-29 12:43:09 25 4
gpt4 key购买 nike

https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints有一个部分称为“图像轨道的属性”。我将如何调整这些设置?

当我运行 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下的“Properties of video tracks”

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

但我不确定如何调整 focalLengthXexposureCompensation 等属性。我应该在哪里调整这些?

最佳答案

我从 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.
}
}

https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/applyConstraints

关于javascript - 我将如何实现图像轨道设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48045030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com