Project Overview

This project utilizes the ESP32-S3 AI CAM module and EdgeImpulse to recognize apples and oranges. Through this project, you will learn how to train your own model using EdgeImpulse and deploy it on the ESP32-S3 AI CAM module.

firebeetle ESP32
  • EdgeImpulse Official Website: https://edgeimpulse.com/
  • EdgeImpulse Project Link: [https://studio.edgeimpulse.com/public/571380/live

Data Collection

  1. Burn the "CameraWebServer" example code to the ESP32-S3 AI CAM module.
  2. Open the serial monitor to check the IP address.
  3. Access the IP address through a browser on a device within the same local network. Click the “Start” button to view the camera feed.
  4. Save images to your computer by clicking the upper-right corner of the video frame. (It is recommended to save images of different objects in separate folders for easier data labeling during training.)

Note: Collect as much image data as possible to improve model accuracy. For this project, around 50 images of apples and oranges were used.

firebeetle ESP32

Collected image dataset:

firebeetle ESP32

Data Labeling

  1. Create a new project in EdgeImpulse.
firebeetle ESP32
  1. Click “Add existing data” to upload collected images.
firebeetle ESP32
  1. Select “Upload data” and upload image files. Enter corresponding labels for the images.
firebeetle ESP32
  1. In “Data acquisition -> Labeling queue”, mark the object of interest in the images and save.
firebeetle ESP32

Example: Labeling oranges:

firebeetle ESP32

Training the Model

  1. Once all data is labeled, navigate to “Impulse design -> Create impulse” to create and save your impulse.
    Processing blocks explanation: EdgeImpulse Documentation
    firebeetle ESP32

  2. Go to the “image” page and click “Save parameters”.
    firebeetle ESP32

  3. Navigate to the “Generate features” page and click “Generate features” to extract image features.
    firebeetle ESP32

  4. Go to “Object detection”, then click “Save & train” to train the model.
    firebeetle ESP32

  5. Once training is complete, review model performance. Adjust parameters and retrain if necessary.
    firebeetle ESP32

  6. Go to the "Retrain model" page and click "Train model"
    firebeetle ESP32


Deploying the Model

Here's the English translation of the steps:

  1. Extract the trained model files into the "libraries" folder of your Arduino installation directory.

  2. Download the files: 【conv.cpp】, 【depthwise_conv.cpp】, and the 【edge_camera】 folder.

  3. Copy the downloaded conv.cpp and depthwise_conv.cpp files into your trained model's folder, replacing existing files if prompted.

  • Path: Your_Trained_Model_Folder\src\edge-impulse-sdk\tensorflow\lite\micro\kernels

  1. Copy the entire 【edge_camera】 folder and paste it into your trained model's directory.
  • Path: Your_Trained_Model_Folder\examples

  1. Open Arduino IDE, locate the 【edge_camera】 example sketch. Replace the header file with your model's header and input your WiFi credentials (SSID and password).

  1. Compile and upload the sketch. Open the Serial Monitor to view the IP address and classification results. Access the IP via a web browser to see the camera feed.