-
Notifications
You must be signed in to change notification settings - Fork 3
/
gumz.html
65 lines (51 loc) · 1.71 KB
/
gumz.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
<html>
<body>
<video id="vid1" autoplay="true"></video>
<video id="vid2" autoplay="true"></video>
</body>
<script>
function errorCallback(error){
console.log("navigator.getUserMedia error: ", error);
}
function gotColorStream(stream) {
console.log('Got Colour camera');
var video2 = document.getElementById('vid2');
video2.src = webkitURL.createObjectURL(stream);
}
function gotDepthStream(stream) {
console.log('Got Depth camera');
var video1 = document.getElementById('vid1');
video1.src = webkitURL.createObjectURL(stream);
}
function gotSources(sources) {
console.log('Num Sources: ' + sources.length);
window.sources = sources;
var ids = [];
for (var i = 0; i < sources.length; ++i) {
if (sources[i].kind != 'video')
continue;
console.log('Source ' + i + ' id: ' + sources[i].id + ' label: ' + sources[i].label);
ids.push(sources[i].id);
}
var depthSourceId = ids[5];
var colorSourceId = ids[1];
var colorConstraints = {
video: { "mandatory": { "maxWidth": "320", "maxHeight": "240", },
"optional": [{sourceId: colorSourceId}] }
};
console.log('Trying to open Colour camera: ' + colorSourceId);
navigator.webkitGetUserMedia(colorConstraints, gotColorStream, errorCallback);
var depthConstraints = {
video: { "mandatory": { "maxWidth": "320", "maxHeight": "240", },
"optional": [{sourceId: depthSourceId}] }
};
console.log('Trying to open Depth camera: ' + depthSourceId);
navigator.webkitGetUserMedia(depthConstraints, gotDepthStream, errorCallback);
}
function initialize() {
MediaStreamTrack.getSources(gotSources);
// navigator.webkitGetUserMedia(constraints2, gotStream2, errorCallback);
}
initialize();
</script>
</html>