Skip to content

Commit dde3fe9

Browse files
committed
Calibration JSON Schema
1 parent c999c2c commit dde3fe9

File tree

7 files changed

+631
-11
lines changed

7 files changed

+631
-11
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ Keep in mind that this is still just a prototype and that I'm not a frontend dev
1111
## TO-DOs
1212

1313
- Create a calibration page to allow users to calibrate the position and orientation of their camera, and to configure their chroma key (green screen).
14-
15-
- Allow the Mixed Reality Capture session to be initialized with a JSON file with a saved calibration.
1614

1715
## How to test the example
1816

@@ -87,3 +85,40 @@ renderer.render( scene, camera );
8785
mixedRealityCapture.render( renderer.xr, scene );
8886

8987
```
88+
89+
Alternatively, you can instantiate the calibration with a JSON provided by the user:
90+
91+
```javascript
92+
93+
// ...
94+
95+
const json = `
96+
{
97+
"schemaVersion": 1,
98+
"camera": {
99+
"width": 1280,
100+
"height": 720,
101+
"fov": 38,
102+
"position": [0, 1.5, 0],
103+
"orientation": [0, 0, 0, 1]
104+
},
105+
"chromaKey": {
106+
"color": [0, 1, 0],
107+
"similarity": 0.25,
108+
"smoothness": 0
109+
},
110+
"delay": 4
111+
}
112+
`;
113+
114+
const calibrationData = JSON.parse( json );
115+
116+
const calibration = MRC.Calibration.fromData( calibrationData );
117+
118+
// ...
119+
120+
mixedRealityCapture = new MRC.MixedRealityCapture( calibration );
121+
122+
// ...
123+
124+
```

examples/calibration_parser.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Calibration parser</title>
6+
<style>
7+
body { margin: 0; }
8+
</style>
9+
</head>
10+
<body style="background-color:black;">
11+
12+
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
13+
14+
<script type="importmap">
15+
{
16+
"imports": {
17+
"three": "../node_modules/three/build/three.module.js",
18+
"reality-mixer": "../src/mrc.js"
19+
}
20+
}
21+
</script>
22+
23+
<script type="module">
24+
import * as MRC from 'reality-mixer';
25+
26+
const json = `
27+
{
28+
"schemaVersion": 1,
29+
"camera": {
30+
"width": 1280,
31+
"height": 720,
32+
"fov": 38,
33+
"position": [0, 1.5, 0],
34+
"orientation": [0, 0, 0, 1]
35+
},
36+
"chromaKey": {
37+
"color": [0, 1, 0],
38+
"similarity": 0.25,
39+
"smoothness": 0
40+
},
41+
"delay": 4
42+
}
43+
`;
44+
45+
const calibrationData = JSON.parse( json );
46+
47+
const calibration = MRC.Calibration.fromData( calibrationData );
48+
console.log(calibration);
49+
</script>
50+
</body>
51+
</html>

0 commit comments

Comments
 (0)