forked from o-netusa/o-netusa.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
223 lines (197 loc) · 9.03 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<html>
<head>
<meta charset="utf-8" />
<title>O-Net LiDAR Viewer</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
<link rel="icon" type="image/ico" href="onet_logo.ico" />
<script src="libs/adapter.min.js"></script>
<script src="webrtcstreamer.js"></script>
<script>
/**
* Global WebRTC configs.
*/
let webRtcOptions = "rtptransport=tcp&timeout=60";
/**
* WebRTC connections.
*/
let webRtcServerList = {};
/**
* Get the div where to insert a video.
*/
function getContentDiv() {
let contentDiv = document.getElementById("content");
return contentDiv;
}
function setDifference(setA, setB) {
let _difference = new Set(setA);
for (let elem of setB) {
_difference.delete(elem);
}
return _difference;
}
/**
* Init device list
* @param {object} mediaList A map of media. E.g.
* let mediaList = {
* 0: {video: "window_0"},
* 1: {video: "window_1"},
* }
*/
function updateMediaList(mediaList) {
// Create navigation menu.
let menu = document.getElementById("menu");
// The current video source that the server is serving.
let validWindowIds = new Set();
for (let key in mediaList) {
validWindowIds.add(mediaList[key].video);
}
// Collect stale and new URLs. Avoid "removing while iterating".
let existingWindowIds = new Set();
let staleWindowIds = new Array();
for (let i = 0; i < menu.children.length; i++) {
let navElt = menu.children[i];
let windowId = navElt.windowId;
existingWindowIds.add(windowId);
if (!validWindowIds.has(windowId)) {
staleWindowIds.push(windowId);
}
}
let newWindowIds = [
...setDifference(validWindowIds, existingWindowIds),
];
// Remove stale URLs.
staleWindowIds.forEach(function (windowId) {
let videoId = "video_" + windowId;
let id = "nav_" + videoId;
document.getElementById(id).remove();
});
// Append new URLs to the menu bar.
newWindowIds.forEach(function (windowId) {
let videoId = "video_" + windowId;
let navId = "nav_" + videoId;
let navElt = document.createElement("a");
navElt.text = windowId;
navElt.windowId = windowId;
navElt.id = navId;
navElt.onclick = function () {
if (this.className === "active") {
delConnection(this.windowId);
} else {
addConnection(this.windowId);
}
};
menu.appendChild(navElt);
});
// Connect to the new URLs, this will also highlight the menu entry.
newWindowIds.forEach((windowId) => {
addConnection(windowId);
});
}
/**
* Delete a WebRTC client connection.
*/
function delConnection(windowId) {
console.log("delConnection: ", windowId);
let videoId = "video_" + windowId;
// Disconnect WebRTC connection.
let webrtcServer = webRtcServerList[videoId];
if (webrtcServer) {
webrtcServer.disconnect();
webRtcServerList[videoId] = undefined;
}
}
/**
* Add a WebRTC client connection.
*/
function addConnection(windowId) {
let videoId = "video_" + windowId;
// Add a video element to display WebRTC stream.
if (document.getElementById(videoId) === null) {
let contentDiv = getContentDiv();
if (contentDiv) {
let divElt = document.createElement("div");
divElt.id = "div_" + videoId;
/* let nameElt = document.createElement("h2");
nameElt.id = "title_" + videoId;
nameElt.innerHTML = "<div>" + windowId + "</div>";
divElt.appendChild(nameElt); */
let videoElt = document.createElement("video");
videoElt.id = videoId;
videoElt.title = windowId;
videoElt.muted = true;
videoElt.controls = false;
videoElt.playsinline = true;
videoElt.innerText = "Your browser does not support HTML5 video.";
divElt.appendChild(videoElt);
contentDiv.appendChild(divElt);
}
}
let videoElt = document.getElementById(videoId);
if (videoElt) {
let onClose = function () {
console.log("onClose() called for videoId:", videoId);
// Remove the video element and its tile.
let divElt = document.getElementById("div_" + videoId);
divElt.parentElement.removeChild(divElt);
// Un-highlight the navigation.
let navElt = document.getElementById("nav_" + videoId);
navElt.className = "";
WebRtcStreamer.getMediaList("https://bogao.us")
.then((response) => response.json())
.then((response) => updateMediaList(response));
};
// Connect video element to WebRTC stream.
let webRtcClient = new WebRtcStreamer(videoId, "https://bogao.us", onClose, null);
console.log("[addConnection] videoId: " + videoId);
webRtcClient.connect(windowId, /*audio*/ null, webRtcOptions);
console.log("[addConnection] windowId: " + windowId);
console.log("[addConnection] options: " + webRtcOptions);
// Highlight the navigation.
let navElt = document.getElementById("nav_" + videoId);
navElt.className = "active";
// Register WebRTC streamer connection.
webRtcServerList[videoId] = webRtcClient;
}
}
/**
* Load/unload callbacks.
*/
window.onload = function () {
WebRtcStreamer.getMediaList("https://bogao.us")
.then((response) => response.json())
.then((response) => updateMediaList(response));
};
window.onbeforeunload = function () {
for (let key in webRtcServerList) {
webRtcServerList[key].disconnect();
}
};
</script>
</head>
<body>
<nav id="menu" hidden></nav>
<div>
<h2>O-Net LiDAR Viewer</h2>
<p class="main">
The goal of the project is to not only develop an application to gather and display point cloud data from LiDAR sensor, but also demonstrate the Object Detection feature implemented using <a href=https://arxiv.org/abs/1812.05784>PointPillars</a> Pytorch model.
We created our PointPillars model based on <a href=https://github.com/isl-org/Open3D-ML/blob/master/ml3d/torch/models/point_pillars.py>Open3D-ML's implementation</a> and serialized it into <a href=https://pytorch.org/docs/stable/jit.html>TorchScript</a> format and then loaded into our C++ object detection module for x86_64 platform.
While for <a href=https://www.xilinx.com/products/boards-and-kits/zcu104.html>Xilinx UltraScale+ MPSoC</a> platform, we took advantage of <a href=https://github.com/Xilinx/Vitis-AI/tree/master/models/AI-Model-Zoo/model-list>Xilinx Vitis AI Model Zoo</a>.
The LiDAR Viewer project largely depends on <a href=http://www.open3d.org>Open3D</a>, which is a very cool open-source library that provides a full stack of features to create an application quickly. Open3D uses <a href=https://github.com/ocornut/imgui>Dear ImGUI</a> for the UI widgets and <a href=https://github.com/google/filament>Google's Filament</a> for the 3D rendering.
</p>
<p class="main">
<b>LiDAR Viewer</b> depends on other three projects that are developed by O-Net, <a href=https://github.com/o-netusa/cppbase>cppbase</a>, <a href=https://github.com/o-netusa/lidardevice>LidarDevice</a> and <a href=https://github.com/o-netusa/pcdetector>PCDetector</a>.
<b>LidarDevice</b> is responsible for communications with LiDAR sensor, saving and loading gathered point cloud data. <b>PCDetector</b> on the other hand is responsible for object detections using pre-trained ML models.
For x86_64 platform, <b>PCDetector</b> is directly linked into <b>LiDAR Viewer</b> and run model locally. While for Xilinx ZCU104 platform, <b>PCDetector</b> runs as a RPC receiver, and <b>LiDAR Viewer</b> runs on PC sending point cloud and getting inference results through RPC channels. (Figure 1. Module Diagram)
</p>
<p class="main">
<div><img src="images/lidarviewer_pcdetector.png"></div>
<div>Figure 1. Module Diagram</div>
</p>
<p class="main">
The following demo shows LiDAR Viewer running through a webrtc server, which can also run as a standalone desktop application. It loads KITTI dataset point cloud and sends it to Xilinx ZCU104 dev board, which runs PCDetector behind a RPC receiver and sends inference results back to LiDAR Viewer, which then updates the visualizer to show the point cloud and object detection results.
</p>
</div>
<div id="content"></div>
<footer id="footer"></footer>
</body>
</html>