This is an example showing how to deploy the face mask detection model on OpenMV Cam H7 with TinyEngine.
Note: This section is basically from https://github.com/openmv/openmv/blob/master/src/README.md. Please refer to the OpenMV's repo for more details or steps on different env.
sudo apt-get update
sudo apt-get install git build-essential
Install arm toolchain
TOOLCHAIN_PATH=/usr/local/arm-none-eabi
TOOLCHAIN_URL="https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2"
sudo mkdir ${TOOLCHAIN_PATH}
wget --no-check-certificate -O - ${TOOLCHAIN_URL} | sudo tar --strip-components=1 -jx -C ${TOOLCHAIN_PATH}
export PATH=${TOOLCHAIN_PATH}/bin:${PATH}
cd examples/openmv_face_mask_detection/
git clone https://github.com/openmv/openmv.git
Currently, we don't have compatibility tests for the OpenMV source, so let's use the version that has been manually tested before.
cd tinyengine/examples/openmv_face_mask_detection/openmv
git checkout 918ccb937730cc759ee5709df089d9de516dc7bf
git submodule update --init --recursive
Let's first build the firmware from the source to make sure all required dependencies are correctly installed. The TARGET
is set to OPENMV4
for OpenMV Cam H7.
cd tinyengine/examples/openmv_face_mask_detection/openmv
make -j4 -C src/micropython/mpy-cross
make -j4 TARGET=OPENMV4 -C src
You should see the compiled binary at openmv/src/build/bin/firmware.bin
.
The patch is to
- disable some features in the firmware for SRAM and Flash space
- setup for TinyEngine source
- add the detection application code in
exampleemodule.c
cd tinyengine/examples/openmv_face_mask_detection/openmv
git apply ../openmv_face_mask_detection.patch
cd tinyengine/examples/openmv_face_mask_detection
sh gen_code.sh
Copy the generated code at tinyengine/example/openmv_face_mask_detection/codegen
into the openvm source.
cd openmv/
make -j4 TARGET=OPENMV4 -C src
Flash the binary openmv/src/build/bin/firmware.bin
into your OpenMV Cam. Please refer to the official Instructions.
- Open OpenMV IDE
- Connect your OpenMV cam to the PC
- Run the python script
tinyengine/examples/openmv_face_mask_detection/face_detection_demo.py
in OpenMV IDE.