Impulses can be deployed as a C++ library. This packages all your signal processing blocks, configuration and learning blocks up into a single package. You can include this package in your own application to run the impulse locally. In this tutorial you'll export an impulse, and build an application for Sony's Spresense development board to classify sensor data.
Knowledge required
This tutorial assumes that you're familiar with building applications for Sony's Spresense. If you're unfamiliar with either of these you build binaries directly for your development board from the Deployment page in the studio.
Note: Are you looking for an example that has all sensors included? The Edge Impulse firmware for Sony's Spresense has that. See edgeimpulse/firmware-sony-spresense.
Make sure you've followed one of the tutorials and have a trained impulse. Also install the following software:
GNU ARM Embedded Toolchain 8-2018-q4-major - make sure arm-none-eabi-gcc
is in your PATH.
We created an example repository which contains a small application for Sony's Spresense, which takes the raw features as an argument, and prints out the final classification. Download the application here, or import this repository using Git:
Head over to your Edge Impulse project, and go to the Deployment tab. From here you can create the full library which contains the impulse and all required libraries. Select C++ library and click Build to create the library.
Download the .zip
file and extract the directories in the example-standalone-inferencing-spresense/edge_impulse/
folder. Your final folder structure should look like this:
With the project ready it's time to verify that the application works. Head back to the studio and click on Live classification. Then load a validation sample, and click on a row under 'Detailed result'.
To verify that the local application classifies the same, we need the raw features for this timestamp. To do so click on the Copy to clipboard button next to 'Raw features'. This will copy the raw values from this validation file, before any signal processing or inferencing happened.
Open ei_main.cpp
and paste the raw features inside the static const float features[]
definition, for example:
Then build and flash the application to your development board:
make
)Build the application by calling make in the root directory of the project:
Connect the board to your computer using USB.
Flash the board:
Build the Docker image:
Build the application by running the container as follows:
Windows
Linux, macOS
Connect the board to your computer using USB.
Flash the board:
Or if you don't have make
installed:
To see the output of the impulse, connect to the development board over a serial port on baud rate 115200 and reset the board. You can do this with your favourite serial monitor or with the Edge Impulse CLI:
This will run the signal processing pipeline, and then classify the output, for example:
Which matches the values we just saw in the studio. You now have your impulse running on your Spresense development board!