|
4 | 4 | SPDX-License-Identifier: MIT |
5 | 5 | --> |
6 | 6 | <script lang="ts"> |
| 7 | + import { onMount } from 'svelte'; |
| 8 | + import { ClassifierInput } from '../../../lib/domain/ClassifierInput'; |
7 | 9 | import { stores } from '../../../lib/stores/Stores'; |
| 10 | + import StaticConfiguration from '../../../StaticConfiguration'; |
| 11 | + import StandardButton from '../../ui/buttons/StandardButton.svelte'; |
8 | 12 | import Fingerprint from '../../ui/recording/Fingerprint.svelte'; |
9 | 13 |
|
10 | 14 | export let gestureName: string; |
11 | 15 | const classifier = stores.getClassifier(); |
12 | 16 | const filters = classifier.getFilters(); |
| 17 | + const highlightedAxes = stores.getHighlightedAxes(); |
| 18 | + $: liveData = $stores.liveData; |
| 19 | + let filteredNormalizedInput: null | number[] = null; |
13 | 20 |
|
14 | 21 | $: filtersLabels = $filters.flatMap(filter => { |
15 | 22 | const filterName = filter.getName(); |
16 | 23 | return [`${filterName} - x`, `${filterName} - y`, `${filterName} - z`]; |
17 | 24 | }); |
18 | | - $: fingerprint = $classifier.filteredInput.normalized.getValue(); |
| 25 | + // $: fingerprint = $classifier.filteredInput.normalized.getValue(); |
| 26 | + onMount(() => { |
| 27 | + return liveData?.subscribe(() => { |
| 28 | + try { |
| 29 | + if (liveData) { |
| 30 | + const bufferedData = liveData |
| 31 | + .getBuffer() |
| 32 | + .getSeries( |
| 33 | + StaticConfiguration.pollingPredictionSampleDuration, |
| 34 | + StaticConfiguration.pollingPredictionSampleSize, |
| 35 | + ); |
| 36 | + filteredNormalizedInput = ClassifierInput.getInputForAxes( |
| 37 | + bufferedData.map(e => e.value), |
| 38 | + $highlightedAxes, |
| 39 | + ).getNormalizedInput(filters); |
| 40 | + } |
| 41 | + } catch (error) {} |
| 42 | + }); |
| 43 | + }); |
19 | 44 | </script> |
20 | 45 |
|
21 | | -<div class="w-7 overflow-hidden"> |
22 | | - <div style="margin-left: -8px;margin-bottom: -7px"> |
| 46 | +<div class="w-7 h-full"> |
| 47 | + {#if !!filteredNormalizedInput} |
23 | 48 | <Fingerprint |
24 | | - height={166} |
25 | | - width={100} |
26 | 49 | filterLabels={filtersLabels} |
27 | 50 | title={gestureName} |
28 | | - {fingerprint} /> |
29 | | - </div> |
| 51 | + fingerprint={filteredNormalizedInput} /> |
| 52 | + {/if} |
30 | 53 | </div> |
0 commit comments