run_classifier_init
run_classifier_continuous(). This includes the moving average filter (MAF). This function should be called prior to calling run_classifier_continuous().
Blocking: yes
Example: nano_ble33_sense_microphone_continuous.ino
run_classifier_init
run_classifier_continuous(). This includes the moving average filter (MAF). This function should be called prior to calling run_classifier_continuous().
Blocking: yes
Example: nano_ble33_sense_microphone_continuous.ino
Parameters
handlestruct with information about model and DSP
run_classifier_deinit
run_classifier_continuous(), which includes the moving average filter (MAF). This function should be called when you are done running continuous classification.
Blocking: yes
Example: ei_run_audio_impulse.cpp
run_classifier_continuous
signal parameter. It performs preprocessing (DSP) on this new slice of features and appends the output to a sliding window of pre-processed features (stored in a static features matrix). The matrix stores the new slice and as many old slices as necessary to make up one full sample for performing inference.
run_classifier_init() must be called before making any calls to run_classifier_continuous().
For example, if you are doing keyword spotting on 1-second slices of audio and you want to perform inference 4 times per second (given by EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW), you would collect 0.25 seconds of audio and call run_classifier_continuous(). The function would compute the Mel-Frequency Cepstral Coefficients (MFCCs) for that 0.25 second slice of audio, drop the oldest 0.25 seconds’ worth of MFCCs from its internal matrix, and append the newest slice of MFCCs. This process allows the library to keep track of the pre-processed features (e.g. MFCCs) in the window instead of the entire set of raw features (e.g. raw audio data), which can potentially save a lot of space in RAM. After updating the static matrix, inference is performed using the whole matrix, which acts as a sliding window of pre-processed features.
Additionally, a moving average filter (MAF) can be enabled for run_classifier_continuous(), which averages (arithmetic mean) the last n inference results for each class. n is EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW / 2. In our example above, if we enabled the MAF, the values in result would contain predictions averaged from the previous 2 inferences.
To learn more about run_classifier_continuous(), see this guide on continuous audio sampling. While the guide is written for audio signals, the concepts of continuous sampling and inference can be extrapolated to any time-series data.
Blocking: yes
Example: nano_ble33_sense_microphone_continuous.ino
Parameters
- 
signalPointer to a signal_t struct that contains the number of elements in the slice of raw features (e.g.EI_CLASSIFIER_SLICE_SIZE) and a pointer to a callback that reads in the slice of raw features. - 
resultPointer to anei_impulse_result_tstruct that contains the various output results from inference after run_classifier() returns. - 
debugPrint internal preprocessing and inference debugging information viaei_printf(). - 
enable_mafEnable the moving average filter (MAF) for the classifier. 
Returns
Error code as defined byEI_IMPULSE_ERROR enum. Will be EI_IMPULSE_OK if inference completed successfully.
run_classifier_continuous
signal parameter. It performs preprocessing (DSP) on this new slice of features and appends the output to a sliding window of pre-processed features (stored in a static features matrix). The matrix stores the new slice and as many old slices as necessary to make up one full sample for performing inference.
run_classifier_init() must be called before making any calls to run_classifier_continuous().
For example, if you are doing keyword spotting on 1-second slices of audio and you want to perform inference 4 times per second (given by EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW), you would collect 0.25 seconds of audio and call run_classifier_continuous(). The function would compute the Mel-Frequency Cepstral Coefficients (MFCCs) for that 0.25 second slice of audio, drop the oldest 0.25 seconds’ worth of MFCCs from its internal matrix, and append the newest slice of MFCCs. This process allows the library to keep track of the pre-processed features (e.g. MFCCs) in the window instead of the entire set of raw features (e.g. raw audio data), which can potentially save a lot of space in RAM. After updating the static matrix, inference is performed using the whole matrix, which acts as a sliding window of pre-processed features.
Additionally, a moving average filter (MAF) can be enabled for run_classifier_continuous(), which averages (arithmetic mean) the last n inference results for each class. n is EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW / 2. In our example above, if we enabled the MAF, the values in result would contain predictions averaged from the previous 2 inferences.
To learn more about run_classifier_continuous(), see this guide on continuous audio sampling. While the guide is written for audio signals, the concepts of continuous sampling and inference can be extrapolated to any time-series data.
Blocking: yes
Example: nano_ble33_sense_microphone_continuous.ino
Parameters
- 
impulseei_impulse_handle_tstruct with information about preprocessing and model. - 
signalPointer to a signal_t struct that contains the number of elements in the slice of raw features (e.g.EI_CLASSIFIER_SLICE_SIZE) and a pointer to a callback that reads in the slice of raw features. - 
resultPointer to anei_impulse_result_tstruct that contains the various output results from inference after run_classifier() returns. - 
debugPrint internal preprocessing and inference debugging information viaei_printf(). - 
enable_mafEnable the moving average filter (MAF) for the classifier. 
Returns
Error code as defined byEI_IMPULSE_ERROR enum. Will be EI_IMPULSE_OK if inference completed successfully.
run_classifier
Parameters
- 
signalPointer to asignal_tstruct that contains the total length of the raw feature array, which must match EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, and a pointer to a callback that reads in the raw features. - 
resultPointer to an ei_impulse_result_t struct that will contain the various output results from inference afterrun_classifier()returns. - 
debugPrint internal preprocessing and inference debugging information viaei_printf(). 
Returns
Error code as defined byEI_IMPULSE_ERROR enum. Will be EI_IMPULSE_OK if inference completed successfully.
run_classifier
signal_t input struct pointing to a callback that reads in pages of raw features. run_classifier() performs any necessary preprocessing on the raw features (e.g. DSP, cropping of images, etc.) before performing inference. Results from inference are stored in an ei_impulse_result_t struct.
Blocking: yes
Example: standalone inferencing main.cpp
Parameters
- 
impulsePointer to anei_impulse_handle_tstruct that contains the model and preprocessing information. - 
signalPointer to asignal_tstruct that contains the total length of the raw feature array, which must match EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, and a pointer to a callback that reads in the raw features. - 
resultPointer to an ei_impulse_result_t struct that will contain the various output results from inference afterrun_classifier()returns. - 
debugPrint internal preprocessing and inference debugging information viaei_printf(). 
Returns
Error code as defined byEI_IMPULSE_ERROR enum. Will be EI_IMPULSE_OK if inference completed successfully.