The library file is in there, but got error of: No such file or directory

Hi everyone,
the code below got error of :
esp32-cam-cat-dog_inferencing.h: No such file or directory
but the file is in there, why?
Thanks
adam

#include <esp32-cam-cat-dog_inferencing.h>  // replace with your deployed Edge Impulse library

#define CAMERA_MODEL_AI_THINKER

#include "img_converters.h"
#include "image_util.h"
#include "esp_camera.h"
#include "camera_pins.h"

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735

#define TFT_SCLK 14 // SCL
#define TFT_MOSI 13 // SDA
#define TFT_RST  12 // RES (RESET)
#define TFT_DC    2 // Data Command control pin
#define TFT_CS   15 // Chip select control pin
                    // BL (back light) and VCC -> 3V3

#define BTN       4 // button (shared with flash led)

dl_matrix3du_t *resized_matrix = NULL;
ei_impulse_result_t result = {0};

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// setup
void setup() {
  Serial.begin(115200);

  // button
  pinMode(4, INPUT);

  // TFT display init
  tft.initR(INITR_GREENTAB); // you might need to use INITR_REDTAB or INITR_BLACKTAB to get correct text colors
  tft.setRotation(0);
  tft.fillScreen(ST77XX_BLACK);

  // cam config
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sscb_sda = SIOD_GPIO_NUM;
  config.pin_sscb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.pixel_format = PIXFORMAT_JPEG;
  config.frame_size = FRAMESIZE_240X240;
  config.jpeg_quality = 10;
  config.fb_count = 1;

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t * s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, 0); // lower the saturation
  }

  Serial.println("Camera Ready!...(standby, press button to start)");
  tft_drawtext(4, 4, "Standby", 1, ST77XX_BLUE);
}

// main loop
void loop() {

  // wait until the button is pressed
  while (!digitalRead(BTN));
  delay(100);

  // capture a image and classify it
  String result = classify();

  // display result
  Serial.printf("Result: %s\n", result);
  tft_drawtext(4, 120 - 16, result, 2, ST77XX_GREEN);
}

// classify labels
String classify() {

  // run image capture once to force clear buffer
  // otherwise the captured image below would only show up next time you pressed the button!
  capture_quick();

  // capture image from camera
  if (!capture()) return "Error";
  tft_drawtext(4, 4, "Classifying...", 1, ST77XX_CYAN);

  Serial.println("Getting image...");
  signal_t signal;
  signal.total_length = EI_CLASSIFIER_INPUT_WIDTH * EI_CLASSIFIER_INPUT_WIDTH;
  signal.get_data = &raw_feature_get_data;

  Serial.println("Run classifier...");
  // Feed signal to the classifier
  EI_IMPULSE_ERROR res = run_classifier(&signal, &result, false /* debug */);
  // --- Free memory ---
  dl_matrix3du_free(resized_matrix);

  // --- Returned error variable "res" while data object.array in "result" ---
  ei_printf("run_classifier returned: %d\n", res);
  if (res != 0) return "Error";

  // --- print the predictions ---
  ei_printf("Predictions (DSP: %d ms., Classification: %d ms., Anomaly: %d ms.): \n",
            result.timing.dsp, result.timing.classification, result.timing.anomaly);
  int index;
  float score = 0.0;
  for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    // record the most possible label
    if (result.classification[ix].value > score) {
      score = result.classification[ix].value;
      index = ix;
    }
    ei_printf("    %s: \t%f\r\n", result.classification[ix].label, result.classification[ix].value);
    tft_drawtext(4, 12 + 8 * ix, String(result.classification[ix].label) + " " + String(result.classification[ix].value * 100) + "%", 1, ST77XX_ORANGE);
  }

#if EI_CLASSIFIER_HAS_ANOMALY == 1
  ei_printf("    anomaly score: %f\r\n", result.anomaly);
#endif

  // --- return the most possible label ---
  return String(result.classification[index].label);
}

// quick capture (to clear buffer)
void capture_quick() {
  camera_fb_t *fb = NULL;
  fb = esp_camera_fb_get();
  if (!fb) return;
  esp_camera_fb_return(fb);
}

// capture image from cam
bool capture() {

  Serial.println("Capture image...");
  esp_err_t res = ESP_OK;
  camera_fb_t *fb = NULL;
  fb = esp_camera_fb_get();
  if (!fb) {
    Serial.println("Camera capture failed");
    return false;
  }

  // --- Convert frame to RGB888  ---
  Serial.println("Converting to RGB888...");
  // Allocate rgb888_matrix buffer
  dl_matrix3du_t *rgb888_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3);
  fmt2rgb888(fb->buf, fb->len, fb->format, rgb888_matrix->item);

  // --- Resize the RGB888 frame to 96x96 in this example ---
  Serial.println("Resizing the frame buffer...");
  resized_matrix = dl_matrix3du_alloc(1, EI_CLASSIFIER_INPUT_WIDTH, EI_CLASSIFIER_INPUT_HEIGHT, 3);
  image_resize_linear(resized_matrix->item, rgb888_matrix->item, EI_CLASSIFIER_INPUT_WIDTH, EI_CLASSIFIER_INPUT_HEIGHT, 3, fb->width, fb->height);

  // --- Convert frame to RGB565 and display on the TFT ---
  Serial.println("Converting to RGB565 and display on TFT...");
  uint8_t *rgb565 = (uint8_t *) malloc(240 * 240 * 3);
  jpg2rgb565(fb->buf, fb->len, rgb565, JPG_SCALE_2X); // scale to half size
  tft.drawRGBBitmap(0, 0, (uint16_t*)rgb565, 120, 120);

  // --- Free memory ---
  rgb565 = NULL;
  dl_matrix3du_free(rgb888_matrix);
  esp_camera_fb_return(fb);

  return true;
}

int raw_feature_get_data(size_t offset, size_t out_len, float *signal_ptr) {

  size_t pixel_ix = offset * 3;
  size_t bytes_left = out_len;
  size_t out_ptr_ix = 0;

  // read byte for byte
  while (bytes_left != 0) {
    // grab the values and convert to r/g/b
    uint8_t r, g, b;
    r = resized_matrix->item[pixel_ix];
    g = resized_matrix->item[pixel_ix + 1];
    b = resized_matrix->item[pixel_ix + 2];

    // then convert to out_ptr format
    float pixel_f = (r << 16) + (g << 8) + b;
    signal_ptr[out_ptr_ix] = pixel_f;

    // and go to the next pixel
    out_ptr_ix++;
    pixel_ix += 3;
    bytes_left--;
  }

  return 0;
}

// draw test on TFT
void tft_drawtext(int16_t x, int16_t y, String text, uint8_t font_size, uint16_t color) {
  tft.setCursor(x, y);
  tft.setTextSize(font_size); // font size 1 = 6x8, 2 = 12x16, 3 = 18x24
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(strcpy(new char[text.length() + 1], text.c_str()));
}

ERROR:

Arduino: 1.8.16 (Windows 7), Board: "AI Thinker ESP32-CAM, 240MHz (WiFi/BT), QIO, 80MHz"


edge-impulse-esp32-cam:11:10: fatal error: esp32-cam-cat-dog_inferencing.h: No such file or directory

 #include <esp32-cam-cat-dog_inferencing.h>  // replace with your deployed Edge Impulse library

          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

esp32-cam-cat-dog_inferencing.h: No such file or directory


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I would ask where "there" is. Also check your spelling, a case or _ instead of - etc will cause this error.

If the above doesn't help I suggest you run an example from that library. Its always good to test pieces of code before full integration.

1 Like

You mean locally and in the same folder structure as your other includes?
If so, then try

#include "esp32-cam-cat-dog_inferencing.h"
1 Like

Thanks for the reply.

the new error came out: Error compiling for board AI Thinker ESP32-CAM. the board is AI Thinker ESP32-CAM and the code is for AI Thinker ESP32-CAM.

Arduino: 1.8.16 (Windows 7), Board: "AI Thinker ESP32-CAM, 240MHz (WiFi/BT), QIO, 80MHz"

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\CMSIS\NN\Source\NNSupportFunctions\arm_nn_accumulate_q7_to_q15.c: In function 'arm_nn_accumulate_q7_to_q15':

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\CMSIS\NN\Source\NNSupportFunctions\arm_nn_accumulate_q7_to_q15.c:57:22: warning: implicit declaration of function '__PKHTB' [-Wimplicit-function-declaration]

         vo2 = (q31_t)__PKHTB(v1, v2, 16);

                      ^~~~~~~

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\CMSIS\NN\Source\NNSupportFunctions\arm_nn_accumulate_q7_to_q15.c:58:22: warning: implicit declaration of function '__PKHBT' [-Wimplicit-function-declaration]

         vo1 = (q31_t)__PKHBT(v2, v1, 16);

                      ^~~~~~~

c:/users/hua.dellv-pc/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\espressif\objs.a(debug_log.cpp.o): in function `DebugLog(char const*)':

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\espressif/debug_log.cpp:34: multiple definition of `DebugLog(char const*)'; libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\arduino\objs.a(debug_log.cpp.o):C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\arduino/debug_log.cpp:34: first defined here

c:/users/hua.dellv-pc/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\espressif\objs.a(ei_classifier_porting.cpp.o): in function `ei_read_timer_ms()':

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\espressif/ei_classifier_porting.cpp:47: multiple definition of `ei_read_timer_ms()'; libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:41: first defined here

c:/users/hua.dellv-pc/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\espressif\objs.a(ei_classifier_porting.cpp.o): in function `ei_read_timer_us()':

C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\espressif/ei_classifier_porting.cpp:51: multiple definition of `ei_read_timer_us()'; libraries\cats_and_dogs_inferencing\edge-impulse-sdk\porting\arduino\objs.a(ei_classifier_porting.cpp.o):C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\cats_and_dogs_inferencing\src\edge-impulse-sdk\porting\arduino/ei_classifier_porting.cpp:45: first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board AI Thinker ESP32-CAM.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

checked the mbed.h that included lot of statement as:

#if MBED_CONF_NSAPI_PRESENT
#include "netsocket/nsapi.h"
#include "netsocket/nsapi_ppp.h"
#endif

and:

#include "platform/mbed_wait_api.h"
#include "platform/mbed_thread.h"

seems Arduino can't use '/' , '_' in library file?

I can search out the esp32-cam-cat-dog_inferencing.h in library, maybe the IDE can't use the files in a deep multiple nesting?

Does your library have an "example" you could run?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.