Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document specific settings for a takePicture() method to be defined as part of the Media Capture specification.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
Comments on this document are welcomed.
This document was published by the Media Capture Task Force as an Editor's Draft. If you wish to make comments regarding this document, please send them to public-media-capture@w3.org (subscribe, archives). All feedback is welcome.
Publication as an Editor's Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
Various proposals have been provided to the Task Force regarding methods for taking a picture that can extend getUserMedia(). This proposal focused on picture settings that are compatible with the cameras associated with many handheld devices. It leverages the takePicture() method as described in Settings API Version 4.
The takePicture() method is currently defined on a a PictureDeviceTrack according to the cited proposal as follows:
interface PictureDeviceTrack : VideoStreamTrack {
void takePicture ();
attribute EventHandler onpicture;
};
onpicture
of type EventHandlertakePicture
void
For the purposes of this proposal, the main focus is on the PictureDeviceTrack
object and takePicture()
method. In addition, the MediaSettingsRange
is leveraged.
MediaSettingsRange
interface MediaSettingsRange {
readonly attribute any max;
readonly attribute any min;
readonly attribute any initial;
void request (any value, optional boolean mandatory);
};
initial
of type any, readonlymax
of type any, readonlymin
of type any, readonlyrequest
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
value | any | ✘ | ✘ | |
mandatory | boolean | ✘ | ✔ |
void
MediaSettingsItem
The MediaSettingsItem
interface is now defined, which allows for a single setting to be managed.
interface MediaSettingsItem {
readonly attribute any value;
readonly attribute any initial;
void request (any value, optional boolean mandatory);
};
initial
of type any, readonlyvalue
of type any, readonlyrequest
Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
value | any | ✘ | ✘ | |
mandatory | boolean | ✘ | ✔ |
void
PictureSettings
A new object PictureSettings is defined to control the settings for takePicture(). PictureDeviceTrack
implements PictureSettings.
The PictureSettings interface must be supported by the User Agent. However, any settings in this object that are not supported by the User Agent or selected camera may be ignored.
interface PictureSettings {
attribute MediaSettingsItem
whiteBalanceMode;
attribute MediaSettingsItem
autoExposureMode;
attribute MediaSettingsRange
exposureCompensation;
attribute MediaSettingsItem
iso;
attribute MediaSettingsItem
redEyeReduction;
attribute MediaSettingsRange
brightness;
attribute MediaSettingsRange
constrast;
attribute MediaSettingsRange
saturation;
attribute MediaSettingsRange
sharpness;
};
autoExposureMode
of type MediaSettingsItem
ExposureModeEnum
.brightness
of type MediaSettingsRange
constrast
of type MediaSettingsRange
exposureCompensation
of type MediaSettingsRange
iso
of type MediaSettingsItem
ISOModeEnum
.redEyeReduction
of type MediaSettingsItem
saturation
of type MediaSettingsRange
sharpness
of type MediaSettingsRange
whiteBalanceMode
of type MediaSettingsItem
WhiteBalanceModeEnum
.WhiteBalanceModeEnum
enum WhiteBalanceModeEnum {
"auto",
"incandescent",
"fluorescent",
"warm-fluorescent",
"daylight",
"cloudy-daylight",
"twilight",
"shade"
};
Enumeration description | |
---|---|
auto | |
incandescent | |
fluorescent | |
warm-fluorescent | |
daylight | |
cloudy-daylight | |
twilight | |
shade |
ExposureModeEnum
enum ExposureModeEnum {
"frame-average",
"center-weighted",
"spot-metering"
};
Enumeration description | |
---|---|
frame-average | |
center-weighted | |
spot-metering |
ISOModeEnum
enum ISOModeEnum {
"auto",
"100",
"200",
"400",
"800",
"1250"
};
Enumeration description | |
---|---|
auto | |
100 | |
200 | |
400 | |
800 | |
1250 |
navigator.getUserMedia({video: true}, gotMedia, failedToGetMedia); function gotMedia(mediastream) { var videoDevice = mediastream.videoTracks[0]; // Check if this device supports a picture mode... var pictureDevice = videoDevice.pictureDeviceTrack; if (pictureDevice) { pictureDevice.onpicture = showPicture; if (pictureDevice.redEyeReduction) { pictureDevice.redEyeReduction.request(true,true); } else console.log('No red eye reduction'); pictureDevice.takePicture(); } } function showPicture(e) { var img = document.querySelector("img"); img.src = URL.createObjectURL(e.data); } function failedToGetMedia{ console.log('Stream failure'); }