2017-12-31 233 views
12

https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraintsに「画像トラックのプロパティ」というセクションがあります。これらの設定はどうすれば調整できますか?イメージトラックの設定方法を教えてください

私はnavigator.mediaDevices.getSupportedConstraints()を実行すると、私は次を得る:私はvideo

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

下の「ビデオトラックのプロパティ」を調整することができます

{ 
    "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 
} 

しかし、私はfocalLengthXなどのプロパティを調整するかどうかはわかりませんまたはexposureCompensation。どこで調整するのですか?

+0

あなたは '.getUserMedia()'に渡されるオブジェクトのプロパティと値を設定しようとしたことがありますか? – guest271314

答えて

2

MSNから、プロセスを説明するドキュメントが見つかりました。基本的に、許容値の最小値と最大値を、最小値と最大値で指定できます。制約オプションオブジェクトに追加された値のみが変更されます。

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

関連する問題