This repository demonstrates pre-compiling the Edge Impulse's C++ library export (includes model) into a shared or static library and linking to a C or C++ application.
No hardware optimization! This example repository contains the bare minimum example of compiling your impulse, and does not contain hardware optimizations for MPUs or on Linux. See example-standalone-inferencing-linux to compile with optimizations.
See shared/
for example of linking with precompiled shared Edge Impulse library and see static
for an example with linking with a statically linked library.
To build only the library skip this step and jump to Build your [static|shared] library and link with application
To get started head over to your Edge Impulse project, and go to Deployment. From here you can create the full library which contains the impulse and all external required libraries. Select C++ library, and click Build to create the library.
Download the .zip, extract and place the contents in C/ and/or C++/ directory depending on which you'd like to build.
Copy a test sample's raw features into the features[]
array in C++/*/source/main.cpp or in C/*/source/main.c. To obtain raw features head back to Studio and click on the Live Classification. Then load a validation sample and then copy the Raw Features. For more information see Add data sample to main.cpp
- To build C application:
- Go to C/static
- To build C++ application:
- Go to C++/static
Then in a terminal or console:
sh build.sh
build.bat
This will build build/edge-impulse-standalone
and the build/libedgeimpulse.a
- To build C application:
- Go to C/shared
- To build C++ application:
- Go to C++/shared
Then in a terminal or console:
sh build.sh
build.bat
This will build build/edge-impulse-standalone
and the build/libedgeimpulse.so
To run the built application go to the console or terminal and:
./build/edge-impulse-stadanlone
E.g. if you built with the following:
- Project: Tutorial: Continuous Motion Recoginition
- Docs: Tutorial: Continuous Motion Recoginition
- Sample:
updown.1.cbor.1q53q9pl
at timestample0
you'd get similar results as below:
run_classifier returned: 0
Timing: DSP 0 ms, inference 0 ms, anomaly 0 ms
Predictions:
idle: 0.00000
snake: 0.00000
updown: 0.99609
wave: 0.00000
Anomaly prediction: -0.540
To use another toolchain other than GNU (gcc/g++
) e.g. clang.
Then you can do so as follows:
CC=clang CXX=clang++ make -j
This repo builds the application by default for your computer (x86). However this can easily adapted for your (embedded) target. Edit Makefile
for your target. See e.g. "Target specific" in Makefile
.