I am implementing my custom preprocessing block and I came across the rich implementations inside “edge-impulse-sdk/dsp”. Sadly, when I try to #include "edge-impulse-sdk/dsp/spectral/processing.hpp"
inside my own preprocessing.hpp
file there are plenty of linker errors, relating to multiple definitions. I have tried similar #include
s but no luck.
Here is the output from Mbed Studio, using (GCC-ARM):
Compile [100.0%]: preprocessing.cpp
[Warning] processing.hpp@512,16: 'int ei::spectral::processing::find_fft_peaks(ei::matrix_i32_t*, ei::matrix_i32_t*, float, float, uint16_t)' defined but not used [-Wunused-function]
[Warning] processing.hpp@360,16: 'int ei::spectral::processing::find_fft_peaks(ei::matrix_t*, ei::matrix_t*, float, float, uint16_t)' defined but not used [-Wunused-function]
[Warning] processing.hpp@177,16: 'int ei::spectral::processing::i16_filter(ei::matrix_i16_t*, float, uint8_t, float, float, int)' defined but not used [-Wunused-function]
[Warning] processing.hpp@144,16: 'int ei::spectral::processing::butterworth_highpass_filter(ei::matrix_t*, float, float, uint8_t)' defined but not used [-Wunused-function]
[Warning] processing.hpp@115,16: 'int ei::spectral::processing::butterworth_lowpass_filter(ei::matrix_t*, float, float, uint8_t)' defined but not used [-Wunused-function]
Link: example-standalone-inferencing-mbed
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::ei_matrix::~ei_matrix()':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/numpy.hpp:1522: multiple definition of `ei::spectral::processing::spectral_power_edges(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:608: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::spectral_power_edges(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:661: multiple definition of `ei::spectral::processing::spectral_power_edges(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:661: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::periodogram(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float, unsigned short)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:728: multiple definition of `ei::spectral::processing::periodogram(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float, unsigned short)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:728: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::periodogram(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float, unsigned short)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:820: multiple definition of `ei::spectral::processing::periodogram(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float, unsigned short)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:820: first defined here
collect2.exe: error: ld returned 1 exit status
[ERROR] c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::ei_matrix::~ei_matrix()':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/numpy.hpp:1522: multiple definition of `ei::spectral::processing::spectral_power_edges(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:608: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::spectral_power_edges(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:661: multiple definition of `ei::spectral::processing::spectral_power_edges(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:661: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::periodogram(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float, unsigned short)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:728: multiple definition of `ei::spectral::processing::periodogram(ei::ei_matrix*, ei::ei_matrix*, ei::ei_matrix*, float, unsigned short)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:728: first defined here
c:/gnu_arm_embedded/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/preprocessing.o: in function `ei::spectral::processing::periodogram(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float, unsigned short)':
c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/././edge-impulse-sdk/dsp/spectral/processing.hpp:820: multiple definition of `ei::spectral::processing::periodogram(ei::ei_matrix_i16*, ei::ei_matrix_i16*, ei::ei_matrix_i16*, float, unsigned short)'; BUILD/ARDUINO_NANO33BLE/GCC_ARM/source/main.o:c:\Users\Kique\Mbed Programs\example-standalone-inferencing-mbed/./edge-impulse-sdk/dsp/spectral/processing.hpp:820: first defined here
collect2.exe: error: ld returned 1 exit status
I would love to be able to benefit from those implementations, like the ones inside numpy.hpp
, which I’m already using and are phenomenal.
The sdk is really rich but the documentation for this portion is just the comments inside the .hpp
files so I would appreciate if you could also confirm this is a good structure for my preprocessing.hpp
:
#ifndef _PREPROCESSING_H_
#define _PREPROCESSING_H_
#include "numpy.hpp"
#include "ei_model_types.h"
//#include "edge-impulse-sdk/dsp/spectral/processing.hpp" // linker errors
// Depending on your block:
typedef struct {
uint16_t implementation_version;
int axes;
float scale_axes;
bool center_data;
int filter_order;
float cutoff;
} ei_dsp_config_custom_t;
int extract_custom_block_features(signal_t *signal, matrix_t *output_matrix, void *config_ptr, const float f);
#endif // _PREPROCESSING_H_
Thanks in advance!