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 |
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.
1. Complete all installation steps
3. 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
7. Click 'Change settings' once the browser automatically opens the home page (http://192.168.4.1)
8. You MUST fill in (1) AP (i.e., Access Point) password, (2) WiFi SSID, and, if applicable, (3) WiFi password
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
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
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']
- 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.
- Successfully setup the ESP32-CAM
- 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!
- Confirm
algae_env
is activealgae_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
ORconda env list
- Open
esp32.py
- Assign HTTP (default) or RTSP ESP32 streaming link listed in Step 14 to
URL
- Run
esp32.py
- POSIX
python src/detection/esp32.py
- Windows
python src\detection\esp32.py
- POSIX
- Press the 'Escape' key on your keyboard to terminate
- Visit one of these Google Colab notebooks, depending on the version of YOLO you want to use
- Follow the notebook's instructions step-by-step
Note
All models are available at and can be downloaded from this repo's releases!
- Get path of the algae detection model you want to use
- Download weight(s), then add to
weights
- To use your own, create custom model then add to
weights
- Default weight is
custom_yolov8n.pt
- Download weight(s), then add to
- Update
camera.py
's constructor parametermodel
(i.e., default model's path) accordingly