-
Notifications
You must be signed in to change notification settings - Fork 3
/
upload.html
274 lines (229 loc) · 11.6 KB
/
upload.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-161822888-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-161822888-1');
</script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Upload immersive pointcloud</title>
<style>
body {
padding-bottom: 2rem;
}
h3 {
margin-top: 2rem;
}
.row {
margin-bottom: 0rem;
}
.row .row {
margin-top: 0rem;
margin-bottom: 0;
}
[class*="col-"] {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
background-color: rgba(86, 61, 124, .15);
border: 1px solid rgba(86, 61, 124, .2);
}
hr {
margin-top: 2rem;
margin-bottom: 2rem;
}
.col-sm-16 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="#">
<img src="images/immersive_points_logo/logo_cutout.png" height="40" class="d-inline-block align-top" alt="">
</a>
<div class="navbar-nav">
<a class="nav-item nav-link" href="/index.html">Home</a>
<a class="nav-item nav-link active" href="/upload.html">Upload <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="/pricing.html">Pricing</a>
</div>
</nav>
</header>
<main role="main" class="container">
<div id="app">
<br>
<h1>Upload your own!</h1>
<div id="explain">
Want to see your own pointcloud in virtual reality? Upload your binary file here! <br>
All binary files are expected to be in float32. <br>
The binary file is expected to be in float32, and consist of XYZH values, or XYZRGB values <br>
X, Y, and Z are floating point numbers in any range, but it's wise to position them around the point of origin of the virtual reality environment. <br>
The H-value signifies the hue of that point, which should be between 0.0 and 1.0 according to <a href=https://threejs.org/docs/#api/en/math/Color.setHSL>this specification</a>. Note that saturation and lightness are currently always set to 1.0. This means your file exists of the following columns: <br>
<div class="row">
<div class="col-sm-16">X (forwards) float32</div>
<div class="col-sm-16">Y (upwards) float32</div>
<div class="col-sm-16">Z (left) float32</div>
<div class="col-sm-16">Hue (between 0 and 1) float32</div>
</div>
For the colour version:
<div class="row">
<div class="col-sm-16">X (forwards) float32</div>
<div class="col-sm-16">Y (upwards) float32</div>
<div class="col-sm-16">Z (left) float32</div>
<div class="col-sm-16">Red (between 0 and 1) float32</div>
<div class="col-sm-16">Green (between 0 and 1) float32</div>
<div class="col-sm-16">Blue (between 0 and 1) float32</div>
</div>
Bounding boxes <b>can't be uploaded right now</b>, but when you can they will have the following format:
<div class="row">
<div class="col-sm-16">Center X (forwards) float32</div>
<div class="col-sm-16">Center Y (upwards) float32</div>
<div class="col-sm-16">Center Z (left) float32</div>
<div class="col-sm-16">Size X float32</div>
<div class="col-sm-16">Size Y float32</div>
<div class="col-sm-16">Size Z float32</div>
<div class="col-sm-16">Rotation around X float32</div>
<div class="col-sm-16">Rotation around Y float32</div>
<div class="col-sm-16">Rotation around Z float32</div>
<div class="col-sm-16">Red (between 0 and 1) float32</div>
<div class="col-sm-16">Green (between 0 and 1) float32</div>
<div class="col-sm-16">Blue (between 0 and 1) float32</div>
<div class="col-sm-16">Opacity (between 0 and 1) float32</div>
</div>
<h3> Get inspired by these examples</h3>
Want to see some examples on how to export pointclouds? Take a look at:
<ul>
<li><a href="https://github.com/rmeertens/ImmersivePoints/blob/master/examples/export_subsample.ipynb">Subsample a big numpy file for display in virtual reality </a></li>
<li> <a href="https://github.com/rmeertens/ImmersivePoints/blob/master/examples/export_csv.ipynb">Export a CSV file.</a></li>
<li><a href="https://github.com/rmeertens/ImmersivePoints/blob/master/examples/export_ply.ipynb">Export a PLY file</a>,</li>
<li><a href="https://github.com/rmeertens/ImmersivePoints/blob/master/examples/export_AEV_data.ipynb"> Export data from a self-driving car</a></li>
</ul>
</div>
<div>
<h2>🛠 Now upload yourself</h2>
<h3>🔧 Step 1: Select your cloud type:</h3>
<input type="radio" id="xyzi" value="xyzi" v-model="picked">
<label for="xyzi">xyzi</label>
<br>
<input type="radio" id="xyzrgb" value="xyzrgb" v-model="picked">
<label for="xyzrgb">xyzrgb</label>
</div>
<h3>🔨 Step 2: Select your file:</h3>
<div v-if="!image">
<input type="file" @change="onFileChange">
</div>
<div v-else>
<!--img :src="image" /-->
<button v-if="!uploadURL" @click="removeImage">🚨 Remove pointcloud</button>
<button v-if="!uploadURL" @click="uploadImage">🔩 Step 3: Upload pointcloud</button>
</div>
<h3 v-if="uploadURL">🥳 Success! Point cloud uploaded to the server. You can see it at this address: <a href={{uploadURL}}>{{uploadURL}}</a></h3>
<h3 v-if="errorMessage">{{errorMessage}}</h3>
<h3 v-if="readyToUploadMessage">{{readyToUploadMessage}}</h3>
<h3 v-if="resultURL">
<div class="spinner-border text-primary" role="status">
<span class="sr-only">Loading...</span>
</div>🦾 Currently uploading! Ready to visualize in a few seconds!
</h3>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.18/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
const MAX_IMAGE_SIZE = 310000000
const API_ENDPOINT = 'https://w7kziwky2h.execute-api.us-east-1.amazonaws.com/default/uploadFilesToS3Python'
function formatBytes(a, b) {
if (0 == a) return "0 Bytes";
var c = 1024,
d = b || 2,
e = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
f = Math.floor(Math.log(a) / Math.log(c));
return parseFloat((a / Math.pow(c, f)).toFixed(d)) + " " + e[f]
}
new Vue({
el: "#app",
data: {
image: '',
uploadURL: '',
errorMessage: '',
readyToUploadMessage: '',
resultURL: '',
picked: 'xyzi'
},
methods: {
onFileChange(e) {
let files = e.target.files || e.dataTransfer.files
if (!files.length) return
this.createImage(files[0])
},
createImage(file) {
// var image = new Image()
let reader = new FileReader()
reader.onload = (e) => {
if (file.size > MAX_IMAGE_SIZE) {
return alert('Pointcloud is loo large - ' + formatBytes(MAX_IMAGE_SIZE) + ' maximum')
}
console.log(file);
console.log(formatBytes(file.size, 2));
this.readyToUploadMessage = '🦾 Ready to upload ' + file.name + ' of ' + formatBytes(file.size, 2) + " to a publicly available data storage for visualization in virtual reality";
this.image = e.target.result
}
reader.readAsDataURL(file)
},
removeImage: function(e) {
console.log('Remove clicked')
this.image = ''
this.uploadURL = ''
this.errorMessage = ''
this.readyToUploadMessage = ''
this.resultURL = ''
},
uploadImage: async function(e) {
console.log('Upload clicked')
var x = this.picked;
console.log(x);
// Get the presigned URL
const response = await axios({
method: 'GET',
url: API_ENDPOINT + "?mode=" + x,
})
console.log(response)
this.readyToUploadMessage = ''
this.resultURL = "https://immersivepoints.com/oculus.html?name=" + response.data.name;
console.log('Uploading: ', this.image)
let binary = atob(this.image.split(',')[1])
let array = []
for (var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i))
}
let blobData = new Blob([new Uint8Array(array)], {
// type: 'image/jpeg'
type: ''
})
console.log('Uploading to: ', response.data.uploadURL)
const result = await fetch(response.data.uploadURL, {
method: 'PUT',
body: blobData
})
console.log('Result: ', result)
if (result.ok) {
// Final URL for the user doesn't need the query string params
// this.uploadURL = response.data.uploadURL.split('?')[0];
this.uploadURL = "https://immersivepoints.com/oculus.html?name=" + response.data.name;
this.resultURL = null;
} else {
this.errorMessage = "Error occured" + result.statusText;
}
}
}
})
</script>
</body>
</html>