-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
93 lines (92 loc) · 2.91 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>AprilTag 36H11 Detection in Pure Javascript</title>
<style>
#spalshScreen {
display: block;
position: absolute;
bottom: 0;
left: 0;
height: 100%;
width: 100%;
text-align: center;
background-color: #d35400;
color: #ccc;
text-shadow: 1px 1px #000;
}
.spinner {
width: 40px;
height: 40px;
background-color: #ccc;
margin: 100px auto;
-webkit-animation: sk-rotateplane 1.2s infinite ease-in-out;
animation: sk-rotateplane 1.2s infinite ease-in-out;
}
.container {
margin: auto;
text-align: center;
}
/* img {
max-width: 240px;
max-height: 160px;
}*/
@-webkit-keyframes sk-rotateplane {
0% { -webkit-transform: perspective(120px) }
50% { -webkit-transform: perspective(120px) rotateY(180deg) }
100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) }
}
@keyframes sk-rotateplane {
0% {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
} 50% {
transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
-webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
} 100% {
transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
-webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
}
}
</style>
</head>
<body>
<div id="spalshScreen">
<div class="spinner"></div>
<p><strong>OpenCV.js is loading ... </strong></p>
</div>
<div class="container">
<h2>This is a pure javascript implementation of AprilTag (36H11 family)</h2>
<p id="detections"></p>
<img id="imgViewer"></img>
<p>Select Image : <input type="file" id="fileInput" name="file" /></p>
</div>
<script type="text/javascript">
let onOpenCvReady = () => {
document.getElementById("spalshScreen").style.display = "none";
}
let inputElement = document.getElementById('fileInput');
let imgViewer = document.getElementById('imgViewer');
inputElement.addEventListener('change', (e) => {
imgViewer.src = URL.createObjectURL(e.target.files[0]);
}, false);
imgViewer.onload = () => {
document.getElementById("detections").innerText = "Detecting ...";
let mat = cv.imread(imgViewer);
detect(mat, (detections) => {
let ids = '';
detections.forEach((detection, index) => {
if (index != 0)
ids += ", " + detection.id;
else
ids += detection.id;
})
document.getElementById("detections").innerHTML = "Detected IDs : " + ids;
});
}
</script>
<script src="apriltag.js" type="text/javascript"></script>
<script async src="https://docs.opencv.org/master/opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
</body>
</html>