| Input: α, the coefficients of the low-pass filter |
| β, the coefficients to adjust the fluctuation characteristic |
| Emax, the user-set maximum cumulative error threshold |
| Ebavg, the average error of the initial quiet period |
| Output: A complete gesture signal segment |
| /∗ initialization ∗/; |
| i ← 0, A ← []; |
| k ← 0, Segment ← [], P ← []; |
| while Get ith 3-axis acceleration sample: Ax, Ay, Az do |
| /∗ signal synthesis and filtering ∗/; |
| |
| ; |
| ; |
| ; |
| /∗ SW or SWAB ∗/; |
| start ← Segment[k − 1], end ← i − 1; |
| ← linear regression to fit a line for A[start: end]; |
| for j = start ⟶ end do |
| Ecum ← Ecum + |
| end |
| if Ecum > Emaxthen |
| /∗ a new segment is cut out by SW or SWAB ∗/; |
| Segment[k] ← i − 1; |
| Eavg ← 1/ai Ecum; |
| /∗ set the fluctuation characteristic ∗/; |
| if Eavg < βEbavgthen |
| P[k] ← 0; |
| else |
| P[k] ← 1; |
| end |
| /∗ process by merge Algorithm ∗/; |
| Segment, P, k ← merge(Segment, P, k); |
| /∗ check if a complete segment is cut-out ∗/; |
| if [P [0], P [1], P [2]] = [1, 0, 1] then |
| TS ← A[0: Segment[0]]; |
| output TS for recognition; |
| end |
| k ← k + 1; |
| end |
| end |