Extract_imu_syntiant_features

Question/Issue: I couldn’t find this function on my library extract_imu_syntiant_features
and if I use &extract_spectral_analysis_features,
I have this error: Failed to run DSP process (-1004)
Project ID: 108781

Context/Use case: using c++ library with nRF connect on vs code using zephyr

Hi @Ghazi,

This feature extraction block is specific to Syntiant targets only, it cannot be used for other boards such as Nordic.

Aurelien

So for Nordic what should I use?

@Ghazi,

It depends on your use case but usually the Spectral Features will be good for movement/vibration analysis (just select appropriate filter in the block).

Aurelien

And how can I fix the error ?
error : Failed to run DSP process (-1004)
Project ID: 108781

Context/Use case: using c++ library with nRF connect on vs code using zephyr

-1004 is actually EIDSP_MATRIX_SIZE_MISMATCH - so one of the buffers passed into the function is the wrong size. Could you share how you’re calling the model, especially how you fill the features array?

Yes of course, I just used the application of Zephyr
#include <zephyr.h>

#include “edge-impulse-sdk/classifier/ei_run_classifier.h”

#include “edge-impulse-sdk/dsp/numpy.hpp”

#include <nrfx_clock.h>

static const float features[] = {-2.9922, -2.7266, 2.1016, -0.0078, -0.0234, 0.0313, -3.2969, -2.9219, 3.4297, -0.0234, -0.0078, 0.0391, -1.9844, -1.9063, 0.8281, -0.0156, 0.0000, 0.0313, -2.1328, -2.4609, -0.5703, -0.0156, -0.0078, 0.0469, -1.3594, -1.4922, -1.3828, -0.0156, -0.0234, 0.0469, -0.8281, -0.4063, -1.0859, -0.0156, -0.0313, 0.0391, 0.1484, -0.9141, 0.6250, -0.0156, -0.0234, 0.0313, -0.9766, -2.9844, 1.9063, -0.0313, -0.0156, 0.0469, -1.1094, -1.7578, 0.2188, -0.0313, -0.0156, 0.0547, -0.0469, 0.8125, -0.0938, -0.0156, -0.0234, 0.0313, -1.8438, 0.8281, 0.6250, -0.0234, 0.0000, 0.0234, -2.8984, -0.1328, -1.4063, -0.0313, -0.0078, 0.0156, 10.0313, -4.3828, 0.1250, -0.0156, -0.0313, 0.0391, 35.7422, -6.5547, 3.9219, -0.0234, -0.0313, 0.0469, 23.6328, -3.5078, 3.4766, -0.0391, -0.0313, 0.0313, -0.6406, 0.0781, 0.9141, -0.0313, -0.0156, 0.0391, 3.9297, 1.0781, -1.3047, -0.0313, -0.0234, 0.0234, 2.5547, 0.4141, -1.4531, -0.0313, -0.0234, 0.0234, 3.8828, -1.1094, -2.1641, -0.0313, -0.0156, 0.0156, 3.0859, -2.3125, -5.0469, -0.0313, -0.0156, 0.0156, -3.4531, -1.6719, -8.9375, -0.0391, -0.0313, 0.0234, -5.7031, -0.8203, -10.7109, -0.0391, -0.0391, 0.0313, -2.6172, -0.1406, -8.8125, -0.0469, -0.0469, 0.0391, -0.1953, 0.8125, -5.5781, -0.0469, -0.0469, 0.0313, -0.8359, 1.6250, -2.7031, -0.0469, -0.0391, 0.0313, 0.8125, 1.4141, -1.2422, -0.0391, -0.0313, 0.0234, -0.6094, 1.9453, -1.4141, -0.0391, -0.0234, 0.0156, -4.3984, 2.5547, -2.1094, -0.0313, -0.0313, 0.0234, -15.3125, 2.0156, -2.1172, -0.0391, -0.0313, 0.1094, -2.2969, 13.3828, -0.6875, -0.0391, -0.0234, 0.0547, 1.6016, 16.1484, 0.5547, -0.0234, 0.0000, -0.0469, -3.3438, 5.3906, -0.4219, -0.0234, -0.0156, 0.0000, 2.4766, 0.4922, 0.8359, -0.0234, -0.0078, 0.0000, 6.4609, -3.3750, 0.6563, -0.0156, -0.0234, 0.0391, 10.3281, -2.7656, 2.8906, -0.0391, -0.0391, 0.0625, 0.9219, 2.2656, 4.7656, -0.0391, -0.0234, 0.0391, -1.1250, 3.9766, 3.9922, -0.0234, -0.0234, 0.0313, 1.9063, 3.6406, 4.5469, -0.0234, -0.0234, 0.0234, 7.4375, 1.4141, 4.3203, -0.0156, -0.0078, 0.0156, 7.0625, -1.2734, 1.2891, -0.0234, -0.0313, 0.0156, -2.2969, -2.7266, -0.2969, -0.0234, -0.0625, 0.0469, -2.4375, -1.7813, 1.9766, -0.0313, -0.0547, 0.0547, -4.7031, 0.1016, 2.3203, -0.0313, -0.0313, 0.0469, -4.8906, 1.5234, 1.7813, -0.0234, -0.0313, 0.0469, -2.1484, 1.0547, 2.6953, -0.0234, -0.0313, 0.0469, 0.2109, 0.9609, 3.2578, -0.0313, -0.0391, 0.0703, 1.2031, 2.6875, 3.7656, -0.0234, -0.0391, 0.0547, -0.6641, 2.3203, 3.7266, -0.0234, -0.0391, 0.0469, -2.6328, 1.6328, 3.3828, -0.0234, -0.0391, 0.0547, -1.4063, 2.8984, 3.7500, -0.0234, -0.0313, 0.0547, -1.1406, 3.3672, 3.7969, -0.0156, -0.0234, 0.0469, -1.5234, 3.2109, 3.3828, -0.0078, -0.0313, 0.0469, -1.2734, 2.7422, 3.3281, -0.0078, -0.0234, 0.0469, -1.3438, 3.0547, 3.3281, -0.0078, -0.0156, 0.0391, -1.2031, 2.8984, 2.9922, 0.0000, -0.0156, 0.0391, -1.2500, 2.6250, 2.7188, -0.0078, -0.0156, 0.0469, -0.6641, 3.5547, 2.3984, -0.0078, -0.0234, 0.0469, 0.0625, 4.4141, 2.6484, 0.0000, -0.0234, 0.0469, -0.4609, 4.5313, 3.0156, 0.0000, -0.0234, 0.0313, -1.7031, 3.1641, 2.9219, 0.0000, -0.0234, 0.0313, -2.6406, 2.2031, 2.3984, 0.0000, -0.0156, 0.0391, -2.3516, 2.3281, 2.1406, 0.0000, -0.0156, 0.0391, -1.4453, 2.7734, 1.6797, 0.0000, -0.0078, 0.0391, -0.6094, 3.2500, 1.2109, 0.0000, -0.0156, 0.0391, 0.3828, 3.6094, 1.1016, 0.0000, -0.0234, 0.0391, 0.4531, 3.6406, 1.6250, 0.0000, -0.0313, 0.0469, -0.1250, 4.1641, 2.3359, 0.0000, -0.0313, 0.0391, -0.9844, 4.1875, 2.5391, 0.0000, -0.0078, 0.0391, -2.0859, 3.7969, 1.4609, 0.0078, -0.0078, 0.0313, -1.2500, 3.7656, 0.4688, 0.0000, -0.0078, 0.0313, 0.5625, 4.0234, 0.2813, 0.0000, -0.0234, 0.0313, 0.8047, 4.3281, 1.0156, 0.0000, -0.0234, 0.0234, -0.3984, 4.0859, 1.1328, 0.0078, -0.0156, 0.0234, -1.5391, 3.2734, 0.5078, 0.0078, -0.0156, 0.0234, -1.4844, 2.6719, 0.0859, 0.0078, -0.0156, 0.0234, -0.6016, 2.2422, -0.1484, 0.0078, -0.0156, 0.0234, -0.2500, 2.0625, -0.4688, 0.0078, -0.0156, 0.0391, -0.2188, 3.2109, -0.6797, 0.0078, -0.0313, 0.0313, -1.0156, 3.2656, 0.2734, 0.0078, -0.0313, 0.0234, -1.1563, 3.1328, 0.8594, 0.0156, -0.0234, 0.0234, -0.8516, 2.7891, 0.7109, 0.0156, -0.0156, 0.0234, -0.9063, 2.3125, 0.3203, 0.0156, -0.0078, 0.0234, -1.1563, 2.1250, -0.2813, 0.0156, -0.0078, 0.0234, -0.7969, 2.2813, -0.8516, 0.0156, -0.0078, 0.0234, -0.3125, 2.2344, -1.2031, 0.0156, -0.0156, 0.0156, -1.2500, 1.3281, -0.8750, 0.0156, -0.0156, 0.0078, -1.6875, -0.1719, -0.4063, 0.0156, -0.0156, 0.0078, -2.8594, -0.9688, -0.6016, 0.0156, -0.0156, 0.0156, -4.1875, -0.7578, -1.1719, 0.0156, -0.0156, 0.0234, -3.5625, -0.3047, -0.6172, 0.0156, -0.0234, 0.0234, -2.9844, -0.9531, 0.8906, 0.0156, -0.0234, 0.0234, -1.4688, -0.4922, 1.8359, 0.0156, -0.0156, 0.0313, 0.0000, 0.3281, 2.0391, 0.0156, -0.0078, 0.0078, -0.4141, -1.2500, 2.1172, 0.0156, -0.0078, 0.0156, -3.7422, -2.8047, 1.6563, 0.0156, 0.0000, 0.0234, -4.1641, -3.2734, 1.2578, 0.0156, 0.0000, 0.0391, -2.7109, -3.0781, 0.9141, 0.0078, 0.0000, 0.0547, -0.8047, -1.8359, 0.7031, 0.0078, 0.0000, 0.0469, 1.7344, -0.7813, 0.9766, 0.0156, 0.0000, 0.0391, 2.4219, -0.9219, 0.7578, 0.0156, 0.0000, 0.0234

// copy raw features here (for example from the 'Live classification' page)

// see https://docs.edgeimpulse.com/docs/running-your-impulse-zephyr

};

int raw_feature_get_data(size_t offset, size_t length, float *out_ptr) {

memcpy(out_ptr, features /* + offset */, length * sizeof(float));

return 0;

}

int main() {

// This is needed so that output of printf is output immediately without buffering

setvbuf(stdout, NULL, _IONBF, 0);

#ifdef CONFIG_SOC_NRF5340_CPUAPP

// Switch CPU core clock to 128 MHz

nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);

#endif

printk("Edge Impulse standalone inferencing (Zephyr)\n");

if (sizeof(features) / sizeof(float) != EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {

    printk("The size of your 'features' array is not correct. Expected %d items, but had %u\n",

        EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, sizeof(features) / sizeof(float));

    return 1;

}

ei_impulse_result_t result = { 0 };

while (1) {

    // the features are stored into flash, and we don't want to load everything into RAM

    signal_t features_signal;

    features_signal.total_length = sizeof(features) / sizeof(features[0]);

    features_signal.get_data = &raw_feature_get_data;

    // invoke the impulse

    EI_IMPULSE_ERROR res = run_classifier(&features_signal, &result, true);

    printk("run_classifier returned: %d\n", res);

    if (res != 0) return 1;

    printk("Predictions (DSP: %d ms., Classification: %d ms., Anomaly: %d ms.): \n",

        result.timing.dsp, result.timing.classification, result.timing.anomaly);

    // print the predictions

    printk("[");

    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {

        ei_printf_float(result.classification[ix].value);

#if EI_CLASSIFIER_HAS_ANOMALY == 1

        printk(", ");

#else

        if (ix != EI_CLASSIFIER_LABEL_COUNT - 1) {

            printk(", ");

        }

#endif

    }

#if EI_CLASSIFIER_HAS_ANOMALY == 1

    ei_printf_float(result.anomaly);

#endif

    printk("]\n");

    k_msleep(2000);

}

}

I see the same number of features (600) in your code and in your project so everything should be good. However I see that your project hasn’t been trained yet so I can’t retrieve the C++ library. Could you go through the training and re-import the C++ library?

Aurelien

It’s already trained