-
Notifications
You must be signed in to change notification settings - Fork 40
/
index.bs
1180 lines (895 loc) · 59.8 KB
/
index.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<pre class="metadata">
Title: MediaStream Image Capture
Repository: w3c/mediacapture-image
Group: webrtc
Markup Shorthands: markdown yes
Status: ED
ED: https://w3c.github.io/mediacapture-image/
TR: https://www.w3.org/TR/image-capture/
Shortname: image-capture
Level: none
Editor: Miguel Casas-Sanchez, w3cid 82825, Google LLC https://www.google.com, [email protected]
Editor: Rijubrata Bhaumik, w3cid 80407, Intel Corporation https://intel.com
Former Editor: Giridhar Mandyam, w3cid 54271, Qualcomm Innovation Center Inc.
Abstract: This document specifies methods and camera settings to produce photographic image capture. The source of images is, or can be referenced via a {{MediaStreamTrack}}.
!Participate: <a href="https://lists.w3.org/Archives/Public/public-webrtc/">Mailing list</a>
!Participate: <a href="https://github.com/w3c/mediacapture-image">GitHub repo</a> (<a href="https://github.com/w3c/mediacapture-image/issues/new">new issue</a>, <a href="https://github.com/w3c/mediacapture-image/issues">open issues</a>)
!Implementation: <a href="https://github.com/w3c/mediacapture-image/blob/master/implementation-status.md">Implementation Status</a>
!Implementation: <a href="http://caniuse.com/#feat=imagecapture">Can I use Image Capture?</a>
!Polyfills: <a href="https://github.com/GoogleChromeLabs/imagecapture-polyfill">GoogleChromeLabs/imagecapture-polyfill</a>
</pre>
<style>
table {
border-collapse: collapse;
border-left-style: hidden;
border-right-style: hidden;
text-align: left;
}
table caption {
font-weight: bold;
padding: 3px;
text-align: left;
}
table td, table th {
border: 1px solid black;
padding: 3px;
}
</style>
# Introduction # {#introduction}
The API defined in this document captures images from a photographic device referenced through a valid {{MediaStreamTrack}} [[!GETUSERMEDIA]]. The produced image can be in the form of a {{Blob}} (see {{takePhoto()}} method) or as a {{ImageBitmap}} (see {{grabFrame()}}).
Reading capabilities and settings and applying constraints is done in one of two ways depending on whether it impacts the video {{MediaStreamTrack}} or not. Photo-specific capabilities and current settings can be retrieved via {{getPhotoCapabilities()}}/{{getPhotoSettings()}} and configured via {{takePhoto()}}'s {{PhotoSettings}} argument. Manipulating video-related capabilities, current settings and constraints is done via the MediaStreamTrack <a href="#extensions">extension mechanism</a>.
# Security and Privacy Considerations # {#securityandprivacy}
The <a href="https://www.w3.org/TR/mediacapture-streams/#privacy-and-security-considerations"> privacy and security considerations</a> discussed in
[[GETUSERMEDIA]] apply to this extension specification.
Moreover, implementors should take care to prevent additional leakage of privacy-sensitive data from captured images.
For instance, embedding the user’s location in the metadata of the digitzed image (e.g. EXIF) might transmit more private data than the user is expecting.
# Image Capture API # {#imagecaptureapi}
The User Agent must support Promises in order to implement the Image Capture API. Any {{Promise}} object is assumed to have a resolver object, with <code>resolve()</code> and <code>reject()</code> methods associated with it.
<pre class="idl">
[Exposed=Window]
interface ImageCapture {
constructor(MediaStreamTrack videoTrack);
Promise<Blob> takePhoto(optional PhotoSettings photoSettings = {});
Promise<PhotoCapabilities> getPhotoCapabilities();
Promise<PhotoSettings> getPhotoSettings();
Promise<ImageBitmap> grabFrame();
readonly attribute MediaStreamTrack track;
};
</pre>
<div class="note">
{{takePhoto()}} returns a captured image encoded in the form of a {{Blob}}, whereas {{grabFrame()}} returns a snapshot of the {{track}} video feed in the form of a non-encoded {{ImageBitmap}}.
</div>
## Attributes ## {#imagecapture-attributes}
<dl class="domintro">
<dt><dfn attribute for="ImageCapture"><code>track</code></dfn></dt>
<dd>The {{MediaStreamTrack}} passed into the constructor.</dd>
</dl>
## Methods ## {#imagecapture-methods}
<dl class="domintro">
<dt><dfn constructor for="ImageCapture"><code>ImageCapture(MediaStreamTrack videoTrack)</code></dfn></dt>
<dd>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">videoTrack</td>
<td class="prmType">{{MediaStreamTrack}}</td>
<td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td>
<td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td>
<td class="prmDesc">The {{MediaStreamTrack}} to be used as source of data. This will be the value of the {{track}} attribute. The {{MediaStreamTrack}} passed to the constructor MUST have its {{MediaStreamTrack/kind}} attribute set to <code>"video"</code> otherwise a {{DOMException}} of type {{NotSupportedError}} will be thrown.</td>
</tr>
</tbody>
</table>
</dd>
<dt><dfn method for="ImageCapture"><code>takePhoto(optional PhotoSettings photoSettings)</code></dfn></dt>
<dd>
{{takePhoto()}} produces the result of a single photographic exposure using the video capture device sourcing the {{track}} and including any {{PhotoSettings}} configured, returning an encoded image in the form of a {{Blob}} if successful. When this method is invoked, the user agent MUST run the following steps:
<ol>
<li>If the {{MediaStreamTrack/readyState}} of {{track}} provided in the constructor is not {{live}}, return <a>a promise rejected with</a> a new {{DOMException}} whose name is {{InvalidStateError}}, and abort these steps. </li>
<li>Let <var>p</var> be a new promise.</li>
<li>Run the following steps in parallel:
<ol>
<li>Gather data from the {{track}} underlying source with the defined {{photoSettings}} and into a {{Blob}} containing a single still image. The method of doing this will depend on the underlying device.
<div class="note">
Devices 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 {{onmute}} and {{onunmute}} events to fire on the track in question.
</div>
</li>
<li>If the operation cannot be completed for any reason (for example, upon invocation of multiple {{takePhoto()}} method calls in rapid succession), then reject <var>p</var> with a new {{DOMException}} whose name is {{UnknownError}}, and abort these steps.</li>
<li>Resolve <var>p</var> with the Blob object.</li>
</ol>
</li>
<li>Return <var>p</var>.</li>
</ol>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">settings</td>
<td class="prmType">{{PhotoSettings}}</td>
<td class="prmNullTrue"><span role="img" aria-label="True">✔</span></td>
<td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td>
<td class="prmDesc">The {{PhotoSettings}} dictionary to be applied.</td>
</tr>
</tbody>
</table>
</dd>
<dt><dfn method for="ImageCapture"><code>getPhotoCapabilities()</code></dfn></dt>
<dd>
{{getPhotoCapabilities()}} is used to retrieve the ranges of available configuration options, if any. When this method is invoked, the user agent MUST run the following steps:
<ol>
<li>If the {{MediaStreamTrack/readyState}} of {{track}} provided in the constructor is not {{live}}, return <a>a promise rejected with</a> a new {{DOMException}} whose name is {{InvalidStateError}}, and abort these steps. </li>
<li>Let <var>p</var> be a new promise.</li>
<li>Run the following steps in parallel:
<ol>
<li>Gather data from {{track}} into a {{PhotoCapabilities}} dictionary containing the available capabilities of the device, including ranges where appropriate. The method of doing this will depend on the underlying device. </li>
<li>If the data cannot be gathered for any reason (for example, the {{MediaStreamTrack}} being ended asynchronously), then reject <var>p</var> with a new {{DOMException}} whose name is {{OperationError}}, and abort these steps.</li>
<li>Resolve <var>p</var> with the {{PhotoCapabilities}} dictionary.</li>
</ol>
</li>
<li>Return <var>p</var>.</li>
</ol>
</dd>
<dt><dfn method for="ImageCapture"><code>getPhotoSettings()</code></dfn></dt>
<dd>
{{getPhotoSettings()}} is used to retrieve the current configuration settings values, if any. When this method is invoked, the user agent MUST run the following steps:
<ol>
<li>If the {{MediaStreamTrack/readyState}} of {{track}} provided in the constructor is not {{live}}, return <a>a promise rejected with</a> a new {{DOMException}} whose name is {{InvalidStateError}}, and abort these steps. </li>
<li>Let <var>p</var> be a new promise.</li>
<li>Run the following steps in parallel:
<ol>
<li>Gather data from {{track}} into a {{PhotoSettings}} dictionary containing the current conditions in which the device is found. The method of doing this will depend on the underlying device. </li>
<li>If the data cannot be gathered for any reason (for example, the {{MediaStreamTrack}} being ended asynchronously), then reject <var>p</var> with</a> a new {{DOMException}} whose name is {{OperationError}}, and abort these steps.</li>
<li>Resolve <var>p</var> with the {{PhotoSettings}} dictionary.</li>
</ol>
</li>
<li>Return <var>p</var>.</li>
</ol>
</dd>
<dt><dfn method for="ImageCapture"><code>grabFrame()</code></dfn></dt>
<dd>{{grabFrame()}} takes a snapshot of the live video being held in {{track}}, returning an {{ImageBitmap}} if successful. {{grabFrame()}} returns data only once upon being invoked. When this method is invoked, the user agent MUST run the following steps:
<ol>
<li>If the {{MediaStreamTrack/readyState}} of {{track}} provided in the constructor is not {{live}}, return <a>a promise rejected with</a> a new {{DOMException}} whose name is {{InvalidStateError}}, and abort these steps.</li>
<li>Let <var>p</var> be a new promise.</li>
<li>Run the following steps in parallel:
<ol>
<li>Gather data from {{track}} into an {{ImageBitmap}} object. The {{ImageBitmap/width}} and {{ImageBitmap/height}} of the {{ImageBitmap}} object are derived from the constraints of {{track}}.
</li>
<li>If the operation cannot be completed for any reason (for example, upon invocation of multiple {{grabFrame()}}/{{takePhoto()}} method calls in rapid succession), then reject <var>p</var> with</a> a new {{DOMException}} whose name is {{UnknownError}}, and abort these steps.</li>
<li>Resolve <var>p</var> with the {{ImageBitmap}} object.</li>
</ol>
</li>
<li>Return <var>p</var>.</li>
</ol>
</dd>
</dl>
# PhotoCapabilities # {#photocapabilities-section}
<pre class="idl">
dictionary PhotoCapabilities {
RedEyeReduction redEyeReduction;
MediaSettingsRange imageHeight;
MediaSettingsRange imageWidth;
sequence<FillLightMode> fillLightMode;
};
</pre>
## Members ## {#photocapabilities-members}
<dl class="domintro">
<dt><dfn dict-member for="PhotoCapabilities"><code>redEyeReduction</code></dfn></dt>
<dd>The <a>red eye reduction</a> capacity of the source.</dd>
<dt><dfn dict-member for="PhotoCapabilities"><code>imageHeight</code></dfn></dt>
<dd>This reflects the <a>image height</a> range supported by the UA.</dd>
<dt><dfn dict-member for="PhotoCapabilities"><code>imageWidth</code></dfn></dt>
<dd>This reflects the <a>image width</a> range supported by the UA.</dd>
<dt><dfn dict-member for="PhotoCapabilities"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the supported <a>fill light mode</a> (flash) settings, if any.</dd>
</dl>
<div class="note">
The supported resolutions are presented as segregated {{PhotoCapabilities/imageWidth}} and {{PhotoCapabilities/imageHeight}} ranges to prevent increasing the fingerprinting surface and to allow the UA to make a best-effort decision with regards to actual hardware configuration.
</div>
# PhotoSettings # {#photosettings-section}
<pre class="idl">
dictionary PhotoSettings {
FillLightMode fillLightMode;
double imageHeight;
double imageWidth;
boolean redEyeReduction;
};
</pre>
## Members ## {#photosettings-members}
<dl class="domintro">
<dt><dfn dict-member for="PhotoSettings"><code>redEyeReduction</code></dfn></dt>
<dd>This reflects whether camera <a>red eye reduction</a> is desired</dd>
<dt><dfn dict-member for="PhotoSettings"><code>imageHeight</code></dfn></dt>
<dd>This reflects the desired <a>image height</a>. The UA MUST select the closest height value to this setting if it supports a discrete set of height options.</dd>
<dt><dfn dict-member for="PhotoSettings"><code>imageWidth</code></dfn></dt>
<dd>This reflects the desired <a>image width</a>. The UA MUST select the closest width value to this setting if it supports a discrete set of width options.</dd>
<dt><dfn dict-member for="PhotoSettings"><code>fillLightMode</code></dfn></dt>
<dd>This reflects the desired <a>fill light mode</a> (flash) setting.</dd>
</dl>
# {{MediaSettingsRange}} # {#mediasettingsrange-section}
<pre class="idl">
dictionary MediaSettingsRange {
double max;
double min;
double step;
};
</pre>
## Members ## {#mediasettingsrange-members}
<dl class="domintro">
<dt><dfn dict-member for="MediaSettingsRange"><code>max</code></dfn></dt>
<dd>The maximum value of this setting</dd>
<dt><dfn dict-member for="MediaSettingsRange"><code>min</code></dfn></dt>
<dd>The minimum value of this setting</dd>
<dt><dfn dict-member for="MediaSettingsRange"><code>step</code></dfn></dt>
<dd>The minimum difference between consecutive values of this setting.</dd>
</dl>
# {{RedEyeReduction}} # {#redeyereduction-section}
<pre class="idl">
enum RedEyeReduction {
"never",
"always",
"controllable"
};
</pre>
## Values ## {#redeyereduction-values}
<dl class="domintro">
<dt><dfn enum-value for="RedEyeReduction"><code>never</code></dfn></dt>
<dd><a>Red eye reduction</a> is not available in the device.</dd>
<dt><dfn enum-value for="RedEyeReduction"><code>always</code></dfn></dt>
<dd><a>Red eye reduction</a> is available in the device and it is always configured to true.</dd>
<dt><dfn enum-value for="RedEyeReduction"><code>controllable</code></dfn></dt>
<dd><a>Red eye reduction</a> is available in the device and it is controllable by the user via {{PhotoSettings/redEyeReduction}}.</dd>
</dl>
# {{FillLightMode}} # {#filllightmode-section}
<pre class="idl">
enum FillLightMode {
"auto",
"off",
"flash"
};
</pre>
## Values ## {#filllightmode-values}
<dl class="domintro">
<dt><dfn enum-value for="FillLightMode"><code>auto</code></dfn></dt>
<dd>The video device's fill light will be enabled when required (typically low light conditions). Otherwise it will be off. Note that auto does not guarantee that a flash will fire when {{takePhoto()}} is called. Use {{flash}} to guarantee firing of the flash for {{takePhoto()}} method.</dd>
<dt><dfn enum-value for="FillLightMode"><code>off</code></dfn></dt>
<dd>The source's fill light and/or flash will not be used.</dd>
<dt><dfn enum-value for="FillLightMode"><code>flash</code></dfn></dt>
<dd>This value will always cause the flash to fire for {{takePhoto()}} method.</dd>
</dl>
# Extensions # {#extensions}
This Section defines a new set of [[mediacapture-streams#constrainable-properties|constrainable properties]] for {{MediaStreamTrack}} that can be applied in order to make its behavior more suitable for taking pictures. Use of these constraints via {{MediaStreamTrack}}'s methods {{MediaStreamTrack/getCapabilities()}}, {{MediaStreamTrack/getSettings()}}, {{MediaStreamTrack/getConstraints()}} and {{MediaStreamTrack/applyConstraints()}} will modify the behavior of the {{ImageCapture}} object's {{track}}.
## {{MediaTrackSupportedConstraints}} dictionary ## {#mediatracksupportedconstraints-section}
{{MediaTrackSupportedConstraints}} is extended here with the list of constraints that a User Agent recognizes for controlling the photo capabilities. This dictionary can be retrieved using {{MediaDevices}} {{getSupportedConstraints()}} method.
<pre class="idl">
partial dictionary MediaTrackSupportedConstraints {
boolean whiteBalanceMode = true;
boolean exposureMode = true;
boolean focusMode = true;
boolean pointsOfInterest = true;
boolean exposureCompensation = true;
boolean exposureTime = true;
boolean colorTemperature = true;
boolean iso = true;
boolean brightness = true;
boolean contrast = true;
boolean pan = true;
boolean saturation = true;
boolean sharpness = true;
boolean focusDistance = true;
boolean tilt = true;
boolean zoom = true;
boolean torch = true;
};
</pre>
### Members ### {#mediatracksupportedconstraints-members}
<dl class="domintro">
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>whiteBalanceMode</code></dfn></dt>
<dd>Whether <a>white balance mode</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>colorTemperature</code></dfn></dt>
<dd>Whether <a>color temperature</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>exposureMode</code></dfn></dt>
<dd>Whether <a>exposure</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>exposureCompensation</code></dfn></dt>
<dd>Whether <a>exposure compensation</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>exposureTime</code></dfn></dt>
<dd>Whether <a>exposure time</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>iso</code></dfn></dt>
<dd>Whether <a>ISO</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>focusMode</code></dfn></dt>
<dd>Whether <a>focus mode</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>pointsOfInterest</code></dfn></dt>
<dd>Whether <a>points of interest</a> are supported.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>brightness</code></dfn></dt>
<dd>Whether <a>brightness</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>contrast</code></dfn></dt>
<dd>Whether <a>contrast</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>pan</code></dfn></dt>
<dd>Whether <a>pan</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>saturation</code></dfn></dt>
<dd>Whether <a>saturation</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>sharpness</code></dfn></dt>
<dd>Whether <a>sharpness</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>focusDistance</code></dfn></dt>
<dd>Whether <a>focus distance</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>tilt</code></dfn></dt>
<dd>Whether <a>tilt</a> constraining is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>zoom</code></dfn></dt>
<dd>Whether configuration of the <a>zoom</a> level is recognized.</dd>
<dt><dfn dict-member for="MediaTrackSupportedConstraints"><code>torch</code></dfn></dt>
<dd>Whether configuration of <a>torch</a> is recognized.</dd>
</dl>
## {{MediaTrackCapabilities}} dictionary ## {#mediatrackcapabilities-section}
{{MediaTrackCapabilities}} is extended here with the capabilities specific to image capture. This dictionary is produced by the UA via {{MediaStreamTrack/getCapabilities()}} and represents the supported ranges and enumerations of the supported constraints.
<pre class="idl">
partial dictionary MediaTrackCapabilities {
sequence<DOMString> whiteBalanceMode;
sequence<DOMString> exposureMode;
sequence<DOMString> focusMode;
MediaSettingsRange exposureCompensation;
MediaSettingsRange exposureTime;
MediaSettingsRange colorTemperature;
MediaSettingsRange iso;
MediaSettingsRange brightness;
MediaSettingsRange contrast;
MediaSettingsRange saturation;
MediaSettingsRange sharpness;
MediaSettingsRange focusDistance;
MediaSettingsRange pan;
MediaSettingsRange tilt;
MediaSettingsRange zoom;
sequence<boolean> torch;
};
</pre>
### Members ### {#mediatrackcapabilities-members}
<dl class="domintro">
<dt><dfn dict-member for="MediaTrackCapabilities"><code>whiteBalanceMode</code></dfn></dt>
<dd>A sequence of supported <a>white balance modes</a>. Each string MUST be one of the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>colorTemperature</code></dfn></dt>
<dd>This range reflects the supported correlated <a>color temperatures</a> to be used for the scene white balance calculation.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>exposureMode</code></dfn></dt>
<dd>A sequence of supported <a>exposure</a> modes. Each string MUST be the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>exposureCompensation</code></dfn></dt>
<dd>This reflects the supported range of <a>exposure compensation</a>. The supported range can be, and usually is, centered around 0 EV.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>exposureTime</code></dfn></dt>
<dd>This reflects the supported range of <a>exposure time</a>. Values are numeric. Increasing values indicate increasing exposure time.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>iso</code></dfn></dt>
<dd>This reflects the permitted range of <a>ISO</a> values.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>focusMode</code></dfn></dt>
<dd>A sequence of supported <a>focus modes</a>. Each string MUST be one of the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>brightness</code></dfn></dt>
<dd>This reflects the supported range of <a>brightness</a> setting of the camera. Values are numeric. Increasing values indicate increasing brightness.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>contrast</code></dfn></dt>
<dd>This reflects the supported range of <a>contrast</a>. Values are numeric. Increasing values indicate increasing contrast.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>pan</code></dfn></dt>
<dd>
This reflects the <a>pan</a> value range supported by the UA and by the track.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>pan</a>.
In that case the UA MUST NOT expose the <a>pan</a> value range but MAY provide an empty {{MediaSettingsRange}} dictionary to indicate that the underlying video source supports <a>pan</a>.
<div class="note">
Even if the UA provides an empty {{MediaSettingsRange}} dictionary to indicate that the underlying video source supports <a>pan</a>, <a>tilt</a> or <a>zoom</a>, that support can be utilized only after a new {{MediaDevices/getUserMedia()}} call which resolves with a {{MediaStream}} object which contains a video track which supports <a>pan</a>, <a>tilt</a> or <a>zoom</a>.
</div>
</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>saturation</code></dfn></dt>
<dd>This reflects the permitted range of <a>saturation</a> setting. Values are numeric. Increasing values indicate increasing saturation.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>sharpness</code></dfn></dt>
<dd>This reflects the permitted <a>sharpness</a> range of the camera. Values are numeric. Increasing values indicate increasing sharpness, and the minimum value always implies no sharpness enhancement or processing.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>focusDistance</code></dfn></dt>
<dd>This reflects the <a>focus distance</a> value range supported by the UA.</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>tilt</code></dfn></dt>
<dd>
This reflects the <a>tilt</a> value range supported by the UA and by the track.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>tilt</a>.
In that case the UA MUST NOT expose the <a>tilt</a> value range but MAY provide an empty {{MediaSettingsRange}} dictionary to indicate that the underlying video source supports <a>tilt</a>.
</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>zoom</code></dfn></dt>
<dd>
This reflects the <a>zoom</a> value range supported by the UA and by the track.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>zoom</a>.
In that case the UA MUST NOT expose the <a>zoom</a> value range but MAY provide an empty {{MediaSettingsRange}} dictionary to indicate that the underlying video source supports <a>zoom</a>.
</dd>
<dt><dfn dict-member for="MediaTrackCapabilities"><code>torch</code></dfn></dt>
<dd>If the source cannot turn on <a>torch</a>, a single <code>false</code> is reported.
If the source cannot turn off <a>torch</a>, a single <code>true</code> is reported.
If the script can control the feature, the source reports a list with both <code>true</code> and <code>false</code> as possible values.</dd>
</dl>
## {{MediaTrackConstraintSet}} dictionary ## {#mediatrackconstraintset-section}
{{MediaTrackConstraintSet}} [[!GETUSERMEDIA]] dictionary is used for both reading the current status with {{MediaStreamTrack/getConstraints()}} and for applying a set of constraints with {{MediaStreamTrack/applyConstraints()}}.
<div class="note">
{{MediaTrackSettings}} can be retrieved to verify the effect of the application by the user agent of the requested {{MediaTrackConstraints}}. Some constraints such as, e.g. <a>zoom</a>, might not be immediately applicable.
</div>
<pre class="idl">
partial dictionary MediaTrackConstraintSet {
ConstrainDOMString whiteBalanceMode;
ConstrainDOMString exposureMode;
ConstrainDOMString focusMode;
ConstrainPoint2D pointsOfInterest;
ConstrainDouble exposureCompensation;
ConstrainDouble exposureTime;
ConstrainDouble colorTemperature;
ConstrainDouble iso;
ConstrainDouble brightness;
ConstrainDouble contrast;
ConstrainDouble saturation;
ConstrainDouble sharpness;
ConstrainDouble focusDistance;
(boolean or ConstrainDouble) pan;
(boolean or ConstrainDouble) tilt;
(boolean or ConstrainDouble) zoom;
ConstrainBoolean torch;
};
</pre>
### Members ### {#mediatrackconstraintset-members}
<dl class="domintro">
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>whiteBalanceMode</code></dfn></dt>
<dd>This string MUST be one of the members of {{MeteringMode}}. See <a>white balance mode</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>exposureMode</code></dfn></dt>
<dd>This string MUST be one of the members of {{MeteringMode}}. See <a>exposure</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>focusMode</code></dfn></dt>
<dd>This string MUST be one of the members of {{MeteringMode}}. See <a>focus mode</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>colorTemperature</code></dfn></dt>
<dd>See <a>color temperature</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>exposureCompensation</code></dfn></dt>
<dd>See <a>exposure compensation</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>exposureTime</code></dfn></dt>
<dd>See <a>exposure time</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>iso</code></dfn></dt>
<dd>See <a>iso</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>pointsOfInterest</code></dfn></dt>
<dd>See <a>points of interest</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>brightness</code></dfn></dt>
<dd>See <a>brightness</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>contrast</code></dfn></dt>
<dd>See <a>contrast</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>pan</code></dfn></dt>
<dd>See <a>pan</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>saturation</code></dfn></dt>
<dd>See <a>saturation</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>sharpness</code></dfn></dt>
<dd>See <a>sharpness</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>focusDistance</code></dfn></dt>
<dd>See <a>focus distance</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>tilt</code></dfn></dt>
<dd>See <a>tilt</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>zoom</code></dfn></dt>
<dd>See <a>zoom</a> constrainable property.</dd>
<dt><dfn dict-member for="MediaTrackConstraintSet"><code>torch</code></dfn></dt>
<dd>See <a>torch</a> constrainable property.</dd>
</dl>
## {{MediaTrackSettings}} dictionary ## {#mediatracksettings-section}
When the {{MediaStreamTrack/getSettings()}} method is invoked on a video stream track, the user agent must return the extended {{MediaTrackSettings}} dictionary, representing the current status of the underlying user agent.
<pre class="idl">
partial dictionary MediaTrackSettings {
DOMString whiteBalanceMode;
DOMString exposureMode;
DOMString focusMode;
sequence<Point2D> pointsOfInterest;
double exposureCompensation;
double exposureTime;
double colorTemperature;
double iso;
double brightness;
double contrast;
double saturation;
double sharpness;
double focusDistance;
double pan;
double tilt;
double zoom;
boolean torch;
};
</pre>
### Members ### {#mediatracksettings-members}
<dl class="domintro">
<dt><dfn dict-member for="MediaTrackSettings"><code>whiteBalanceMode</code></dfn></dt>
<dd>Current <a>white balance mode</a> setting. The string MUST be one of the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>exposureMode</code></dfn></dt>
<dd>Current <a>exposure</a> mode setting. The string MUST be one of the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>colorTemperature</code></dfn></dt>
<dd><a>Color temperature</a> in use for the white balance calculation of the scene. This field is only significant if {{MediaTrackSettings/whiteBalanceMode}} is {{manual}}.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>exposureCompensation</code></dfn></dt>
<dd>Current <a>exposure compensation</a> setting. A value of 0 EV is interpreted as no exposure compensation. This field is only significant if {{MediaTrackSettings/exposureMode}} is {{MeteringMode/continuous}} or {{MeteringMode/single-shot}}</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>exposureTime</code></dfn></dt>
<dd>Current <a>exposure time</a> setting. This field is only significant if {{MediaTrackSettings/exposureMode}} is {{manual}}.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>iso</code></dfn></dt>
<dd>Current camera <a>ISO</a> setting.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>focusMode</code></dfn></dt>
<dd>Current <a>focus mode</a> setting. The string MUST be one of the members of {{MeteringMode}}.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>pointsOfInterest</code></dfn></dt>
<dd>A sequence of {{Point2D}}s in use as <a>points of interest</a> for other settings, e.g. Focus, Exposure and Auto White Balance.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>brightness</code></dfn></dt>
<dd>This reflects the current <a>brightness</a> setting of the camera.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>contrast</code></dfn></dt>
<dd>This reflects the current <a>contrast</a> setting of the camera.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>pan</code></dfn></dt>
<dd>
This reflects the current <a>pan</a> setting of the camera.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>pan</a>.
In that case the UA MUST NOT expose the <a>pan</a> setting.
</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>saturation</code></dfn></dt>
<dd>This reflects the current <a>saturation</a> setting of the camera.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>sharpness</code></dfn></dt>
<dd>This reflects the current <a>sharpness</a> setting of the camera.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>focusDistance</code></dfn></dt>
<dd>This reflects the current <a>focus distance</a> setting of the camera.</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>tilt</code></dfn></dt>
<dd>
This reflects the current <a>tilt</a> setting of the camera.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>tilt</a>.
In that case the UA MUST NOT expose the <a>tilt</a> setting.</dd><dt><dfn dict-member for="MediaTrackSettings"><code>zoom</code></dfn></dt><dd>This reflects the current <a>zoom</a> setting of the camera.
If the track has been created without <a>requesting permission to use</a> (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true or if that permission request is denied, the track does not support <a>zoom</a>.
In that case the UA MUST NOT expose the <a>zoom</a> setting.
</dd>
<dt><dfn dict-member for="MediaTrackSettings"><code>torch</code></dfn></dt>
<dd>Current camera <a>torch</a> configuration setting.</dd>
</dl>
## Additional Constrainable Properties ## {#additional-constrainable-props}
<pre class="idl">
dictionary ConstrainPoint2DParameters {
sequence<Point2D> exact;
sequence<Point2D> ideal;
};
typedef (sequence<Point2D> or ConstrainPoint2DParameters) ConstrainPoint2D;
</pre>
### Members ### {#constraintpoint2d-members}
<dl class="domintro">
<dt><dfn dict-member for="ConstrainPoint2DParameters"><code>exact</code></dfn></dt>
<dd>The exact required value of <a>points of interest</a>.</dd>
<dt><dfn dict-member for="ConstrainPoint2DParameters"><code>ideal</code></dfn></dt>
<dd>The ideal (target) value of <a>points of interest</a>.</dd>
</dl>
# Photo Capabilities and Constrainable Properties # {#constrainable-properties}
<div class="note">
Many of the mentioned photo and video capabilities mirror hardware features that are hard to define since they can be implemented in a number of ways. Moreover, manufacturers tend to publish vague definitions to protect their intellectual property.
</div>
<div class="note">
None of the names of these photo capabilities and constrainable properties are in the list of <a>allowed required constraints for device selection</a>.
Therefore, in {{MediaDevices/getUserMedia()}}, these photo capabilities and constrainable properties can be constrained only with <a>optional basic constraints</a> and <a>advanced constraints</a>, but not with <a>required constraints</a>.
</div>
<ol>
<li><i><dfn>White balance mode</dfn></i> is a setting that cameras use to adjust for different color temperatures. <dfn>Color temperature</dfn> is the temperature of background light (usually measured in Kelvin). This setting can usually be automatically and continuously determined by the implementation, but it's also common to offer a <code>manual</code> mode in which the estimated temperature of the scene illumination is hinted to the implementation. Typical temperature ranges for popular modes are provided below:
<table class="simple">
<tr> <th>Mode</th> <th>Kelvin range</th> </tr>
<tr> <td>incandescent</td> <td>2500-3500</td> </tr>
<tr> <td>fluorescent</td> <td>4000-5000</td> </tr>
<tr> <td>warm-fluorescent</td> <td>5000-5500</td> </tr>
<tr> <td>daylight</td> <td>5500-6500</td> </tr>
<tr> <td>cloudy-daylight</td> <td>6500-8000</td> </tr>
<tr> <td>twilight</td> <td>8000-9000</td> </tr>
<tr> <td>shade</td> <td>9000-10000</td> </tr>
</table>
</li>
<li><i><dfn>Exposure</dfn></i> is the amount of light that is allowed to fall on the photosensitive device. In auto-exposure modes ({{MeteringMode/single-shot}} or {{MeteringMode/continuous}} {{MediaTrackSettings/exposureMode}}), the exposure time and/or camera aperture are automatically adjusted by the implementation based on the subject of the photo. In {{MeteringMode/manual}} {{MediaTrackSettings/exposureMode}}, these parameters are set to fixed absolute values.</li>
<li><dfn>Focus mode</dfn> describes the focus setting of the capture device (e.g. `auto` or `manual`). </li>
<li><dfn>Points of interest</dfn> describe the metering area centers used in other settings, e.g. <a>exposure</a>, <a>white balance mode</a> and <a>focus mode</a> each one being a {{Point2D}} (usually these three controls are modified simultaneously by the so-called <code>3A</code> algorithm: auto-focus, auto-exposure, auto-white-balance).
A {{Point2D}} Point of Interest is interpreted to represent a pixel position in a normalized square space (`{x,y} ∈ [0.0, 1.0]`). The origin of coordinates `{x,y} = {0.0, 0.0}` represents the upper leftmost corner whereas the `{x,y} = {1.0, 1.0}` represents the lower rightmost corner: the <a href="#dom-point2d-x"><code>x</code></a> coordinate (columns) increases rightwards and the <a href="#dom-point2d-y"><code>y</code></a> coordinate (rows) increases downwards. Values beyond the mentioned limits will be clamped to the closest allowed value.</li>
<li><i><dfn>Exposure Compensation</dfn></i> is a numeric camera setting that adjusts the exposure level from the current value used by the implementation. This value can be used to bias the exposure level enabled by auto-exposure, and usually is a symmetric range around 0 EV (the no-compensation value). This value is only used in {{MeteringMode/single-shot}} and {{MeteringMode/continuous}} {{MediaTrackSettings/exposureMode}}.</li>
<li><i><dfn>Exposure Time</dfn></i> is a numeric camera setting that controls the length of time during which light is allowed to fall on the photosensitive device. This value is used in {{MeteringMode/manual}} {{MediaTrackSettings/exposureMode}} to control exposure. The value is in 100 microsecond units. That is, a value of 1.0 means an exposure time of 1/10000th of a second and a value of 10000.0 means an exposure time of 1 second.</li>
<li>The <i><dfn>ISO</dfn></i> setting of a camera describes the sensitivity of the camera to light. It is a numeric value, where the lower the value the greater the sensitivity. This value should follow the [[iso12232]] standard.</li>
<li><dfn>Red Eye Reduction</dfn> is a feature in cameras that is designed to limit or prevent the appearance of red pupils ("Red Eye") in photography subjects due prolonged exposure to a camera's flash.</li>
<li>[[LIGHTING-VOCABULARY]] defines <i><dfn>brightness</dfn></i> as "the attribute of a visual sensation according to which an area appears to emit more or less light" and in the context of the present API, it refers to the numeric camera setting that adjusts the perceived amount of light emitting from the photo object. A higher brightness setting increases the intensity of darker areas in a scene while compressing the intensity of brighter parts of the scene. The range and effect of this setting is implementation dependent but in general it translates into a numerical value that is added to each pixel with saturation.</li>
<li><i><dfn>Contrast</dfn></i> is the numeric camera setting that controls the difference in brightness between light and dark areas in a scene. A higher contrast setting reflects an expansion in the difference in brightness. The range and effect of this setting is implementation dependent but it can be understood as a transformation of the pixel values so that the luma range in the histogram becomes larger; the transformation is sometimes as simple as a gain factor.</li>
<li>[[LIGHTING-VOCABULARY]] defines <i><dfn>saturation</dfn></i> as "the colourfulness of an area judged in proportion to its brightness" and in the current context it refers to a numeric camera setting that controls the intensity of color in a scene (i.e. the amount of gray in the scene). Very low saturation levels will result in photos closer to black-and-white. Saturation is similar to <a>contrast</a> but referring to colors, so its implementation, albeit being platform dependent, can be understood as a gain factor applied to the chroma components of a given image.</li>
<li><i><dfn>Sharpness</dfn></i> is a numeric camera setting that controls the intensity of edges in a scene. Higher sharpness settings result in higher contrast along the edges, while lower settings result in less contrast and blurrier edges (i.e. soft focus). The implementation is platform dependent, but it can be understood as the linear combination of an edge detection operation applied on the original image and the original image itself; the relative weights being controlled by this <a>sharpness</a>.
<div class="note">
<a>Brightness</a>, <a>contrast</a>, <a>saturation</a> and <a>sharpness</a> are specified in [[UVC]].
</div></li>
<li><dfn>Image width</dfn> and <dfn>image height</dfn> represent the supported/desired resolution of the resulting photographic image after any potential sensor corrections and other algorithms are run.
<div class="note">
The supported resolutions are managed segregated e.g. {{PhotoCapabilities/imageWidth}} and {{PhotoCapabilities/imageHeight}} values/ranges to prevent increasing the fingerprinting surface and to allow the UA to make a best-effort decision with regards to actual hardware configuration vis-a-vis requested constraints.
</div>
</li>
<li><dfn>Focus distance</dfn> is a numeric camera setting that controls the focus distance of the lens. The setting usually represents distance in meters to the optimal focus distance.</li>
<li><dfn>Pan</dfn> is a numeric camera setting that controls the pan of the camera. The setting represents pan in arc seconds, which are 1/3600th of a degree. Values are in the range from -180\*3600 arc seconds to +180\*3600 arc seconds. Positive values pan the camera clockwise as viewed from above, and negative values pan the camera counter clockwise as viewed from above.
Constraints on pan influence camera selection through <a>fitness distance</a> toward cameras with the ability to pan. To exert this influence without overwriting the current pan setting, pan may be constrained to true. Conversely, constraining it to false disfavors cameras with the ability to pan.
Any algorithm which uses a {{MediaTrackConstraintSet}} object whose {{MediaTrackConstraintSet/pan}} dictionary member exists with a value other than false MUST either [=request permission to use=] (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true, or decide not to expose the pan setting.
If the {{Document/visibilityState}} of the <a>top-level browsing context</a> value is "hidden", the {{MediaStreamTrack/applyConstraints()}} algorithm MUST throw a {{SecurityError}} if {{MediaTrackConstraintSet/pan}} dictionary member exists with a value other than false.</li>
<li><dfn>Tilt</dfn> is a numeric camera setting that controls the tilt of the camera. The setting represents tilt in arc seconds, which are 1/3600th of a degree. Values are in the range from -180\*3600 arc seconds to +180\*3600 arc seconds. Positive values tilt the camera upward when viewed from the front, and negative values tilt the camera downward as viewed from the front.
Constraints on tilt influence camera selection through <a>fitness distance</a> toward cameras with the ability to tilt. To exert this influence without overwriting the current tilt setting, tilt may be constrained to true. Conversely, constraining it to false disfavors cameras with the ability to tilt.
Any algorithm which uses a {{MediaTrackConstraintSet}} object whose {{MediaTrackConstraintSet/tilt}} dictionary member exists with a value other than false MUST either [=request permission to use=] (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true, or decide not to expose the tilt setting.
If the {{Document/visibilityState}} of the <a>top-level browsing context</a> value is "hidden", the {{MediaStreamTrack/applyConstraints()}} algorithm MUST throw a {{SecurityError}} if {{MediaTrackConstraintSet/tilt}} dictionary member exists with a value other than false.
<div class="note">
There is no defined order when applying <a>pan</a> and <a>tilt</a>, the UA is allowed to apply them in any order. In practice this should not matter since these values are absolute, so order will not affect the final position. However, if applying pan and tilt is slow enough, the order in which they are applied may be visually noticeable.
</div></li>
<li><dfn>Zoom</dfn> is a numeric camera setting that controls the focal length of the lens. The setting usually represents a ratio, e.g. 4 is a zoom ratio of 4:1. The minimum value is usually 1, to represent a 1:1 ratio (i.e. no zoom).
Constraints on zoom influence camera selection through <a>fitness distance</a> toward cameras with the ability to zoom. To exert this influence without overwriting the current zoom setting, zoom may be constrained to true. Conversely, constraining it to false disfavors cameras with the ability to zoom.
Any algorithm which uses a {{MediaTrackConstraintSet}} object whose {{MediaTrackConstraintSet/zoom}} dictionary member exists with a value other than false MUST either [=request permission to use=] (as defined in [[!permissions]]) a {{PermissionDescriptor}} with its name member set to <a permission>camera</a> and its {{CameraDevicePermissionDescriptor/panTiltZoom}} member set to true, or decide not to expose the zoom setting.
If the {{Document/visibilityState}} of the <a>top-level browsing context</a> value is "hidden", the {{MediaStreamTrack/applyConstraints()}} algorithm MUST throw a {{SecurityError}} if {{MediaTrackConstraintSet/zoom}} dictionary member exists with a value other than false.</li>
<li><dfn>Fill light mode</dfn> describes the flash setting of the capture device (e.g. `auto`, `off`, `on`). <dfn>Torch</dfn> describes the setting of the source's fill light as continuously connected, staying on as long as {{track}} is active.</li>
</ol>
# {{MeteringMode}} # {#meteringmode-section}
<pre class="idl">
enum MeteringMode {
"none",
"manual",
"single-shot",
"continuous"
};
</pre>
## Values ## {#meteringmode-values}
<dl class="domintro">
<dt><dfn enum-value for="MeteringMode"><code>none</code></dfn></dt>
<dd>This source does not offer focus/exposure/white balance mode. For setting, this is interpreted as a command to turn off the feature.</dd>
<dt><dfn enum-value for="MeteringMode"><code>manual</code></dfn></dt>
<dd>The capture device is set to manually control the lens position/exposure time/white balance, or such a mode is requested to be configured.</dd>
<dt><dfn enum-value for="MeteringMode"><code>single-shot</code></dfn></dt>
<dd>The capture device is configured for single-sweep autofocus/one-shot exposure/white balance calculation, or such a mode is requested.</dd>
<dt><dfn enum-value for="MeteringMode"><code>continuous</code></dfn></dt>
<dd>The capture device is configured for continuous focusing for near-zero shutter-lag/continuous auto exposure/white balance calculation, or such continuous focus hunting/exposure/white balance calculation mode is requested.</dd>
</dl>
# {{Point2D}} # {#point2d-section}
A {{Point2D}} represents a location in a two dimensional space. The origin of coordinates is situated in the upper leftmost corner of the space.
<pre class="idl">
dictionary Point2D {
double x = 0.0;
double y = 0.0;
};
</pre>
## Members ## {#point2d-members}
<dl class="domintro">
<dt><dfn dict-member for="Point2D"><code>x</code></dfn></dt>
<dd>Value of the horizontal (abscissa) coordinate.</dd>
<dt><dfn dict-member for="Point2D"><code>y</code></dfn></dt>
<dd>Value of the vertical (ordinate) coordinate.</dd>
</dl>
# Examples # {#examples}
<div class="note">
Slightly modified versions of these examples can be found in e.g. <a href="https://codepen.io/collection/nLeobQ/">this codepen collection</a>.
</div>
## Update camera pan, tilt and zoom and {{takePhoto()}} ## {#example1}
<div class="note">
The following example can also be found in e.g. <a href="https://codepen.io/eehakkin/pen/XWbOVxp/left?editors=1010">this codepen</a> with minimal modifications.
</div>
<div class="example" highlight="javascript">
<pre>
<html>
<body>
<video autoplay></video>
<img>
<div>
<input id="pan" title="Pan" type="range" disabled />
<label for="pan">Pan</label>
</div>
<div>
<input id="tilt" title="Tilt" type="range" disabled />
<label for="tilt">Tilt</label>
</div>
<div>
<input id="zoom" title="Zoom" type="range" disabled />
<label for="zoom">Zoom</label>
</div>
<script>
let imageCapture;
async function getMedia() {
try {
const stream = await navigator.mediaDevices.getUserMedia({
video: {pan: true, tilt: true, zoom: true},
});
const video = document.querySelector('video');
video.srcObject = stream;
const [track] = stream.getVideoTracks();
imageCapture = new ImageCapture(track);
const capabilities = track.getCapabilities();
const settings = track.getSettings();
for (const ptz of ['pan', 'tilt', 'zoom']) {
// Check whether pan/tilt/zoom is available or not.
if (!(ptz in settings)) continue;
// Map it to a slider element.
const input = document.getElementById(ptz);
input.min = capabilities[ptz].min;
input.max = capabilities[ptz].max;
input.step = capabilities[ptz].step;
input.value = settings[ptz];
input.disabled = false;
input.oninput = async event => {
try {
// Warning: Chrome requires advanced constraints.
await track.applyConstraints({[ptz]: input.value});
} catch (err) {
console.error("applyConstraints() failed: ", err);
}
};
}
} catch (err) {
console.error(err);
}
}
async function takePhoto() {
try {
const blob = await imageCapture.takePhoto();
console.log("Photo taken: " + blob.type + ", " + blob.size + "B");
const image = document.querySelector('img');
image.src = URL.createObjectURL(blob);
} catch (err) {
console.error("takePhoto() failed: ", err);
}
}
</script>
</body>
</html>
</pre>
</div>
## Repeated grabbing of a frame with {{grabFrame()}} ## {#example2}
<div class="note">
The following example can also be found in e.g. <a href="https://codepen.io/miguelao/pen/wzxxwp/left?editors=1010">this codepen</a> with minimal modifications.
</div>
<div class="example" highlight="javascript">
<pre>
<html>
<body>
<canvas></canvas>
<button id="stopButton">Stop frame grab</button>
<script>
async function grabFrames() {
try {
const canvas = document.querySelector('canvas');
const video = document.querySelector('video');
const stream = await navigator.mediaDevices.getUserMedia({video: true});
video.srcObject = stream;
const [track] = stream.getVideoTracks();
try {