Question/Issue: Error during running local inference
Project ID:
Context/Use case: I’m trying to collect the ECG data using the AD832 heart rate monitor and run an impulse on it, referring the Inference with custom sensor(Inference with Custom Sensor - YouTube) by Shawn Hymel.
The code I optimized for my project :
#include <ECG_MIT_2017_inferencing.h>
#define BTN_PIN 4
#define LED_R_PIN 22
#define CONVERT_S_TO_MS 0.001
#define SAMPLING_FREQ_HZ 330
#define SAMPLING_PERIOD_MS 3000/SAMPLING_FREQ_HZ
#define NUM_CHANNELS EI_CLASSIFIER_RAW_SAMPLES_PER_FRAME
#define NUM_READINGS EI_CLASSIFIER_RAW_SAMPLE_COUNT
#define NUM_CLASSES EI_CLASSIFIER_LABEL_COUNT
void setup() {
pinMode(BTN_PIN, INPUT_PULLUP);
pinMode(LED_R_PIN,OUTPUT);
digitalWrite(LED_R_PIN, HIGH);
Serial.begin(115200);
pinMode(A0,INPUT);
}
void loop() {
float ecg_input;
unsigned long timestamp;
ei_impulse_result_t result;
int err;
float input_buf[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE];
signal_t signal;
while(digitalRead(BTN_PIN)==1);
digitalWrite(LED_R_PIN,LOW);
for(int i=0; i<NUM_READINGS;i++){
timestamp=millis();
ecg_input=analogRead(ecg_input);
input_buf[(NUM_CHANNELS*i)]=ecg_input;
while(millis()<timestamp+SAMPLING_PERIOD_MS);
}
digitalWrite(LED_R_PIN,HIGH);
err=numpy::signal_from_buffer(input_buf,
EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE,
&signal);
if(err!=0){
Serial.print(“ERROR”);
Serial.print(err);
return;
}
err=run_classifier(&signal, &result, false);
if(err!=0){
Serial.print(“ERROR”);
Serial.print(err);
return;
}
Serial.println(“Prediction”);
for(int i=0;i<EI_CLASSIFIER_LABEL_COUNT;i++){
Serial.print(" “);
Serial.print(result.classification[i].label);
Serial.print(”: ");
Serial.print(result.classification[i].value);
}
while(digitalRead(BTN_PIN==0));
delay(100);
}
Error Message :
c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp: In function ‘void tflite::tensor_utils::AsymmetricQuantizeFloats(const float*, int, int8_t*, float*, int32_t*)’:
c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:84:23: error: ‘fmin’ is not a member of ‘std’
const double rmin = std::fmin(0, *minmax.first);
^
c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:84:23: note: suggested alternative:
In file included from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\cmath:44:0,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\random:38,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:66,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62,
from c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src/edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_utils_common.h:18,
from c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:16:
C:\Users\dvall\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/newlib/math.h:285:15: note: ‘fmin’
extern double fmin _PARAMS((double, double));
^
c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:85:23: error: ‘fmax’ is not a member of ‘std’
const double rmax = std::fmax(0, *minmax.second);
^
c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:85:23: note: suggested alternative:
In file included from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\cmath:44:0,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\random:38,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:66,
from c:\users\dvall\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62,
from c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src/edge-impulse-sdk/tensorflow/lite/kernels/internal/tensor_utils_common.h:18,
from c:\Users\dvall\OneDrive\Documents\Arduino\libraries\ECG_MIT_2017_inferencing\src\edge-impulse-sdk\tensorflow\lite\micro\tensor_utils_common.cpp:16:
C:\Users\dvall\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/newlib/math.h:284:15: note: ‘fmax’
extern double fmax _PARAMS((double, double));
^
exit status 1
Compilation error: exit status 1