-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
parameters-tunning.html
383 lines (345 loc) · 12.3 KB
/
parameters-tunning.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<!DOCTYPE html>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- three.js library -->
<script src='vendor/three.js/build/three.js'></script>
<script src="vendor/three.js/examples/js/libs/stats.min.js"></script>
<!-- jsartookit -->
<script src="../vendor/jsartoolkit5/build/artoolkit.min.js"></script>
<script src="../vendor/jsartoolkit5/js/artoolkit.api.js"></script>
<!-- include threex.artoolkit -->
<script src="../src/threex/threex-artoolkitsource.js"></script>
<script src="../src/threex/threex-artoolkitcontext.js"></script>
<script src="../src/threex/threex-artoolkitprofile.js"></script>
<script src="../src/threex/threex-arbasecontrols.js"></script>
<script src="../src/threex/threex-armarkercontrols.js"></script>
<script>THREEx.ArToolkitContext.baseURL = '../'</script>
<!-- domElement UI -->
<style>
body {
font-family: Monospace;
}
#demoUISource {
z-index: 3;
position: absolute;
top: 0;
left: 0;
background-color: rgba(255,255,255,0.4);
padding: 10px;
}
#demoUIContext {
z-index: 3;
position: absolute;
bottom: 0;
left: 0;
background-color: rgba(255,255,255,0.4);
padding: 10px;
}
#demoUIControls {
z-index: 3;
position: absolute;
bottom: 0;
right: 0;
background-color: rgba(255,255,255,0.4);
padding: 10px;
}
.rs-base { /* the aframe stat */
left : auto;
right: 20px;
}
</style>
<div id='demoUISource'>
<h3>Source Parameters</h3>
<label title='the video source used by artoolkit'>Video Source :
<select id='videoSourceType'>
<option value="webcam">webcam</option>
<option value="video_headtracking.mp4">video_headtracking</option>
<option value="video_output_4.mp4">video_output_4</option>
<option value="image_armchair.jpg">image_armchair</option>
<option value="image_chalk_multi.jpg">image_chalk_multi</option>
<option value="image_chalk.jpg">image_chalk</option>
<option value="image_img.jpg">image_img</option>
<option value="image_kuva.jpg">image_kuva</option>
</select>
</label>
<br/>
<label title='the video source used by artoolkit'>Source Width x Height :
<select id='videoSourceDimensions'>
<option value="640x480">640x480</option>
<option value="320x240">320x240</option>
<option value="240x180">240x180</option>
</select>
</label>
<br/>
<label title='the video source used by artoolkit'>Display Width x Height :
<select id='videoDisplayDimensions'>
<option value="640x480">640x480</option>
<option value="320x240">320x240</option>
<option value="240x180">240x180</option>
</select>
</label>
</div>
<div id='demoUIContext'>
<h3>Context Parameters</h3>
<label title='enabled debug in artoolkit'>debug :
<select id='debug'>
<option value="true">true</option>
<option value="false">false</option>
</select>
</label>
<br/>
<label title='type of marker detected by artoolkit'>detectionMode :
<select id='detectionMode'>
<option value="color">color</option>
<option value="color_and_matrix">color_and_matrix</option>
<option value="mono">mono</option>
<option value="mono_and_matrix">mono_and_matrix</option>
</select>
</label>
<br/>
<label title='valid only detectionMode contains matrix'>matrixCodeType :
<select id='matrixCodeType'>
<option value="3x3">3x3</option>
<option value="3x3_HAMMING63">3x3_HAMMING63</option>
<option value="3x3_PARITY65">3x3_PARITY65</option>
<option value="4x4">4x4</option>
<option value="4x4_BCH_13_9_3">4x4_BCH_13_9_3</option>
<option value="4x4_BCH_13_5_5">4x4_BCH_13_5_5</option>
</select>
</label>
<br/>
<label title='max detection rate'>maxDetectionRate :
<select id='maxDetectionRate'>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60" selected="selected">60</option>
</select>
</label>
<br/>
<label title='resolution of at which we detect pose in the source image'>Canvas Width x Height :
<select id='canvasDimensions'>
<option value="640x480">640x480</option>
<option value="320x240">320x240</option>
<option value="240x180">240x180</option>
</select>
</label>
<br/>
<label title='enabled image smoothing'>image smoothing :
<select id='imageSmoothingEnabled'>
<option value="true">true</option>
<option value="false">false</option>
</select>
</label>
</div>
<div id='demoUIControls'>
<h3>Controls Parameters</h3>
<label title='The type of marker detected'>Marker Type :
<select id='markerType'>
<option value="hiro">hiro</option>
<option value="kanji">kanji</option>
<option value="unknown">unknown</option>
<option value="barcode_3x3_20">barcode_3x3_20</option>
</select>
</label>
<br/>
<label title='change matrix mode'>matrix mode :
<select id='matrixMode'>
<option value="modelViewMatrix">modelViewMatrix</option>
<option value="cameraTransformMatrix">cameraTransformMatrix</option>
</select>
</label>
<br/>
<label title='size of the marker in meters'>size in meters :
<select id='makerSize'>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</label>
<br/>
<label title='minimal confidence in the marke recognition'>minimal recognition confidence :
<select id='confidence'>
<option value="0">0</option>
<option value="0.2">0.2</option>
<option value="0.4">0.4</option>
<option value="0.6">0.6</option>
<option value="0.8">0.8</option>
<option value="1" selected="selected">1</option>
</select>
</label>
</div>
<body style='margin : 0px; overflow: hidden; font-family: Monospace;'><div style='position: absolute; top: 10px; width:100%; text-align: center;z-index:1';>
<a href="https://github.com/jeromeetienne/AR.js/" target="_blank">AR.js</a> - developement playground
<br/>
Contact me any time at <a href='https://twitter.com/jerome_etienne' target='_blank'>@jerome_etienne</a>
</div><script>
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////
// init renderer
var renderer = new THREE.WebGLRenderer({
// antialias : true,
alpha: true
});
renderer.setClearColor(new THREE.Color('lightgrey'), 0)
// renderer.setPixelRatio( 2 );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.domElement.style.position = 'absolute'
renderer.domElement.style.top = '0px'
renderer.domElement.style.left = '0px'
document.body.appendChild( renderer.domElement );
// array of functions for the rendering loop
var onRenderFcts= [];
// init scene and camera
var scene = new THREE.Scene();
var ambient = new THREE.AmbientLight( 0x666666 );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0x887766 );
directionalLight.position.set( -1, 1, 1 ).normalize();
scene.add( directionalLight );
//////////////////////////////////////////////////////////////////////////////////
// Initialize a basic camera
//////////////////////////////////////////////////////////////////////////////////
// Create a camera
var camera = new THREE.Camera();
scene.add(camera);
////////////////////////////////////////////////////////////////////////////////
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////
function buildSourceParameters(){
var sourceParameters = {}
// handle #videoSource
var value = document.querySelector('#videoSource').value
var sourceType = value.split('_')[0]
var sourceUrl = value.split('_')[1]
if( sourceType === 'webcam' ){
sourceParameters.sourceType = sourceType
}else if( sourceType === 'image' ){
sourceParameters.sourceType = sourceType
sourceParameters.sourceUrl = THREEx.ArToolkitContext.baseURL + '../data/images/' + sourceUrl
}else if( sourceType === 'video' ){
sourceParameters.sourceType = sourceType
sourceParameters.sourceUrl = THREEx.ArToolkitContext.baseURL + '../data/videos/' + sourceUrl
}
return sourceParameters
}
function onParametersChange(){
var parameters = {
sourceParameters : buildSourceParameters()
}
location.hash = '#' + encodeURIComponent( JSON.stringify(parameters) )
location.reload()
}
document.querySelector('#videoSourceType').addEventListener('change', onParametersChange)
var sourceParameters = {
sourceType : 'webcam'
}
if( location.hash.substring(1) ){
var data = JSON.parse( decodeURIComponent( location.hash.substring(1) ) )
sourceParameters = data.sourceParameters
console.log('there is a hash param,eters', data)
}
var arToolkitSource = new THREEx.ArToolkitSource(sourceParameters)
// var arToolkitSource = new THREEx.ArToolkitSource({
// // to read from the webcam
// sourceType : 'webcam',
//
// // // to read from an image
// // sourceType : 'image',
// // sourceUrl : THREEx.ArToolkitContext.baseURL + '../data/images/img.jpg',
//
// // to read from a video
// // sourceType : 'video',
// // sourceUrl : THREEx.ArToolkitContext.baseURL + '../data/videos/headtracking.mp4',
// })
arToolkitSource.init(function onReady(){
// handle resize of renderer
arToolkitSource.onResizeElement(renderer.domElement)
})
// handle resize
window.addEventListener('resize', function(){
// handle arToolkitSource resize
arToolkitSource.onResizeElement(renderer.domElement)
})
////////////////////////////////////////////////////////////////////////////////
// initialize arToolkitContext
////////////////////////////////////////////////////////////////////////////////
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext({
cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
detectionMode: 'mono',
canvasWidth: 80*3,
canvasHeight: 60*3,
})
// initialize it
arToolkitContext.init(function onCompleted(){
// copy projection matrix to camera
camera.projectionMatrix.copy( arToolkitContext.getProjectionMatrix() );
})
// update artoolkit on every frame
onRenderFcts.push(function(){
if( arToolkitSource.ready === false ) return
arToolkitContext.update( arToolkitSource.domElement )
})
////////////////////////////////////////////////////////////////////////////////
// Create a ArMarkerControls
////////////////////////////////////////////////////////////////////////////////
var markerRoot = new THREE.Group
scene.add(markerRoot)
var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, {
type : 'pattern',
patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro',
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji',
})
//////////////////////////////////////////////////////////////////////////////////
// add an object in the scene
//////////////////////////////////////////////////////////////////////////////////
var mesh = new THREE.AxesHelper()
markerRoot.add(mesh)
// add a torus knot
var geometry = new THREE.CubeGeometry(1,1,1);
var material = new THREE.MeshNormalMaterial({
transparent : true,
opacity: 0.5,
side: THREE.DoubleSide
});
var mesh = new THREE.Mesh( geometry, material );
mesh.position.y = geometry.parameters.height/2
markerRoot.add( mesh );
var geometry = new THREE.TorusKnotGeometry(0.3,0.1,64,16);
var material = new THREE.MeshNormalMaterial();
var mesh = new THREE.Mesh( geometry, material );
mesh.position.y = 0.5
markerRoot.add( mesh );
onRenderFcts.push(function(delta){
mesh.rotation.x += delta * Math.PI
})
//////////////////////////////////////////////////////////////////////////////////
// render the whole thing on the page
//////////////////////////////////////////////////////////////////////////////////
var stats = new Stats();
// document.body.appendChild( stats.dom );
// render the scene
onRenderFcts.push(function(){
renderer.render( scene, camera );
stats.update();
})
// run the rendering loop
var lastTimeMsec= null
requestAnimationFrame(function animate(nowMsec){
// keep looping
requestAnimationFrame( animate );
// measure time
lastTimeMsec = lastTimeMsec || nowMsec-1000/60
var deltaMsec = Math.min(200, nowMsec - lastTimeMsec)
lastTimeMsec = nowMsec
// call each update function
onRenderFcts.forEach(function(onRenderFct){
onRenderFct(deltaMsec/1000, nowMsec/1000)
})
})
</script></body>