`filter.jq' is a simple jq script for extracting hand position and velocity data from a leap gesture sample captured with handy.
jq --from-file filter.jq in.json > out.json
We're using it to convert gesture samples prior to rendering.
[ | |
.[] | | |
{ | |
timestamp, | |
left: { | |
id: .hands[0].id, | |
pos: { | |
x: .hands[0].palmPosition[0], | |
y: .hands[0].palmPosition[1], | |
z: .hands[0].palmPosition[2] | |
}, | |
vel: { | |
x: .hands[0].palmVelocity[0], | |
y: .hands[0].palmVelocity[1], | |
z: .hands[0].palmVelocity[2] | |
} | |
}, | |
right: { | |
id: .hands[1].id, | |
pos: { | |
x: .hands[1].palmPosition[0], | |
y: .hands[1].palmPosition[1], | |
z: .hands[1].palmPosition[2] | |
}, | |
vel: { | |
x: .hands[1].palmVelocity[0], | |
y: .hands[1].palmVelocity[1], | |
z: .hands[1].palmVelocity[2] | |
} | |
} | |
} | |
] |
[ | |
{ | |
"timestamp": 3726297668, | |
"t": [ | |
-2371.2, | |
-4278.67, | |
1973.98 | |
], | |
"currentFrameRate": 57.2716, | |
"gestures": [], | |
"hands": [ | |
{ | |
"timeVisible": 0.156521, | |
"t": [ | |
0, | |
0, | |
0 | |
], | |
"stabilizedPalmPosition": [ | |
71.4505, | |
128.013, | |
99.0209 | |
], | |
"sphereRadius": 48.5946, | |
"direction": [ | |
0.545751, | |
0.835466, | |
-0.0644334 | |
], | |
"id": 40, | |
"palmNormal": [ | |
-0.329128, | |
0.14301, | |
-0.933393 | |
], | |
"palmPosition": [ | |
71.4287, | |
128.014, | |
98.9659 | |
], | |
"palmVelocity": [ | |
-158.824, | |
5.34524, | |
-402.842 | |
], | |
"r": [ | |
[ | |
1, | |
0, | |
0 | |
], | |
[ | |
0, | |
1, | |
0 | |
], | |
[ | |
0, | |
0, | |
1 | |
] | |
], | |
"s": 1, | |
"sphereCenter": [ | |
69.6372, | |
132.235, | |
107.875 | |
] | |
} | |
], | |
"id": 42340, | |
"interactionBox": { | |
"size": [ | |
261.882, | |
261.882, | |
191.686 | |
], | |
"center": [ | |
0, | |
240, | |
0 | |
] | |
}, | |
"pointables": [ | |
{ | |
"touchZone": "hovering", | |
"touchDistance": 0.333333, | |
"tool": false, | |
"direction": [ | |
0.733056, | |
0.233466, | |
-0.638845 | |
], | |
"handId": -1, | |
"id": 36, | |
"length": 34.6309, | |
"stabilizedTipPosition": [ | |
82.247, | |
253.895, | |
62.029 | |
], | |
"timeVisible": 0.034789, | |
"tipPosition": [ | |
82.247, | |
253.895, | |
62.029 | |
], | |
"tipVelocity": [ | |
5.27358, | |
491.535, | |
-152.441 | |
] | |
} | |
], | |
"r": [ | |
[ | |
0.281917, | |
-0.214347, | |
0.935189 | |
], | |
[ | |
0.0611448, | |
-0.96873, | |
-0.240467 | |
], | |
[ | |
0.957488, | |
0.124974, | |
-0.259995 | |
] | |
], | |
"s": -153.668 | |
}, | |
{ | |
"timestamp": 3726315050, | |
"t": [ | |
-2369.36, | |
-4269.78, | |
1973.25 | |
], | |
"currentFrameRate": 57.3491, | |
"gestures": [], | |
"hands": [ | |
{ | |
"timeVisible": 0, | |
"t": [ | |
-1.20433, | |
0.718803, | |
-2.2152 | |
], | |
"stabilizedPalmPosition": [ | |
69.0469, | |
129.435, | |
94.5849 | |
], | |
"sphereRadius": 49.1321, | |
"direction": [ | |
0.400563, | |
0.913539, | |
-0.0706783 | |
], | |
"id": 40, | |
"palmNormal": [ | |
-0.289082, | |
0.0528033, | |
-0.955847 | |
], | |
"palmPosition": [ | |
69.0201, | |
129.451, | |
94.5354 | |
], | |
"palmVelocity": [ | |
-138.572, | |
82.7066, | |
-254.885 | |
], | |
"r": [ | |
[ | |
1, | |
0, | |
0 | |
], | |
[ | |
0, | |
1, | |
0 | |
], | |
[ | |
0, | |
0, | |
1 | |
] | |
], | |
"s": 1, | |
"sphereCenter": [ | |
69.7615, | |
131.942, | |
107.435 | |
] | |
} | |
], | |
"id": 42341, | |
"interactionBox": { | |
"size": [ | |
261.882, | |
261.882, | |
191.686 | |
], | |
"center": [ | |
0, | |
240, | |
0 | |
] | |
}, | |
"pointables": [ | |
{ | |
"touchZone": "hovering", | |
"touchDistance": 0.333333, | |
"tool": false, | |
"direction": [ | |
0.734636, | |
0.315176, | |
-0.600811 | |
], | |
"handId": -1, | |
"id": 36, | |
"length": 35.5817, | |
"stabilizedTipPosition": [ | |
83.657, | |
259.111, | |
61.1662 | |
], | |
"timeVisible": 0.052171, | |
"tipPosition": [ | |
83.657, | |
259.111, | |
61.1662 | |
], | |
"tipVelocity": [ | |
116.457, | |
520.129, | |
-109.216 | |
] | |
} | |
], | |
"r": [ | |
[ | |
0.281917, | |
-0.214347, | |
0.935189 | |
], | |
[ | |
0.0611448, | |
-0.96873, | |
-0.240467 | |
], | |
[ | |
0.957488, | |
0.124974, | |
-0.259995 | |
] | |
], | |
"s": -153.668 | |
}, | |
{ | |
"timestamp": 3726332453, | |
"t": [ | |
-2375.22, | |
-4270.91, | |
1968.8 | |
], | |
"currentFrameRate": 57.3827, | |
"gestures": [], | |
"hands": [ | |
{ | |
"timeVisible": 0.017403, | |
"t": [ | |
-14.2588, | |
-11.0807, | |
-10.8865 | |
], | |
"stabilizedPalmPosition": [ | |
67.2896, | |
130.044, | |
92.2266 | |
], | |
"sphereRadius": 48.7864, | |
"direction": [ | |
0.287253, | |
0.938918, | |
-0.189522 | |
], | |
"id": 40, | |
"palmNormal": [ | |
-0.2543, | |
-0.116006, | |
-0.960143 | |
], | |
"palmPosition": [ | |
67.2629, | |
130.053, | |
92.1908 | |
], | |
"palmVelocity": [ | |
-100.969, | |
34.6039, | |
-134.727 | |
], | |
"r": [ | |
[ | |
1, | |
0, | |
0 | |
], | |
[ | |
0, | |
1, | |
0 | |
], | |
[ | |
0, | |
0, | |
1 | |
] | |
], | |
"s": 1, | |
"sphereCenter": [ | |
68.837, | |
130.112, | |
106.86 | |
] | |
} | |
], | |
"id": 42342, | |
"interactionBox": { | |
"size": [ | |
261.882, | |
261.882, | |
191.686 | |
], | |
"center": [ | |
0, | |
240, | |
0 | |
] | |
}, | |
"pointables": [ | |
{ | |
"touchZone": "none", | |
"touchDistance": 0.333333, | |
"tool": false, | |
"direction": [ | |
0.891829, | |
0.246817, | |
-0.379109 | |
], | |
"handId": -1, | |
"id": 36, | |
"length": 35.8098, | |
"stabilizedTipPosition": [ | |
84.1415, | |
263.188, | |
60.2956 | |
], | |
"timeVisible": 0.069574, | |
"tipPosition": [ | |
84.1415, | |
263.188, | |
60.2956 | |
], | |
"tipVelocity": [ | |
23.3885, | |
358.329, | |
-98.087 | |
] | |
}, | |
{ | |
"touchZone": "hovering", | |
"touchDistance": 0.333333, | |
"tool": false, | |
"direction": [ | |
0.331701, | |
-0.409046, | |
-0.850092 | |
], | |
"handId": 40, | |
"id": 57, | |
"length": 25.103, | |
"stabilizedTipPosition": [ | |
37.5933, | |
121.8, | |
62.5981 | |
], | |
"timeVisible": 0, | |
"tipPosition": [ | |
37.5933, | |
121.8, | |
62.5981 | |
], | |
"tipVelocity": [ | |
-1431.06, | |
-1397.34, | |
-869.242 | |
] | |
} | |
], | |
"r": [ | |
[ | |
0.277301, | |
-0.232373, | |
0.932259 | |
], | |
[ | |
0.0384933, | |
-0.966845, | |
-0.252444 | |
], | |
[ | |
0.960012, | |
0.105889, | |
-0.259162 | |
] | |
], | |
"s": -153.596 | |
} | |
] |
[ | |
{ | |
"right": { | |
"vel": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"pos": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"id": null | |
}, | |
"left": { | |
"vel": { | |
"z": -402.842, | |
"y": 5.34524, | |
"x": -158.824 | |
}, | |
"pos": { | |
"z": 98.9659, | |
"y": 128.014, | |
"x": 71.4287 | |
}, | |
"id": 40 | |
}, | |
"timestamp": 3726297668 | |
}, | |
{ | |
"right": { | |
"vel": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"pos": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"id": null | |
}, | |
"left": { | |
"vel": { | |
"z": -254.885, | |
"y": 82.7066, | |
"x": -138.572 | |
}, | |
"pos": { | |
"z": 94.5354, | |
"y": 129.451, | |
"x": 69.0201 | |
}, | |
"id": 40 | |
}, | |
"timestamp": 3726315050 | |
}, | |
{ | |
"right": { | |
"vel": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"pos": { | |
"z": null, | |
"y": null, | |
"x": null | |
}, | |
"id": null | |
}, | |
"left": { | |
"vel": { | |
"z": -134.727, | |
"y": 34.6039, | |
"x": -100.969 | |
}, | |
"pos": { | |
"z": 92.1908, | |
"y": 130.053, | |
"x": 67.2629 | |
}, | |
"id": 40 | |
}, | |
"timestamp": 3726332453 | |
} | |
] |