Kir*_*eck 12 javascript webcam html5
在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
}
Run Code Online (Sandbox Code Playgroud)
我可以调整"视频轨道的属性" video
navigator.mediaDevices.getUserMedia({
video: {
aspectRatio: 1.5,
width: 1280,
},
})
Run Code Online (Sandbox Code Playgroud)
但我不知道如何调整像focalLengthX
或的属性exposureCompensation
.我会在哪里调整那些?
小智 3
我从 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.
}
}
Run Code Online (Sandbox Code Playgroud)
https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/applyConstraints
归档时间: |
|
查看次数: |
396 次 |
最近记录: |