forked from w3c/mediacapture-depth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.src.html
1516 lines (1492 loc) · 60.2 KB
/
index.src.html
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
<!DOCTYPE html>
<html>
<head>
<title>
Media Capture Depth Stream Extensions
</title>
<meta charset="utf-8">
<script src="https://www.w3.org/Tools/respec/respec-w3c-common" class=
"remove">
</script>
<script class="remove">
var respecConfig = {
specStatus: "ED",
shortName: "mediacapture-depth",
previousPublishDate: "2015-12-08",
previousMaturity: "WD",
edDraftURI: "https://w3c.github.io/mediacapture-depth/",
editors: [
{
w3cid: "41974",
name: "Anssi Kostiainen",
company: "Intel",
companyURL: "http://www.intel.com/"
},
{
w3cid: "68202",
name: "Ningxin Hu",
company: "Intel",
companyURL: "http://www.intel.com/"
},
{
w3cid: "95320",
name: "Aleksandar Stojiljkovic",
company: "Intel",
companyURL: "http://www.intel.com/"
},
{
w3cid: "76096",
name: "Rob Manson",
company: "Invited Expert"
}
],
wg: [
"Web Real-Time Communications Working Group"
],
wgURI: [
"https://www.w3.org/2011/04/webrtc/"
],
wgPublicList: "public-media-capture",
wgPatentURI: [
"https://www.w3.org/2004/01/pp-impl/47318/status"
],
otherLinks: [{
key: "Participate",
data: [
{
value: "[email protected]",
href: "https://lists.w3.org/Archives/Public/public-media-capture/"
},
{
value: "GitHub w3c/mediacapture-depth",
href: "https://github.com/w3c/mediacapture-depth/"
},
{
value: "GitHub w3c/mediacapture-depth/issues",
href: "https://github.com/w3c/mediacapture-depth/issues"
},
{
value: "GitHub w3c/mediacapture-depth/commits",
href: "https://github.com/w3c/mediacapture-depth/commits/"
}
]
},
{
key: "Implementation status",
data: [{
value: "Blink",
href: "https://crbug.com/616098"
}]
}],
localBiblio: {
"WEBGL2": {
title: "WebGL 2 Specification",
href: "https://www.khronos.org/registry/webgl/specs/2.0.0/",
authors: [
"Dean Jackson (Apple Inc.)",
"Jeff Gilbert (Mozilla Corp.)"
],
"date": "1 December 2016",
publisher: "Khronos"
},
"OpenGL ES 3.0.5": {
title: "OpenGL ES 3.0.5 Specification",
href: "http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.5.pdf",
authors: [
"Jon Leech",
"Benj Lipchak"
],
"date": "3 November 2016",
publisher: "Khronos"
},
"WEBGL-GET-BUFFER-SUB-DATA-ASYNC": {
title: "WebGL WEBGL_get_buffer_sub_data_async Extension Draft Specification",
href: "https://www.khronos.org/registry/webgl/extensions/WEBGL_get_buffer_sub_data_async/",
authors: [
"Kai Ninomiya, Google Inc.",
"Members of WebGL working group"
],
"date": "13 December 2016",
publisher: "Khronos"
}
}
};
</script>
<script src=
"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_CHTML">
</script>
<style>
/* workaround to hide redundant dfns */
p.related { visibility: hidden; height: 0px; }
</style>
</head>
<body>
<section id="abstract">
<p>
This specification <a href=
"https://w3c.github.io/mediacapture-main/#extensibility">extends</a>
the <em>Media Capture and Streams</em> specification [[!GETUSERMEDIA]]
to allow a <a>depth-only stream</a> or combined <a>depth+color
stream</a> to be requested from the web platform using APIs familiar to
web authors.
</p>
</section>
<section id="sotd">
<p>
This extensions specification defines a new media type and
constrainable property per <a href=
"https://w3c.github.io/mediacapture-main/#extensibility">Extensibility</a>
guidelines of the <em>Media Capture and Streams</em> specification
[[!GETUSERMEDIA]]. Horizontal reviews and feedback from early
implementations of this specification are encouraged.
</p>
</section>
<section>
<h2>
Introduction
</h2>
<p>
Depth cameras are increasingly being integrated into devices such as
phones, tablets, and laptops. Depth cameras provide a <a>depth map</a>,
which conveys the distance information between points on an object's
surface and the camera. With depth information, web content and
applications can be enhanced by, for example, the use of hand gestures
as an input mechanism, or by creating 3D models of real-world objects
that can interact and integrate with the web platform. Concrete
applications of this technology include more immersive gaming
experiences, more accessible 3D video conferences, and augmented
reality, to name a few.
</p>
<p>
To bring depth capability to the web platform, this specification
<a href=
"https://w3c.github.io/mediacapture-main/#extensibility">extends</a>
the <a>MediaStream</a> interface [[!GETUSERMEDIA]] to enable it to also
contain depth-based <a>MediaStreamTrack</a>s. A depth-based
<a>MediaStreamTrack</a>, referred to as a <a>depth stream track</a>,
represents an abstraction of a stream of frames that can each be
converted to objects which contain an array of pixel data, where each
pixel represents the distance between the camera and the objects in the
scene for that point in the array. A <a>MediaStream</a> object that
contains one or more <a>depth stream track</a>s is referred to as a
<a>depth-only stream</a> or <a>depth+color stream</a>.
</p>
</section>
<section>
<h2>
Use cases and requirements
</h2>
<p>
This specification attempts to address the <a href=
"https://www.w3.org/wiki/Media_Capture_Depth_Stream_Extension">Use
Cases and Requirements</a> for accessing depth stream from a depth
camera. See also the <a href=
"https://www.w3.org/wiki/Media_Capture_Depth_Stream_Extension#Examples">
Examples</a> section for concrete usage examples.
</p>
</section>
<section id="conformance">
<p>
This specification defines conformance criteria that apply to a single
product: the <dfn>user agent</dfn> that implements the interfaces that
it contains.
</p>
<p>
Implementations that use ECMAScript to implement the APIs defined in
this specification must implement them in a manner consistent with the
ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]],
as this specification uses that specification and terminology.
</p>
</section>
<section>
<h2>
Dependencies
</h2>
<p>
The <dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaStreamTrack"><code>MediaStreamTrack</code></dfn>
and <dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaStream"><code>MediaStream</code></dfn>
interfaces this specification extends are defined in [[!GETUSERMEDIA]].
</p>
<p>
The concepts <dfn data-cite=
"!GETUSERMEDIA#dfn-constraints"><code>Constraints</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#dfn-capabilities"><code>Capabilities</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-ConstraintSet"><code>ConstraintSet</code></dfn>,
and <dfn data-cite=
"!GETUSERMEDIA#dfn-settings"><code>Settings</code></dfn>, and
<dfn data-cite="!GETUSERMEDIA#types-for-constrainable-properties">types
of constrainable properties</dfn> are defined in [[!GETUSERMEDIA]].
</p>
<p>
The <dfn data-cite=
"!GETUSERMEDIA#idl-def-ConstrainDOMString"><code>ConstrainDOMString</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-ConstrainDouble"><code>ConstrainDouble</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-ConstrainBoolean"><code>ConstrainBoolean</code></dfn>,
and <dfn data-cite=
"!GETUSERMEDIA#idl-def-DoubleRange"><code>DoubleRange</code></dfn>
types are defined in [[!GETUSERMEDIA]].
</p>
<p>
<dfn data-cite=
"GETUSERMEDIA#idl-def-MediaTrackSettings"><code>MediaTrackSettings</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaTrackConstraints"><code>MediaTrackConstraints</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaTrackSupportedConstraints"><code>MediaTrackSupportedConstraints</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaTrackCapabilities"><code>MediaTrackCapabilities</code></dfn>,
and <dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaTrackConstraintSet"><code>MediaTrackConstraintSet</code></dfn>
dictionaries this specification extends are defined in
[[!GETUSERMEDIA]].
</p>
<p>
The <dfn data-cite=
"!GETUSERMEDIA#dom-mediadevices-getusermedia"><code>getUserMedia()</code></dfn>,
<dfn data-cite=
"!GETUSERMEDIA#dfn-getsettings"><code>getSettings()</code></dfn>
methods and the <dfn data-cite=
"!GETUSERMEDIA#idl-def-NavigatorUserMediaSuccessCallback"><code>NavigatorUserMediaSuccessCallback</code></dfn>
callback are defined in [[!GETUSERMEDIA]].
</p>
<p>
The concepts <dfn data-cite="!GETUSERMEDIA#track-muted">muted</dfn>,
<dfn data-cite="!GETUSERMEDIA#track-enabled">disabled</dfn>, and
<dfn data-cite=
"!GETUSERMEDIA#event-mediastreamtrack-overconstrained"><code>overconstrained</code></dfn>
as applied to <a>MediaStreamTrack</a> are defined in [[!GETUSERMEDIA]].
</p>
<p>
The terms <dfn data-cite="!GETUSERMEDIA#dfn-source">source</dfn> and
<dfn data-cite="!GETUSERMEDIA#dfn-consumer">consumer</dfn> are defined
in [[!GETUSERMEDIA]].
</p>
<p>
The <dfn data-cite=
"!GETUSERMEDIA#idl-def-MediaDeviceKind"><code>MediaDeviceKind</code></dfn>
enumeration is defined in [[!GETUSERMEDIA]].
</p>
<p>
The <dfn data-cite="!HTML#the-video-element"><code>video</code></dfn>
element and <dfn data-cite=
"!HTML#imagedata"><code>ImageData</code></dfn> (and its <dfn data-cite=
"!HTML#dom-imagedata-data"><code>data</code></dfn> attribute and
<dfn data-cite="!HTML#canvas-pixel-arraybuffer">Canvas Pixel
<code>ArrayBuffer</code></dfn>), <dfn data-cite=
"!HTML#videotrack"><code>VideoTrack</code></dfn>, <dfn data-cite=
"!HTML#htmlmediaelement"><code>HTMLMediaElement</code></dfn> (and its
<dfn data-cite="!HTML#dom-media-srcobject"><code>srcObject</code></dfn>
attribute), <dfn data-cite=
"!HTML#htmlvideoelement"><code>HTMLVideoElement</code></dfn> interfaces
and the <dfn data-cite=
"!HTML#canvasimagesource"><code>CanvasImageSource</code></dfn> enum are
defined in [[!HTML]].
</p>
<p>
The terms <dfn data-cite="!HTML#media-data">media data</dfn>,
<dfn data-cite="!HTML#media-provider-object">media provider
object</dfn>, <dfn data-cite=
"!HTML#assigned-media-provider-object">assigned media provider
object</dfn>, and the concept <dfn data-cite=
"!HTML#potentially-playing">potentially playing</dfn> are defined in
[[!HTML]].
</p>
<p>
The term <dfn data-cite="!PERMISSIONS#permission">permission</dfn> and
the permission name "<dfn data-cite=
"!PERMISSIONS#dom-permissionname-camera"><code>camera</code></dfn>" are
defined in [[!PERMISSIONS]].
</p>
<p>
The <dfn data-cite="!WEBIDL#idl-DataView"><code>DataView</code></dfn>,
<dfn data-cite=
"!WEBIDL#idl-Uint8ClampedArray"><code>Uint8ClampedArray</code></dfn>,
and <code><dfn data-cite=
"!WEBIDL#idl-Uint16Array">Uint16Array</dfn></code> buffer source types
are defined in [[WEBIDL]].
</p>
<p>
The meaning of dictionary member being <dfn data-cite=
"!WEBIDL#dfn-present">present</dfn> or <dfn data-cite=
"!WEBIDL#dfn-present">not present</dfn>, and its <dfn data-cite=
"!WEBIDL#dfn-dictionary-member-default-value">default value</dfn> are
defined in [[WEBIDL]].
</p>
</section>
<section>
<h2>
Terminology
</h2>
<p>
The term <dfn>depth+color stream</dfn> means a <a>MediaStream</a>
object that contains one or more <a>MediaStreamTrack</a> objects whose
<code>videoKind</code> of <code>Settings</code> is "<code>depth</code>"
(<a>depth stream track</a>) and one or more <a>MediaStreamTrack</a>
objects whose <code>videoKind</code> of <code>Settings</code> is
"<code>color</code>" (<a>color stream track</a>).
</p>
<p>
The term <dfn>depth-only stream</dfn> means a <a>MediaStream</a> object
that contains one or more <a>MediaStreamTrack</a> objects whose
<code>videoKind</code> of <code>Settings</code> is "<code>depth</code>"
(<a>depth stream track</a>) only.
</p>
<p>
The term <dfn>color-only stream</dfn> means a <a>MediaStream</a> object
that contains one or more <a>MediaStreamTrack</a> objects whose
<code>videoKind</code> of <code>Settings</code> is "<code>color</code>"
(<a>color stream track</a>) only, and optionally of kind
"<code>audio</code>".
</p>
<p>
The term <dfn>depth stream track</dfn> means a <a>MediaStreamTrack</a>
object whose <code>videoKind</code> of <code>Settings</code> is
"<code>depth</code>". It represents a media stream track whose
<a>source</a> is a depth camera.
</p>
<p>
The term <dfn>color stream track</dfn> means a <a>MediaStreamTrack</a>
object whose <code>videoKind</code> of <code>Settings</code> is
"<code>color</code>". It represents a media stream track whose
<a>source</a> is a color camera.
</p>
<section>
<h2>
Depth map
</h2>
<p>
A <dfn>depth map</dfn> is an abstract representation of a frame of a
<a>depth stream track</a>. A <a>depth map</a> is a two-dimensional
array that contains information relating to the perpendicular
distance of the surfaces of scene objects to camera's <a>near
plane</a>. The numeric values in the <a>depth map</a> are referred to
as <dfn data-lt="depth map value">depth map values</dfn> and
represent distances to <a>near plane</a> <a>normalized</a> against
the distance between <a href="#dfn-far-plane">far</a> and <a href=
"#dfn-near-plane">near</a> plane.
</p>
<p>
<dfn>Normalized</dfn> <a>depth map value</a> means that it's range is
from 0 to 1, where maximum <a>depth map value</a> of 1 corresponds to
distances equal to <a>far value</a>. Following the <a href=
"#dfn-calculate-depth-map-value">conversion between depth map value
and distance</a>, the minumum value of 0 would correspond to
distances equal to <a>near value</a>, but 0 has a special meaning -
it is an <dfn>invalid depth map value</dfn> and represents that the
user agent is unable to acquire depth information for the given pixel
for any reason. <a>Normalized</a> <a>depth map value</a> is
represented using <dfn>floating-point</dfn> or <dfn>unsigned
fixed-point</dfn> formats <a href=
"https://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.5.pdf#subsection.2.1.6">
[OpenGL ES 3.0.5]#subsection.2.1.6</a>.
</p>
<p>
A <a>depth map</a> has an associated <dfn>near value</dfn> which is a
double. It represents the minimum range in meters and it defines
<dfn>near plane</dfn> which is a plane perpendicular to camera
viewing direction on distance <a>near value</a> from the camera
origin.
</p>
<p>
A <a>depth map</a> has an associated <dfn>far value</dfn> which is a
double. It represents the maximum range in meters. It represents the
minimum range in meters and it defines <dfn>far plane</dfn> which is
a plane perpendicular to camera viewing direction on distance <a>far
value</a> from the camera origin.
</p>
<p>
A <a>depth map</a> has an associated <dfn>horizontal focal
length</dfn> which is a double. It represents the horizontal
<dfn>focal length</dfn> of the depth camera, in pixels.
</p>
<p>
A <a>depth map</a> has an associated <dfn>vertical focal length</dfn>
which is a double. It represents the vertical focal length of the
depth camera, in pixels.
</p>
<p>
A <a>depth map</a> has an associated <dfn>principal point</dfn>,
specified by <dfn>principal point x</dfn> and <dfn>principal point
y</dfn> coordinates which are double. It is a concept defined in the
pinhole camera model; a projection of perspective center to the image
plane.
</p>
<p>
A <a>depth map</a> has an associated <dfn>transformation from depth
to video</dfn>, which is a <dfn>transformation matrix</dfn>
represented by a <a>Transformation</a> dictionary. It is used to
translate position in depth camera 3D coordinate system to RGB video
stream's camera (identified by <dfn>videoDeviceId</dfn>) 3D
coordinate system. After projecting depth 2D pixel coordinates to 3D
space, we use this matrix to transform depth camera 3D space
coordinates to RGB video camera 3D space.
</p>
<p>
Both depth and color cameras usually introduce significant distortion
caused by the camera and lens. While in some cases, the effects are
not noticeable, these distortions cause errors in image analysis. To
map <a>depth map</a> pixel values to corresponding color video track
pixels, we use two <a>DistortionCoefficients</a> dictionaries:
<dfn>deprojection distortion coefficients</dfn> and <dfn>projection
distortion coefficients</dfn>.
</p>
<p>
<a>Deprojection distortion coefficients</a> are used for compensating
camera distortion when deprojecting 2D pixel coordinates to 3D space
coordinates. <a>Projection distortion coefficients</a> are used in
the opposite case, when projecting camera 3D space points to pixels.
One track doesn't have both of the coefficients specified. The most
common scenario is that the depth track has <a>deprojection
distortion coefficients</a> or that the color video track has
<a>projection distortion coefficients</a>. For the details, see
<a>algorithm to map depth pixels to color pixels</a>.
</p>
</section>
</section>
<section>
<h2>
Conversion between depth map value and distance
</h2>
<p>
A <a>depth map value</a> is a distance to <a>near plane</a>
<a>normalized</a> against the distance between <a href=
"#dfn-far-plane">far</a> and <a href="#dfn-near-plane">near</a> plane:
</p>
<ul>
<li>Let <var>near</var> be the the <a>near value</a>.
</li>
<li>Let <var>far</var> be the the <a>far value</a>.
</li>
<li>Let <var>d</var> be the the distance to <a>near plane</a>.
</li>
<li>Let <var>depth</var> be the the <a>depth map value</a>.
</li>
<li>The formula to <dfn>calculate depth map value</dfn>
<var>depth</var> for the given distance <var>d</var> is:
<p>
`depth = (d - n ear) / (far - n ear)`
</p>
</li>
<li>If the distance <var>d</var> is greater than <a>far value</a>, the
depth is <a>invalid depth map value</a>.
</li>
<li>The formula to <dfn>convert the depth map value to distance</dfn>
<var>d</var>, for a <a>depth map value</a> <var>depth</var>, is as
follows:
<p>
`d = depth * (far - n ear) + n ear`
</p>
</li>
</ul>
</section>
<section>
<h2>
Extensions
</h2>
<p>
If the implementation is unable to report the value represented by any
of the dictionary members, they are not <a>present</a> in the
dictionary.
</p>
<section>
<h2>
<a>MediaTrackSupportedConstraints</a> dictionary
</h2>
<p>
<a>MediaTrackSupportedConstraints</a> dictionary represents the list
of <a>Constraints</a> recognized by a <a>user agent</a> for
controlling the <a>Capabilities</a> of a <a>MediaStreamTrack</a>
object.
</p>
<p>
Partial dictionary <a>MediaTrackSupportedConstraints</a> extends the
original dictionary defined in [[!GETUSERMEDIA]]. The dictionary
value true represents an <a>applicable constraint</a>.
</p>
<p>
An <dfn>applicable constraint</dfn> is not omitted by the <a>user
agent</a> in step 6.2.2 in the <a>getUserMedia()</a> algorithm.
</p>
<pre class="idl">
partial dictionary MediaTrackSupportedConstraints {
// Apply to both depth stream track and color stream track:
boolean videoKind = true;
boolean focalLengthX = false;
boolean focalLengthY = false;
boolean principalPointX = false;
boolean principalPointY = false;
boolean deprojectionDistortionCoefficients = false;
boolean projectionDistortionCoefficients = false;
// Apply to depth stream track:
boolean depthNear = false;
boolean depthFar = false;
boolean depthToVideoTransform = false;
};
</pre>
</section>
<section>
<h2>
<a>MediaTrackCapabilities</a> dictionary
</h2>
<p>
<a>MediaTrackCapabilities</a> dictionary represents the
<a>Capabilities</a> of a <a>MediaStreamTrack</a> object.
</p>
<p>
Partial dictionary <a>MediaTrackCapabilities</a> extends the original
<a>MediaTrackCapabilities</a> dictionary defined in
[[!GETUSERMEDIA]].
</p>
<pre class="idl">
partial dictionary MediaTrackCapabilities {
// Apply to both depth stream track and color stream track:
DOMString videoKind;
(double or DoubleRange) focalLengthX;
(double or DoubleRange) focalLengthY;
(double or DoubleRange) principalPointX;
(double or DoubleRange) principalPointY;
boolean deprojectionDistortionCoefficients;
boolean projectionDistortionCoefficients;
// Apply to depth stream track:
(double or DoubleRange) depthNear;
(double or DoubleRange) depthFar;
boolean depthToVideoTransform;
};
</pre>
</section>
<section>
<h2>
<code>MediaTrackConstraintSet</code> dictionary
</h2>
<p>
<a>ConstraintSet</a> dictionary specifies each member's set of
<a>allowed values</a>.
</p>
<p>
The <dfn>allowed values</dfn> for <a>ConstrainDOMString</a>,
<a>ConstrainDouble</a>, and <a>ConstrainBoolean</a> types are defined
in [[!GETUSERMEDIA]] respectively.
</p>
<pre class="idl">
partial dictionary MediaTrackConstraintSet {
// Apply to both depth stream track and color stream track:
ConstrainDOMString videoKind;
ConstrainDouble focalLengthX;
ConstrainDouble focalLengthY;
ConstrainDouble principalPointX;
ConstrainDouble principalPointY;
ConstrainBoolean deprojectionDistortionCoefficients;
ConstrainBoolean projectionDistortionCoefficients;
// Apply to depth stream track:
ConstrainDouble depthNear;
ConstrainDouble depthFar;
ConstrainBoolean depthToVideoTransform;
};
</pre>
</section>
<section>
<h2>
<code>MediaTrackSettings</code> dictionary
</h2>
<p>
<a>MediaTrackSettings</a> dictionary represents the <a>Settings</a>
of a <a>MediaStreamTrack</a> object.
</p>
<p>
Partial dictionary <a>MediaTrackSettings</a> extends the original
<a>MediaTrackSettings</a> dictionary.
</p>
<pre class="idl">
partial dictionary MediaTrackSettings {
// Apply to both depth stream track and color stream track:
DOMString videoKind;
double focalLengthX;
double focalLengthY;
double principalPointX;
double principalPointY;
DistortionCoefficients deprojectionDistortionCoefficients;
DistortionCoefficients projectionDistortionCoefficients;
// Apply to depth stream track:
double depthNear;
double depthFar;
Transformation depthToVideoTransform;
};
</pre>
<section>
<h2>
<code>DistortionCoefficients</code> dictionary
</h2>
<pre class="idl">
dictionary DistortionCoefficients {
double k1;
double k2;
double p1;
double p2;
double k3;
};
</pre>
<div data-dfn-for="DistortionCoefficients">
<p>
The <dfn><code>DistortionCoefficients</code></dfn> dictionary has
the <dfn>k1</dfn>, <dfn>k2</dfn>, <dfn>p1</dfn>, <dfn>p2</dfn>
and <dfn>k3</dfn> dictionary members that represent the
<a>deprojection distortion coefficients</a> or <a>projection
distortion coefficients</a>. <dfn data-dfn-for="k1">k1</dfn>,
<dfn data-dfn-for="k2">k2</dfn> and <dfn data-dfn-for=
"k3">k3</dfn> are <dfn>radial distortion coefficients</dfn> while
<dfn data-dfn-for="p1">p1</dfn> and <dfn data-dfn-for=
"p2">p2</dfn> are <dfn>tangential distortion coefficients</dfn>.
<a>Radial distortion coefficients</a> and <a>tangential
distortion coefficients</a> are used to <a>deproject</a> depth
value to 3D space or to <a>project</a> 3D value to 2D video frame
coordinates.
</p>
<p class="note">
See the <a>algorithm to map depth pixels to color pixels</a> and
Brown-Conrady distortion model implementation in <a>3D point
cloud rendering</a> example GLSL shader.<br>
</p>
</div>
</section>
<section>
<h2>
<code>Transformation</code> dictionary
</h2>
<pre class="idl">
dictionary Transformation {
Float32Array transformationMatrix;
DOMString videoDeviceId;
};
</pre>
<div data-dfn-for="Transformation">
<p>
The <dfn><code>Transformation</code></dfn> dictionary has the
<dfn><code>transformationMatrix</code></dfn> dictionary member
that is a 16 element array that defines the <a>transformation
matrix</a> of the <a>depth map</a>'s camera's 3D coordinate
system to video track's camera 3D coordinate system.
</p>
<p>
The first four elements of the array correspond to the first
matrix row, followed by four elements of the second matrix row
and so on. It is in format suitable for use with WebGL's
uniformMatrix4fv.
</p>
<p>
The <dfn><code>videoDeviceId</code></dfn> dictionary member
represents the <code>deviceId</code> of video camera the depth
stream must be synchronized with.
</p>
<p class="note">
The value of <a><code>videoDeviceId</code></a> can be used as the
<code>deviceId</code> constraint in [[!GETUSERMEDIA]] to get the
corresponding video and audio streams.
</p>
</div>
</section>
</section>
<section>
<h2>
Constrainable properties for color stream track and depth stream
track
</h2>
<p>
The following constrainable properties are defined to apply to both
<a>color stream track</a> and <a>depth stream track</a>.
</p>
<section id="def-constraint-videoKind">
<h3>
<code>videoKind</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">videoKind</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">videoKind</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">videoKind</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">videoKind</dfn>
</p>
<p>
The <code>videoKind</code> member specifies the <dfn>video
kind</dfn> of the <a>source</a>.
</p>
<pre class="idl">
enum VideoKindEnum {
"color",
"depth"
};
</pre>
<p>
The <dfn>VideoKindEnum</dfn> enumeration defines the valid <a>video
kind</a>s: <dfn data-dfn-for="VideoKindEnum">color</dfn> for
<a>color stream track</a> whose <a>source</a> is a color camera,
and <dfn data-dfn-for="VideoKindEnum">depth</dfn> for <a>depth
stream track</a> whose <a>source</a> is a depth camera.
</p>
<p>
The <a>MediaStream</a> <a>consumer</a> for the <a>depth-only
stream</a> and <a>depth+color stream</a> is <a href=
"#the-video-element">the <code>video</code> element</a> [[!HTML]].
</p>
<p>
If a <a>MediaStreamTrack</a> whose <code>videoKind</code> is
<a data-link-for="VideoKindEnum">depth</a> is <a>muted</a> or
<a>disabled</a>, it MUST render frames as if all the pixels would
be 0.
</p>
<div class="note">
<p>
A <a>color stream track</a> and a <a>depth stream track</a> can
be combined into one <a>depth+color stream</a>. The rendering of
the two tracks are intended to be synchronized. The resolution of
the two tracks are intended to be same. And the coordination of
the two tracks are intended to be calibrated. These are not hard
requirements, since it might not be possible to synchronize
tracks from sources.
</p>
<p>
This approach is simple to use but comes with the following
caveats: it might might not be supported by the implementation
and the resolutions of two tracks are intended to be the same
that can require downsampling and degrade quality. The
alternative approach is that a web developer implements the
<a>algorithm to map depth pixels to color pixels</a>. See the
<a>3D point cloud rendering</a> example code.
</p>
</div>
</section>
<section id="def-constraint-focalLengthX">
<h3>
<code>focalLengthX</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">focalLengthX</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">focalLengthX</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">focalLengthX</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">focalLengthX</dfn>
</p>
<p>
The <code>focalLengthX</code> member specifies the <a>horizontal
focal length</a>, in pixels.
</p>
</section>
<section id="def-constraint-focalLengthY">
<h3>
<code>focalLengthY</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">focalLengthY</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">focalLengthY</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">focalLengthY</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">focalLengthY</dfn>
</p>
<p>
The <code>focalLengthY</code> member specifies the <a>vertical
focal length</a>, in pixels.
</p>
</section>
<section id="def-constraint-principalPointX">
<h3>
<code>principalPointX</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">principalPointX</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">principalPointX</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">principalPointX</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">principalPointX</dfn>
</p>
<p>
The <code>principalPointX</code> member specifies the <a>principal
point x</a> coordinate, in pixels.
</p>
</section>
<section id="def-constraint-principalPointY">
<h3>
<code>principalPointY</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">principalPointY</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">principalPointY</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">principalPointY</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">principalPointY</dfn>
</p>
<p>
The <code>principalPointY</code> member specifies the <a>principal
point y</a> coordinate, in pixels.
</p>
</section>
<section id="def-constraint-deprojectionDistortionCoefficients">
<h3>
<code>deprojectionDistortionCoefficients</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">deprojectionDistortionCoefficients</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">deprojectionDistortionCoefficients</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">deprojectionDistortionCoefficients</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">deprojectionDistortionCoefficients</dfn>
</p>
<p>
The <code>deprojectionDistortionCoefficients</code> member
specifies the <a>MediaStreamTrack</a>'s <a>deprojection distortion
coefficients</a> used when deprojecting from 2D to 3D space.
</p>
</section>
<section id="def-constraint-projectionDistortionCoefficients">
<h3>
<code>projectionDistortionCoefficients</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">projectionDistortionCoefficients</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">projectionDistortionCoefficients</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">projectionDistortionCoefficients</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">projectionDistortionCoefficients</dfn>
</p>
<p>
The <code>projectionDistortionCoefficients</code> member specifies
the <a>MediaStreamTrack</a>'s <a>projection distortion
coefficients</a> used when deprojecting from 2D to 3D space.
</p>
</section>
</section>
<section>
<h2>
Constrainable properties for depth stream track
</h2>
<p>
The following constrainable properties are defined to apply only to
<a>depth stream track</a>.
</p>
<section id="def-constraint-depthNear-depthFar">
<h3>
<code>depthNear</code> and <code>depthFar</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">depthNear</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">depthNear</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">depthNear</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">depthNear</dfn>,
<a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">depthFar</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">depthFar</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">depthFar</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">depthFar</dfn>
</p>
<p>
The <code>depthNear</code> member specifies the <a>near value</a>,
in meters.
</p>
<p>
The <code>depthFar</code> member specifies the <a>far value</a>, in
meters.
</p>
<p>
The <code>depthNear</code> and <code>depthFar</code> constrainable
properties, when set, allow the implementation to pick the best
depth camera mode optimized for the range <code>[depthNear,
depthFar]</code> and help minimize the error introduced by the
lossy conversion from the depth value <var>d</var> to a quantized
d<sub>8bit</sub> and back to an approximation of the depth value
<var>d</var>.
</p>
<p>
If the <code>depthFar</code> property's value is less than the
<code>depthNear</code> property's value, the <a>depth stream
track</a> is <a>overconstrained</a>.
</p>
</section>
<section id="def-constraint-depthToVideoTransform">
<h3>
<code>depthToVideoTransform</code>
</h3>
<p class="related">
Related: <a>MediaTrackSupportedConstraints</a>.<dfn data-dfn-for=
"MediaTrackSupportedConstraints">depthToVideoTransform</dfn>,
<a>MediaTrackCapabilities</a>.<dfn data-dfn-for=
"MediaTrackCapabilities">depthToVideoTransform</dfn>,
<a>MediaTrackConstraintSet</a>.<dfn data-dfn-for=
"MediaTrackConstraintSet">depthToVideoTransform</dfn>,
<a>MediaTrackSettings</a>.<dfn data-dfn-for=
"MediaTrackSettings">depthToVideoTransform</dfn>
</p>
<p>
The <code>depthToVideoTransform</code> member specifies the
<a>depth map</a>'s camera's <a>transformation from depth to
video</a> camera 3D coordinate system.
</p>
</section>
</section>
<section class="informative">
<h2>
WebGL implementation considerations
</h2>
<div class="note">
This section is currently work in progress, and subject to change.
</div>
<p>
<a>Depth map</a> values that the camera produces are often in 16-bit
<a>normalized</a> <a>unsigned fixed-point</a> format. Application
developer can access the data using <a>canvas pixel arraybuffer</a>
red color component, but that would cause a precision loss given that
it is in 8-bit <a>normalized</a> <a>unsigned fixed-point</a> format.
</p>
<p>
The same precision loss is related to usage of [[WEBGL]]
<code>UNSIGNED_BYTE</code> textures. In order to access the full
precision, application developer <a href="#dfn-uploaded">can use</a>
[[WEBGL]] <a>floating-point</a> textures.
</p>
<p>
There are several use-cases which are a good fit to be, at least
partially, implemented on the GPU, such as motion recognition,
pattern recognition, background removal, as well as 3D point cloud.
</p>
<p>
This section explains which APIs can be used for some of these
mentioned use-cases; the concrete examples are provided in the
<a href="#examples">Examples</a> section.
</p>
<section>
<h3>
Upload video frame to WebGL texture
</h3>
<p>
A <a>video</a> element whose source is a <a>MediaStream</a> object
containing a <a>depth stream track</a> may be <dfn>uploaded</dfn>