Demo 50: Bring Tensorflow Lite to ESP32 Arduino - person detection application using deep learning with ESP32 CAM

1. Introduction
Deep learning is hot. It is hotter when you can run it on ESP32 a hot MCU for IoT. I made a demo Demo 47: Deep learning - Computer vision with ESP32 and tensorflow.js It is an interesting demo but it not really run on ESP32. Today I will make another demo that is bring Tensorflow Lite to ESP32 Arduino through person detection application using deep learning with ESP32 CAM.
Figure: Bring Tensorflow Lite to ESP32 Arduino
2. Hardware
I use the ESP32 CAM module
Figure: ESP32 CAM with OV2640 cam
3. Software
I prepared the resources and the code for you.
Steps to install:
- Install libraries Jpeg decoder and Tensorflow lite.
Jpeg decoder: https://github.com/nhatuan84/tensorflow-lite-esp32-person-detection/blob/master/resources/JPEGDecoder-master.zip
Tensorflow lite: https://github.com/nhatuan84/tensorflow-lite-esp32-person-detection/blob/master/resources/tensorflow_lite.zip
- Install zip libraries, choose Sketch > Include Library > Add .Zip Library
- Download Arduino code and open it with Arduino IDE:
Arduino code: https://github.com/nhatuan84/tensorflow-lite-esp32-person-detection/tree/master/Arduino_code/person_detect
- After flashed the code, open the Terminal to see the IP address of the board.
- Open Web browser and type the IP address above and enjoy the result
4. Result
It is not really smooth and slow.


Post a Comment

3 Comments

David Nguyen said…
The project cannot be compiled.
Pradeep Mishra said…
In file included from E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src\tensorflow\lite\micro\kernels\concatenation.cpp:15:0:
E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/tensorflow/lite/kernels/internal/reference/concatenation.h: In function 'void tflite::reference_ops::ConcatenationWithScaling(const tflite::ConcatenationParams&, const tflite::RuntimeShape* const*, const uint8* const*, const tflite::RuntimeShape&, uint8*)':
E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/tensorflow/lite/kernels/internal/reference/concatenation.h:125:36: error: 'round' is not a member of 'std'
static_cast(std::round(input_ptr[j] * scale + bias)) +
^
E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/tensorflow/lite/kernels/internal/reference/concatenation.h:125:36: note: suggested alternative:
In file included from c:\users\prads\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\cmath:44:0,
from c:\users\prads\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\random:38,
from c:\users\prads\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\bits\stl_algo.h:66,
from c:\users\prads\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0\algorithm:62,
from E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/third_party/gemmlowp/fixedpoint/fixedpoint.h:21,
from E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/tensorflow/lite/kernels/internal/common.h:24,
from E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src/tensorflow/lite/kernels/internal/reference/concatenation.h:19,
from E:\Users\prads\Documents\Arduino\libraries\tensorflow_lite\src\tensorflow\lite\micro\kernels\concatenation.cpp:15:
C:\Users\prads\AppData\Local\arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/newlib/math.h:278:15: note: 'round'
extern double round _PARAMS((double));
^
Multiple libraries were found for "WiFi.h"
Used: C:\Users\prads\AppData\Local\arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
Multiple libraries were found for "SD.h"
Used: C:\Users\prads\AppData\Local\arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
Error compiling for board AI Thinker ESP32-CAM.
Great post, much appreciate the time you took to write this.