Skip to content

Commit 7b9cd0a

Browse files
author
Dimitar Tomov
committed
Add preloaded ML model for continious gesture detection
Signed-off-by: Dimitar Tomov <dimi@edgeimpulse.com>
1 parent 1021ef6 commit 7b9cd0a

File tree

7 files changed

+948
-0
lines changed

7 files changed

+948
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* Generated by Edge Impulse
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
#ifndef _EI_CLASSIFIER_ANOMALY_CLUSTERS_H_
23+
#define _EI_CLASSIFIER_ANOMALY_CLUSTERS_H_
24+
25+
#include "edge-impulse-sdk/anomaly/anomaly.h"
26+
27+
// (before - mean) / scale
28+
const float ei_classifier_anom_scale[EI_CLASSIFIER_ANOM_AXIS_SIZE] = { 4.735934431428502, 2.6370697886685024, 1.752289641283062 };
29+
const float ei_classifier_anom_mean[EI_CLASSIFIER_ANOM_AXIS_SIZE] = { 4.292335472136911, 2.1852703082689375, 1.6949875804138423 };
30+
31+
const ei_classifier_anom_cluster_t ei_classifier_anom_clusters[EI_CLASSIFIER_ANOM_CLUSTER_COUNT] = { { { 1.1627247333526611, -0.09127187728881836, 0.039932578802108765 }, 0.45766612185692546 }
32+
, { { 1.0793125629425049, -0.35539326071739197, -0.25196555256843567 }, 0.393853330260634 }
33+
, { { -0.6699717044830322, -0.025066491216421127, 1.8257455825805664 }, 0.4076753010490145 }
34+
, { { -0.905547022819519, -0.8271730542182922, -0.9636279940605164 }, 0.07057358582419748 }
35+
, { { -0.6083683967590332, 0.3378922939300537, -0.2750750780105591 }, 0.34529380833031026 }
36+
, { { 1.8524712324142456, -0.011566506698727608, 0.8461854457855225 }, 0.432528610593013 }
37+
, { { 1.3358670473098755, -0.05726705491542816, -0.43816810846328735 }, 0.5062860278160605 }
38+
, { { -0.7409022450447083, -0.34725621342658997, -0.8029352426528931 }, 0.21884703625369306 }
39+
, { { -0.503063440322876, -0.3759881258010864, 2.3207943439483643 }, 0.7885827511063271 }
40+
, { { -0.6956930160522461, -0.3123343288898468, 1.5905060768127441 }, 0.39691538375970054 }
41+
, { { 0.7493807077407837, 2.8090922832489014, 0.8038313388824463 }, 0.4756844734737089 }
42+
, { { -0.6844053864479065, -0.14970919489860535, -0.8244701623916626 }, 0.26707199648543406 }
43+
, { { 1.5486040115356445, 0.7133833765983582, 0.5105420351028442 }, 0.4487223169579444 }
44+
, { { 1.7191046476364136, 0.2774096429347992, 0.3952651917934418 }, 0.4223370205546866 }
45+
, { { -0.5709540247917175, 0.6095415353775024, 0.03743164613842964 }, 0.5761022260100517 }
46+
, { { -0.7589687705039978, -0.5149730443954468, 1.1454917192459106 }, 0.41873647710696993 }
47+
, { { -0.03281811252236366, 3.856318950653076, -0.06501699984073639 }, 0.4937528681009911 }
48+
, { { 0.9676327705383301, 3.318385362625122, 1.194267749786377 }, 0.3862170996134061 }
49+
, { { -0.31564873456954956, 1.6312458515167236, 0.08470914512872696 }, 0.5464022209211731 }
50+
, { { -0.4383845925331116, 3.3809237480163574, -0.20014718174934387 }, 0.5178456874700895 }
51+
, { { -0.7231196761131287, -0.3596212565898895, -0.5751107335090637 }, 0.2102935035976298 }
52+
, { { -0.5922588109970093, 0.08036672323942184, 1.3690720796585083 }, 0.4210207540244469 }
53+
, { { 1.2505220174789429, 0.2934052348136902, -0.31634294986724854 }, 0.4438873246997636 }
54+
, { { -0.4361991286277771, -0.1800207793712616, 2.741694450378418 }, 0.7265706160475239 }
55+
, { { 0.9043402075767517, -0.10142571479082108, 0.8351730704307556 }, 0.5526395773058033 }
56+
, { { 0.945662260055542, -0.027204414829611778, -0.3570230305194855 }, 0.37494576737715907 }
57+
, { { 1.8591350317001343, 0.09516841173171997, 1.431195616722107 }, 0.5613021315333133 }
58+
, { { -0.14796173572540283, 3.592709541320801, -0.3852364122867584 }, 0.46899416758090073 }
59+
, { { 1.414710521697998, 0.6246669888496399, -0.007774942554533482 }, 0.46243669139995136 }
60+
, { { 1.2696725130081177, -0.39998090267181396, 0.6421909332275391 }, 0.3975097018500365 }
61+
, { { -0.12758338451385498, 1.1125560998916626, 0.7232611775398254 }, 0.672883066503446 }
62+
, { { -0.2525366246700287, 1.0297623872756958, 2.618793249130249 }, 0.8520370623106243 }
63+
};
64+
65+
#endif // _EI_CLASSIFIER_ANOMALY_CLUSTERS_H_
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Generated by Edge Impulse
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
#ifndef _EI_CLASSIFIER_ANOMALY_TYPES_HEADER_H_
23+
#define _EI_CLASSIFIER_ANOMALY_TYPES_HEADER_H_
24+
25+
#define EI_CLASSIFIER_HAS_ANOMALY 1
26+
27+
const uint16_t EI_CLASSIFIER_ANOM_AXIS[] { 0, 11, 22 };
28+
#define EI_CLASSIFIER_ANOM_AXIS_SIZE 3
29+
#define EI_CLASSIFIER_ANOM_CLUSTER_COUNT 32
30+
31+
typedef struct {
32+
float centroid[EI_CLASSIFIER_ANOM_AXIS_SIZE];
33+
float max_error;
34+
} ei_classifier_anom_cluster_t;
35+
36+
#endif // _EI_CLASSIFIER_ANOMALY_TYPES_HEADER_H_
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* Generated by Edge Impulse
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
#ifndef _EI_CLASSIFIER_DSP_BLOCKS_H_
23+
#define _EI_CLASSIFIER_DSP_BLOCKS_H_
24+
25+
#include "model-parameters/model_metadata.h"
26+
#include "model-parameters/model_variables.h"
27+
#include "edge-impulse-sdk/classifier/ei_run_dsp.h"
28+
#include "edge-impulse-sdk/classifier/ei_model_types.h"
29+
30+
const size_t ei_dsp_blocks_size = 1;
31+
ei_model_dsp_t ei_dsp_blocks[ei_dsp_blocks_size] = {
32+
{ // DSP block 3
33+
33,
34+
&extract_spectral_analysis_features,
35+
(void*)&ei_dsp_config_3,
36+
ei_dsp_config_3_axes,
37+
ei_dsp_config_3_axes_size
38+
}
39+
};
40+
41+
#endif // _EI_CLASSIFIER_DSP_BLOCKS_H_
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
/* Generated by Edge Impulse
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
* SOFTWARE.
20+
*/
21+
22+
#ifndef _EI_CLASSIFIER_MODEL_METADATA_H_
23+
#define _EI_CLASSIFIER_MODEL_METADATA_H_
24+
25+
#include <stdint.h>
26+
27+
#define EI_CLASSIFIER_NONE 255
28+
#define EI_CLASSIFIER_UTENSOR 1
29+
#define EI_CLASSIFIER_TFLITE 2
30+
#define EI_CLASSIFIER_CUBEAI 3
31+
#define EI_CLASSIFIER_TFLITE_FULL 4
32+
#define EI_CLASSIFIER_TENSAIFLOW 5
33+
#define EI_CLASSIFIER_TENSORRT 6
34+
35+
#define EI_CLASSIFIER_SENSOR_UNKNOWN -1
36+
#define EI_CLASSIFIER_SENSOR_MICROPHONE 1
37+
#define EI_CLASSIFIER_SENSOR_ACCELEROMETER 2
38+
#define EI_CLASSIFIER_SENSOR_CAMERA 3
39+
#define EI_CLASSIFIER_SENSOR_9DOF 4
40+
#define EI_CLASSIFIER_SENSOR_ENVIRONMENTAL 5
41+
#define EI_CLASSIFIER_SENSOR_FUSION 6
42+
43+
// These must match the enum values in TensorFlow Lite's "TfLiteType"
44+
#define EI_CLASSIFIER_DATATYPE_FLOAT32 1
45+
#define EI_CLASSIFIER_DATATYPE_INT8 9
46+
47+
#define EI_CLASSIFIER_PROJECT_ID 110877
48+
#define EI_CLASSIFIER_PROJECT_OWNER "EdgeImpulse Inc."
49+
#define EI_CLASSIFIER_PROJECT_NAME "Tutorial: Continuous motion recognition"
50+
#define EI_CLASSIFIER_PROJECT_DEPLOY_VERSION 53
51+
#define EI_CLASSIFIER_NN_INPUT_FRAME_SIZE 33
52+
#define EI_CLASSIFIER_RAW_SAMPLE_COUNT 125
53+
#define EI_CLASSIFIER_RAW_SAMPLES_PER_FRAME 3
54+
#define EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE (EI_CLASSIFIER_RAW_SAMPLE_COUNT * EI_CLASSIFIER_RAW_SAMPLES_PER_FRAME)
55+
#define EI_CLASSIFIER_INPUT_WIDTH 0
56+
#define EI_CLASSIFIER_INPUT_HEIGHT 0
57+
#define EI_CLASSIFIER_INPUT_FRAMES 0
58+
#define EI_CLASSIFIER_INTERVAL_MS 16
59+
#define EI_CLASSIFIER_LABEL_COUNT 4
60+
#define EI_CLASSIFIER_HAS_ANOMALY 1
61+
#define EI_CLASSIFIER_FREQUENCY 62.5
62+
#define EI_CLASSIFIER_USE_QUANTIZED_DSP_BLOCK 0
63+
#define EI_CLASSIFIER_HAS_MODEL_VARIABLES 1
64+
65+
66+
#define EI_CLASSIFIER_OBJECT_DETECTION 0
67+
#define EI_CLASSIFIER_TFLITE_OUTPUT_DATA_TENSOR 0
68+
69+
70+
#define EI_CLASSIFIER_TFLITE_INPUT_DATATYPE EI_CLASSIFIER_DATATYPE_INT8
71+
#define EI_CLASSIFIER_TFLITE_INPUT_QUANTIZED 1
72+
#define EI_CLASSIFIER_TFLITE_INPUT_SCALE 0.11322642862796783
73+
#define EI_CLASSIFIER_TFLITE_INPUT_ZEROPOINT -128
74+
#define EI_CLASSIFIER_TFLITE_OUTPUT_DATATYPE EI_CLASSIFIER_DATATYPE_INT8
75+
#define EI_CLASSIFIER_TFLITE_OUTPUT_QUANTIZED 1
76+
#define EI_CLASSIFIER_TFLITE_OUTPUT_SCALE 0.00390625
77+
#define EI_CLASSIFIER_TFLITE_OUTPUT_ZEROPOINT -128
78+
79+
80+
81+
#define EI_CLASSIFIER_INFERENCING_ENGINE EI_CLASSIFIER_TFLITE
82+
83+
84+
#define EI_CLASSIFIER_COMPILED 1
85+
#define EI_CLASSIFIER_HAS_TFLITE_OPS_RESOLVER 1
86+
87+
88+
#define EI_CLASSIFIER_HAS_FFT_INFO 0
89+
90+
#define EI_CLASSIFIER_SENSOR EI_CLASSIFIER_SENSOR_ACCELEROMETER
91+
#define EI_CLASSIFIER_FUSION_AXES_STRING "accX + accY + accZ"
92+
93+
#ifndef EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW
94+
#define EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW 4
95+
#endif // EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW
96+
#define EI_CLASSIFIER_SLICE_SIZE (EI_CLASSIFIER_RAW_SAMPLE_COUNT / EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW)
97+
98+
#if EI_CLASSIFIER_INFERENCING_ENGINE == EI_CLASSIFIER_TFLITE && EI_CLASSIFIER_USE_FULL_TFLITE == 1
99+
#undef EI_CLASSIFIER_INFERENCING_ENGINE
100+
#undef EI_CLASSIFIER_HAS_TFLITE_OPS_RESOLVER
101+
#define EI_CLASSIFIER_INFERENCING_ENGINE EI_CLASSIFIER_TFLITE_FULL
102+
#define EI_CLASSIFIER_HAS_TFLITE_OPS_RESOLVER 0
103+
#if EI_CLASSIFIER_COMPILED == 1
104+
#error "Cannot use full TensorFlow Lite with EON"
105+
#endif
106+
#endif // EI_CLASSIFIER_INFERENCING_ENGINE == EI_CLASSIFIER_TFLITE && EI_CLASSIFIER_USE_FULL_TFLITE == 1
107+
108+
typedef struct {
109+
uint16_t implementation_version;
110+
int axes;
111+
float scale_axes;
112+
bool average;
113+
bool minimum;
114+
bool maximum;
115+
bool rms;
116+
bool stdev;
117+
bool skewness;
118+
bool kurtosis;
119+
} ei_dsp_config_flatten_t;
120+
121+
typedef struct {
122+
uint16_t implementation_version;
123+
int axes;
124+
const char * channels;
125+
} ei_dsp_config_image_t;
126+
127+
typedef struct {
128+
uint16_t implementation_version;
129+
int axes;
130+
int num_cepstral;
131+
float frame_length;
132+
float frame_stride;
133+
int num_filters;
134+
int fft_length;
135+
int win_size;
136+
int low_frequency;
137+
int high_frequency;
138+
float pre_cof;
139+
int pre_shift;
140+
} ei_dsp_config_mfcc_t;
141+
142+
typedef struct {
143+
uint16_t implementation_version;
144+
int axes;
145+
float frame_length;
146+
float frame_stride;
147+
int num_filters;
148+
int fft_length;
149+
int low_frequency;
150+
int high_frequency;
151+
int win_size;
152+
int noise_floor_db;
153+
} ei_dsp_config_mfe_t;
154+
155+
typedef struct {
156+
uint16_t implementation_version;
157+
int axes;
158+
float scale_axes;
159+
} ei_dsp_config_raw_t;
160+
161+
typedef struct {
162+
uint16_t implementation_version;
163+
int axes;
164+
float scale_axes;
165+
const char * filter_type;
166+
float filter_cutoff;
167+
int filter_order;
168+
const char * analysis_type;
169+
int fft_length;
170+
int spectral_peaks_count;
171+
float spectral_peaks_threshold;
172+
const char * spectral_power_edges;
173+
bool do_log;
174+
bool do_fft_overlap;
175+
int wavelet_level;
176+
const char * wavelet;
177+
} ei_dsp_config_spectral_analysis_t;
178+
179+
typedef struct {
180+
uint16_t implementation_version;
181+
int axes;
182+
float frame_length;
183+
float frame_stride;
184+
int fft_length;
185+
int noise_floor_db;
186+
bool show_axes;
187+
} ei_dsp_config_spectrogram_t;
188+
189+
typedef struct {
190+
uint16_t implementation_version;
191+
int axes;
192+
float frame_length;
193+
float frame_stride;
194+
int num_filters;
195+
int fft_length;
196+
int low_frequency;
197+
int high_frequency;
198+
float pre_cof;
199+
} ei_dsp_config_audio_syntiant_t;
200+
201+
typedef struct {
202+
uint16_t implementation_version;
203+
int axes;
204+
bool scaling;
205+
} ei_dsp_config_imu_syntiant_t;
206+
207+
#endif // _EI_CLASSIFIER_MODEL_METADATA_H_

0 commit comments

Comments
 (0)