forked from teleline/ScriptCam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo4.htm
61 lines (60 loc) · 2.03 KB
/
demo4.htm
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
<!DOCTYPE html>
<html>
<head>
<script language="JavaScript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script language="JavaScript" src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script language="JavaScript" src="scriptcam.js"></script>
<script>
$(document).ready(function() {
$("#webcam").scriptcam({
onMotion:onMotion,
cornerRadius:0,
onError:onError,
onWebcamReady:onWebcamReady
});
});
function onError(errorId,errorMsg) {
alert(errorMsg);
}
function changeCamera() {
$.scriptcam.changeCamera($('#cameraNames').val());
}
function onWebcamReady(cameraNames,camera,microphoneNames,microphone,volume) {
$.each(cameraNames, function(index, text) {
$('#cameraNames').append( $('<option></option>').val(index).html(text) )
});
$('#cameraNames').val(camera);
}
function onMotion(motion,brightness,color,motionx,motiony) {
$('#motion').html('Motion (0 or 1): '+motion);
$('#brightness').html('Brightness level (0-255): '+brightness);
$('#color').html('Average color (hex): '+color);
$('#colordiv').css('background-color','#'+color);
$('#motionx').html('Motion x: '+motionx);
$('#motiony').html('Motion y: '+motiony);
}
</script>
</head>
<body>
<div style="width:330px;float:left;">
<div id="webcam">
</div>
<div style="margin:5px;">
<img src="webcamlogo.png" style="vertical-align:text-top"/>
<select id="cameraNames" size="1" onChange="changeCamera()" style="width:245px;font-size:10px;height:25px;">
</select>
</div>
</div>
<div style="width:135px;float:left;">
<button class="btn btn-small" onclick="$.scriptcam.getMotionParameters();">Get values</button>
</div>
<div style="width:200px;float:left;">
<p id="motion"></p>
<p id="brightness"></p>
<p id="color"></p>
<div id="colordiv" style="width:150px;height:10px;margin-bottom:5px;border:1px solid black;"></div>
<p id="motionx"></p>
<p id="motiony"></p>
</div>
</body>
</html>