-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_ar.html
110 lines (78 loc) · 2.81 KB
/
test_ar.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
<!DOCTYPE html>
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta charset="UTF-8">
<!-- include three.js -->
<script src='webarjs/three.js'></script>
<!-- <script src='webarjs/stats.min.js'></script>FPS的js-->
<!-- include some extensions -->
<script src='webarjs/threex.webcamgrabbing.js'></script> <!--摄像头这个界面的JS-->
<script src="js/jquery-3.1.1.min.js"></script>
<style>
#elemdiv {
height: 35px;width: 100px;background-color: red;color: white;text-align: center;
position: absolute;left: 40%;top: 80%;
}
#picture{
height:40px;width: 30%;
position: absolute;left: 40%;top: 85%;
}
</style>
<body style='margin: 0px; overflow: hidden;'>
<div>
</div>
<script>
</script>
<script>
'use strict';
var videoElement = document.querySelector('video');
navigator.mediaDevices.enumerateDevices()
.then(gotDevices).then(getStream).catch(handleError);
function gotDevices(deviceInfos) {
for (var i = 0; i !== deviceInfos.length; ++i) {
var deviceInfo = deviceInfos[i];
var option = document.createElement('option');
option.value = deviceInfo.deviceId;
if (deviceInfo.kind === 'audioinput') {
// option.text = deviceInfo.label ||
// 'microphone ' + (audioSelect.length + 1);
console.log(option);
} else if (deviceInfo.kind === 'videoinput') {
// option.text = deviceInfo.label || 'camera ' +
// (videoSelect.length + 1);
// videoSelect.appendChild(option);
console.log(deviceInfo)
} else {
console.log('Found one other kind of source/device: ', deviceInfo);
}
}
}
function getStream() {
if (window.stream) {
window.stream.getTracks().forEach(function(track) {
track.stop();
});
}
//
// var constraints = {
// audio: {
// deviceId: {exact: audioSelect.value}
// },
// video: {
// deviceId: {exact: videoSelect.value}
// }
// };
navigator.mediaDevices.getUserMedia(constraints).
then(gotStream).catch(handleError);
}
function gotStream(stream) {
window.stream = stream; // make stream available to console
videoElement.srcObject = stream;
}
function handleError(error) {
console.log('Error: ', error);
}
</script>
<script src="js/jquery-3.1.1.min.js">
</script>
</body>
</html>