-
Notifications
You must be signed in to change notification settings - Fork 37
/
step2.html
39 lines (32 loc) · 867 Bytes
/
step2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>监控系统</title>
</head>
<body>
<video width="640" height="480" autoplay></video>
<canvas width="640" height="480"></canvas>
<script>
var video = document.querySelector('video');
var canvas = document.querySelector('canvas');
// video捕获摄像头画面
navigator.webkitGetUserMedia({
video: true
}, success, error);
function success(stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}
function error(err) {
alert('video error: ' + err)
}
//canvas
var context = canvas.getContext('2d');
setTimeout(function(){
//把当前视频帧内容渲染到画布上
context.drawImage(video, 0, 0, 640, 480);
}, 5000);
</script>
</body>
</html>