-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.html
More file actions
120 lines (110 loc) · 4.15 KB
/
Copy pathapp.html
File metadata and controls
120 lines (110 loc) · 4.15 KB
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
<!doctype html>
<meta name="robots" content="noindex">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Camera</title>
<script src="https://blocklypro.webduino.io/components/jquery/dist/jquery.min.js?rev=4a356126b9573eb7bd1e9a7494737410"></script>
<script src="https://blocklypro.webduino.io/dist/lib/webduino-all-0.4.20.min.js?rev=4426739c00d85325cb2d3d701fa50666"></script>
<script src="https://blocklypro.webduino.io/dist/webduino-blockly.min.js?rev=6a9037f813da79372168951bbfeafb49"></script>
<script src="js/camera.js"></script>
<link rel='stylesheet' type='text/css' href='style.css' />
</head>
<body>
<canvas id='qq' width='320px' height='480px' class='display'></canvas>
<div>
<div id="demo-area-09" class="da">
<div id="demo-area-09-content">
<div id="demo-area-09-controller">
<input type="range" min="0" max="180" step="5" value="90" class="demo-area-09-input">
<div class="demo-area-09-btn-group btn-direction-group">
<div class="demo-area-09-btn btn-up">▲</div>
<br>
<div class="demo-area-09-btn btn-left">◀</div>
<div class="demo-area-09-btn btn-center">●</div>
<div class="demo-area-09-btn btn-right">▶</div>
<br>
<div class="demo-area-09-btn btn-down">▼</div>
</div>
</div>
</div>
</div>
</div>
<script>
var imageClassifier;
var hServo;
var vServo;
//https://marty5499.github.io/WebEye/index.html#remotecam.webduino.io/camera/ylWjzxAnK/live/nJ3Em
var param = location.hash.substring(1).split('@');
var deviceID = param[0];
var camURL = param[1];
console.log("deviceID:", deviceID);
console.log("camURL:", camURL);
boardReady({ board: 'Smart', device: deviceID, transport: 'mqtt' }, function (board) {
board.samplingInterval = 50;
var cam = new Camera(camURL);
cam.setRotate(90);
cam.onCanvas('qq');
hServo = getServo(board, 2);
vServo = getServo(board, 5);
var p;
vServo.angle = 90;
hServo.angle = 90;
setTimeout(function () {
vServo.angle = 45;
}, 500);
controllerBtnEvent(getElement('#demo-area-09 .btn-up'), 'click', function () {
vServo.angle -= 5;
});
controllerBtnEvent(getElement('#demo-area-09 .btn-down'), 'click', function () {
vServo.angle += 5;
});
controllerBtnEvent(getElement('#demo-area-09 .btn-left'), 'click', function () {
hServo.angle += 5;
});
controllerBtnEvent(getElement('#demo-area-09 .btn-right'), 'click', function () {
hServo.angle -= 5;
});
controllerBtnEvent(getElement('#demo-area-09 .btn-center'), 'click', function () {
hServo.angle = 90;
vServo.angle = 90;
});
var range = document.querySelector('.demo-area-09-input');
range.setAttribute('min', 0);
range.setAttribute('max', 180);
range.setAttribute('step', 1);
range.setAttribute('value', 90);
p = Math.round((90 - 0) * 100 / (180 - 0));
range.style.backgroundImage = '-webkit-linear-gradient(left, #246 0%, #246 ' + p + '%, #222 ' + p + '%, #222 100%)';
range.oninput = function () {
var _value = this.value;
p = Math.round((_value - 0) * 100 / (180 - 0));
range.style.backgroundImage = '-webkit-linear-gradient(left, #246 0%, #246 ' + p + '%, #222 ' + p + '%, #222 100%)';
hServo.angle = (180 - _value);
};
});
function getElement(dom) {
var element = document.querySelector(dom);
return element;
}
function controllerBtnEvent(c, e, callback) {
if (e !== 'click') {
var _u = navigator.userAgent;
if (_u.indexOf('Android') > -1 || _u.indexOf('iPhone') > -1 || _u.indexOf('iPad') > -1) {
c.addEventListener(e[1], function () {
callback();
});
} else {
c.addEventListener(e[0], function () {
callback();
});
}
} else {
c.addEventListener('click', function () {
callback();
});
}
}
</script>
</body>