Skip to content

Files

Latest commit

 Cannot retrieve latest commit at this time.

History

History
283 lines (252 loc) · 13.8 KB

manual.md

File metadata and controls

283 lines (252 loc) · 13.8 KB

Manual

Command Line Arguments

Option Type Description Default
-H, --help Show help message and exit
-C, --cam <camera> str, int Set to livestream URL for ESP32-CAM, 0 for primary camera, 1 for secondary camera 0
-T, --title <title> str Window title "Custom Object Detection"
-p, --path <path> str Detection model's path weights/custom_yolov8n.pt
-c, --conf <confidence> int Detection model's minimum confidence threshold 50
-d, --device <device> str Device running detection model Available device
-i, --iou <iou> int Lower values eliminate overlapping boxes 25
-m, --max <max-detections> int Limit number of detections per frame 100
-s, --strides <strides> int 1 processes every frame, higher values skip frames 1
-w, --width <width> int Camera width 256
-h, --height <height> int Camera height 256
-f, --fps <fps> float Camera frames per second 30.0
-n, --n-threads <threads> int Number of video processing threads 0
-b, --buffer bool True: All frames are buffered during video stream processing; False: Model should return most recent frame True

ESP32-CAM

Important

Current implementation requires WiFi!

  • This is because the ESP32-CAM livestreams to an MJPEG server over HTTP, which is how esp32.py gets the camera input
  • Unfortunately, WiFi connections from hotspots or SSOs are — in my experience — incompatible

Tip

If you're a visual learner, here's the YouTube tutorial + demo.

Steps starting with:

  • ▶ (i.e., Black Right-Pointing Triangle)
    • Show an accompanying image when clicked to help guide you through the process
    • Example: Step #8
  • ▼ (i.e., Black Down-Pointing Triangle)
    • Already have an image displayed that can be toggled off (i.e., hidden) when clicked
    • Example: Step #4

Important

Refer to ESP32CAM-RTSP's README.md (credit: rzeldent) for further information, troubleshooting tips, etc.

Initial Setup

1. Complete all installation steps

2. Click the PlatformIO icon in the activity bar, then click 'Pick a folder'
Open PlatformIO project
3. Open streaming
Open `streaming`
4. Connect the ESP32 to your computer with the Micro-USB cable, then select its board type and USB port at the bottom of the window
Select board and port
5. Click 'Build' to compile code, then click 'Upload' to flash code to ESP32
Build, Upload, Monitor
6. To connect initially to the device, connect to the WiFi network starting with ESP32CAM-RTSP
ESP32CAM-RTSP network
7. Click 'Change settings' once the browser automatically opens the home page (http://192.168.4.1)
Window popup
8. You MUST fill in (1) AP (i.e., Access Point) password, (2) WiFi SSID, and, if applicable, (3) WiFi password
System config

Important

Any time you're prompted for a password dialog (particularly upon clicking 'Change settings' after you've set it up):

  • Username: admin
  • Password: AP password from Step 8

Note

If you ever lose/forget the AP password, click 'Erase flash' (in PlatformIO's extension UI) to erase and reset the device, then follow Step 5 and onwards again.

9. Update the settings and configure camera options (you can always change them later), though be mindful of the settings you choose as they may affect the ESP32's performance
Camera Settings

10. Scroll down and click 'Apply' to save settings

11. Disconnect from the current network and reconnect to your WiFi in order to reset ESP32 and connect to the AP
Disconnect

Important

You must reset the ESP32 (i.e., press its 'Reset' button) everytime you change the settings for it to take effect.

Note

If there's an error screen saying it's unable to make a connection, try resetting the ESP32 first. It'll wait 30 seconds for a connection (can be changed in system configuration's 'Startup delay (seconds)' setting, shown in Step 8).

Connect to the SSID, go to the ESP32's IP address and enter your credentials:

  • Username: admin
  • Password: AP password from Step 8

12. Go back to PlatformIO extension, click 'Monitor', then use 'Find' keyboard shortcut to find the ESP32's IP address

  • PC
    Ctrl + F
  • Mac
    ⌘ + F

13. After invoking the shortcut, type 'IP address' in the find box, press 'Enter', and copy the resulting IP address [preceded by 'WiFi connected']
IP address
14. You can now stream from the ESP32
Home Page
  • HTTP Motion JPEG Streamer: http://<IP address from Step 13>/snapshot
  • HTTP Image: http://<IP address from Step 13>/snapshot
  • RTSP: rtsp://<IP address from Step 13>:554/mjpeg/1

Caution

Anyone with network access to the device can see the streams and images!

Note

Once the ESP32-CAM is setup successfully, you don't have to repeat these steps again; just plug in the ESP32-CAM and it's good to go! Stream URL remains the same as usual.

Usage

  1. Successfully setup the ESP32-CAM
  2. Activate algae_env (i.e., virtual environment)
    conda activate algae_env

Tip

Typing out entire Conda commands can sometimes be tedious, so I wrote a shell script (conda_shortcuts.sh on GitHub Gist) to define shortcuts for commonly used Conda commands.

Example: Delete/remove a conda environment named test_env
  • Shortcut command
    rmenv test_env
    
  • Manually typing out the entire command
    conda env remove -n test_env && rm -rf $(conda info --base)/envs/test_env

The shortcut has 80.8% fewer characters!

  1. Confirm algae_env is active
    • algae_env should be in parentheses () or brackets [] before your command prompt, e.g.
      (algae_env) $
    • See which virtual environments are available and/or currently active (active environment denoted with asterisk (*))
      conda info --envs
      OR
      conda env list
  2. Open esp32.py
  3. Assign HTTP (default) or RTSP ESP32 streaming link listed in Step 14 to URL
  4. Run esp32.py
    • POSIX
      python src/detection/esp32.py
    • Windows
      python src\detection\esp32.py
  5. Press the 'Escape' key on your keyboard to terminate

Train, Validate, and Test Model

  1. Visit one of these Google Colab notebooks, depending on the version of YOLO you want to use
  2. Follow the notebook's instructions step-by-step

Select Model

Note

All models are available at and can be downloaded from this repo's releases!

  1. Get path of the algae detection model you want to use
  2. Update camera.py's constructor parameter model (i.e., default model's path) accordingly