I managed to compile under the Arduino IDE, basically putting all object files in an archive to bypass the Windows command line issue.
You can create a platform.local.txt file under the ESP32 target folder (C:\Users\MYUSER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4) with the following content:
## Customized platform.local.txt to compile for ESP32 targets under Windows
## This recipe works around the Windows limit of 32k characters in a cmd line by calling .o files from a text file during linking
## Install: put file under your esp32 sub-directory - ie:C:\Users\MYUSER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4
## You can also find the local arduino folder in the IDE under File -> Preferences -> see preferences.txt location in the bottom part of the window
## hooks
# create a txt file with all object file paths from libraries and sketch folders
recipe.hooks.linking.prelink.1.pattern=cmd /c dir /b /s {build.path}\sketch\*.o > {build.path}\obj_files_tmp.txt
recipe.hooks.linking.prelink.2.pattern=cmd /c "dir /b /s {build.path}\libraries\*.o >> {build.path}\obj_files_tmp.txt 2>nul & exit 0"
# replace \ by \\ in file paths (otherwise escaped by linker) and save in new txt file
recipe.hooks.linking.prelink.3.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files_tmp.txt) do (set line=%a && set line=!line:\=\\! && echo !line! >> {build.path}\obj_files.txt)"
# save object files in archive
recipe.hooks.linking.prelink.4.pattern=cmd /v /c "@echo off && for /f %a in ({build.path}\obj_files.txt) do ({compiler.path}{compiler.ar.cmd} {compiler.ar.flags} {compiler.ar.extra_flags} {build.path}\custom_lib.a %a)"
# delete txt file and archive after linking
recipe.hooks.linking.postlink.1.pattern=cmd /c del {build.path}\obj_files.txt
recipe.hooks.linking.postlink.2.pattern=cmd /c del {build.path}\custom_lib.a
## modify compile patterns (use custom_lib.a instead of object_files)
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} -Wl,--start-group "{build.path}\custom_lib.a" "{archive_file_path}" {compiler.c.elf.libs} -Wl,--end-group -Wl,-EL -o "{build.path}/{build.project_name}.elf"
I created my image object recognition application, which I exported to the Arduino for the ESP32CAM,
So how do I get my data into the application?
When I run the application, I get the following message in the Arduino IDE Serial Port Monitor: Edge Impulse standalone inferencing (Arduino) The size of your ‘features’ array is not correct. Expected 9216 items, but had 0
Once it works, you can proceed with filling the features array directly from your ESP32Cam (you should capture a 96x96 pixels image) and check results for 1 image.
Final step is to fill the features array dynamically in the loop() so your inference can run continuously.
@tcontrada After you’ve managed to get it working based on @aurel’s comments the prefered way of getting data in is by implementing the signal.get_data callback:
int raw_feature_get_data(size_t offset, size_t length, float *out_ptr) {
// Here read `length` bytes from offset `offset` from the camera's *frame buffer*
// then copy into `out_ptr` in the format from Studio
// (1 pixel per value like 0xFF0000 for red)
return 0;
}
signal_t features_signal;
features_signal.total_length = EI_CLASSIFIER_INPUT_WIDTH * EI_CLASSIFIER_INPUT_HEIGHT;
features_signal.get_data = &raw_feature_get_data;
This way you don’t allocate another large buffer, but can stream straight from frame buffer => neural network.
In the Arduino sketch, you have the following array assignment:
static const float features[] = { ... }
It needs to be filled with the pixels from the image you want to classify. First step is just to make sure it works, by pasting an image example directly from your Edge Impulse project. Then you can use the ESP32Cam method to capture a frame (probably with esp_camera_fb_get() but I’m not familiar with this target).
It looks like the program tries to access some prohibited memory space but you’ll need to decode the backtrace to understand where the issue comes from. This plugin seems to do the work: https://github.com/me-no-dev/EspExceptionDecoder
Also what is the RAM and Flash capacity on your board?
In the configuration for Huge app on the ESP32 CAM, max flash is 3145728, max ram is 327680
Is this enough to run the application? The CAM board has a micro SD card slot available as well…
@janjongboom I just received an ESP32 cam. I’m trying to learn how the data is classified. Does the software support classification of live streaming data or is it just classifying single pictures/frames?
Frame-by-frame, I don’t really get how you would do live streaming of the data. The buffer should remain the same until classification is done, then you can read from the camera again.