Copyright © 2012-2013 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document specific the takePhoto() method and corresponding camera settings or use with MediaStreams as defined in Media Capture and Streams [GETUSERMEDIA].
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.
The API defined in this document taks a valid MediaStream and returns an encoded image in the form of a Blob
(as defined in [FILE-API]). The image is
provided by the capture device that provides the MediaStream. Moreover,
picture-specific settings can be optionally provided as arguments that can be applied to the image being captured.
interface ImageCapture : EventTarget {
readonly attribute PhotoSettingsOptions
photoSettingsOptions;
attribute MediaStream stream;
attribute EventHandler onphoto;
attribute EventHandler onphotoerror;
attribute EventHandler onphotosettingschange;
attribute EventHandler onphotosettingserror;
void setPhotoSettings (PhotoSettings
photoSettings);
void takePhoto (optional DOMString trackID);
};
onphoto
of type EventHandleronphotoerror
of type EventHandleronphotosettingschange
of type EventHandleronphotosettingserror
of type EventHandlerphotoSettingsOptions
of type PhotoSettingsOptions
, readonlystream
of type MediaStreamsetPhotoSettings
setPhotoSettings()
method of an ImageCapture
object is invoked, then
then a valid PhotoSettings
object must be passed in the method to the
UA. If the UA can successfully apply the settings, then the UA must invoke the
onphotosettingschange
(if specified). If the UA cannot successfully apply the settings, then the UA
must invoke the onphotosettingserror
event handler (if specified). Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
photoSettings |
| ✘ | ✘ |
void
takePhoto
takePhoto()
method of an ImageCapture
object is invoked,
then if a trackID
is provided and it is not the
id
of a Track object in stream
's videoTrackList
whose readyState
is "live", the UA must invoke the onphotoerror
event handler (if specified) with a
new PhotoError object whose code
is set to INVALID_TRACK_ID. If a trackID
is not provided then the UA may select a default track in
the stream
to apply the takePhoto()
method. If the UA is unable to select a track, then the UA must invoke the onphotoerror
event handler (if specified) with a
new PhotoError object whose code
is set to PHOTO_ERROR.
Otherwise it must
queue a task, using the DOM manipulation task source, that runs the following steps:
Blob
containing a single still image. The method of doing
this will depend on the underlying device. Some devices may just do a frame grab, while others
may temporarily stop streaming data, reconfigure themselves with the appropriate photo settings, take the photo,
and then resume streaming. In this case, the stopping and restarting of streaming should
cause mute
and unmute
events to fire on the Track in question. PhotoEvent
event containing the Blob
.Parameter | Type | Nullable | Optional | Description |
---|---|---|---|---|
trackID | DOMString | ✘ | ✔ |
void
PhotoEvent
interface PhotoEvent : Event {
readonly attribute Blob data;
};
data
of type Blob, readonly<img>
tag. MediaSettingsRange
interface MediaSettingsRange {
readonly attribute unsigned long max;
readonly attribute unsigned long min;
readonly attribute unsigned long initial;
};
initial
of type unsigned long, readonlymax
of type unsigned long, readonlymin
of type unsigned long, readonlyMediaSettingsItem
The MediaSettingsItem
interface is now defined, which allows for a single setting to be managed.
interface MediaSettingsItem {
readonly attribute any value;
};
value
of type any, readonlyPhotoSettingsOptions
The PhotoSettingsOptions attribute of the ImageCapture
object provides
the photo-specific settings options and current settings values.
interface PhotoSettingsOptions {
attribute MediaSettingsItem
whiteBalanceMode;
attribute MediaSettingsItem
autoExposureMode;
attribute MediaSettingsRange
exposureCompensation;
attribute MediaSettingsRange
iso;
attribute MediaSettingsItem
redEyeReduction;
attribute MediaSettingsRange
brightness;
attribute MediaSettingsRange
constrast;
attribute MediaSettingsRange
saturation;
attribute MediaSettingsRange
sharpness;
attribute MediaSettingsRange
imageHeight;
attribute MediaSettingsRange
imageWidth;
};
autoExposureMode
of type MediaSettingsItem
ExposureModeEnum
.brightness
of type MediaSettingsRange
constrast
of type MediaSettingsRange
exposureCompensation
of type MediaSettingsRange
imageHeight
of type MediaSettingsRange
imageWidth
of type MediaSettingsRange
iso
of type MediaSettingsRange
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 | auto |
incandescent | 2500-3500 Kelvin |
fluorescent | 4000-5000 Kelvin |
warm-fluorescent | 5000-5500 Kelvin |
daylight | 5000-6500 Kelvin |
cloudy-daylight | 6500-8000 Kelvin |
twilight | 8000-9000 Kelvin |
shade | 9000-10000 Kelvin |
ExposureModeEnum
enum ExposureModeEnum {
"frame-average",
"center-weighted",
"spot-metering"
};
Enumeration description | |
---|---|
frame-average | Average of light information from entire scene |
center-weighted | Sensitivity concentrated towards center of viewfinder |
spot-metering | Spot-centered weighting |
PhotoSettings
The PhotoSettings
object is optionally passed into the ImageCapture.setPhotoSettings()
method
in order to modify capture device settings specific to still imagery. Each of the attributes in this object
are optional.
interface PhotoSettings {
attribute any whiteBalanceModeSetting;
attribute any autoExposureModeSetting;
attribute unsigned long exposureCompensationSetting;
attribute unsigned long isoSetting;
attribute boolean redEyeReductionSetting;
attribute unsigned long brightnessSetting;
attribute unsigned long constrastSetting;
attribute unsigned long saturationSetting;
attribute unsigned long sharpnessSetting;
attribute unsigned long imageHeightSetting;
attribute unsigned long imageWidthSetting;
};
autoExposureModeSetting
of type anyExposureModeEnum
.brightnessSetting
of type unsigned longconstrastSetting
of type unsigned longexposureCompensationSetting
of type unsigned longimageHeightSetting
of type unsigned longimageWidthSetting
of type unsigned longisoSetting
of type unsigned longredEyeReductionSetting
of type booleansaturationSetting
of type unsigned longsharpnessSetting
of type unsigned longwhiteBalanceModeSetting
of type anyWhiteBalanceModeEnum
.PhotoError
The PhotoError
object is passed to an onphotoerror
event handler of an
ImageCapture
object if an error occurred when the takePhoto()
method was invoked.
interface PhotoError {
readonly attribute unsigned short code;
const unsigned short PHOTO_ERROR = 0;
const unsigned short DEVICE_UNAVAILABLE = 1;
};
code
of type unsigned short, readonlyDEVICE_UNAVAILABLE
of type unsigned shortcode
for when image capture device is unavailablePHOTO_ERROR
of type unsigned shortcode
for when an error occurred while capturing the imagenavigator.getUserMedia({video: true}, gotMedia, failedToGetMedia); function gotMedia(mediastream) { var videoDevice = mediastream.videoTracks[0]; // Check if this device supports a picture mode... var pictureDevice = new ImageCapture(); if (pictureDevice) { pictureDevice.onphoto = showPicture; if (pictureDevice.photoSettingsOptions.redEyeReduction) { pictureDevice.setPhotoSettings({redEyeReductionSetting:true}); } else console.log('No red eye reduction'); pictureDevice.onphotosettingschange = function(){ currentRedEye = new Boolean; currentRedEye = false; if (pictureDevice.photoSettingsOptions.redEyeReduction) currentRedEye = pictureDevice.photoSettingsOptions.redEyeReduction.value; if (currentRedEye == true) pictureDevice.takePhoto(); } } } function showPicture(e) { var img = document.querySelector("img"); img.src = URL.createObjectURL(e.data); } function failedToGetMedia{ console.log('Stream failure'); }