This project implements pet tracking using an OpenCV2-based algorithm combined with a YOLO model. The application is designed to analyze video frames and track pets dynamically.
- Conda version: 3
- Python version: 3.10
- OpenCV version: 4.5.5
- Create a Conda environment:
conda env create -f enviroment.yml -n net_tracking
- Export your own environment:
conda env export > environment.yml
- Clone the YOLO model and set up the classification ID file:
The main script for running the pet tracking project is tracker_test.exe. This is a compiled executable built with PyInstaller for ease of use.
.\dist\tracker_test.exe <video_path> <model_class_id> <model_confidence> -d <debug_mode> -s <strategy> --minInterval <min_time> --maxInterval <max_time> --strategyInterval <strategy_time> --resize <width> <height>.\dist\tracker_test.exe D:\video.mp4 15 0.1 -d True -s WHEN_LOST --minInterval 500 --maxInterval 0 --strategyInterval 0 --resize 1920 1080| Parameter | Description | Example |
|---|---|---|
<video_path> |
Path to the input video file. | D:\video.mp4 |
<model_class_id> |
The class id of the model match | 15 |
<model_confidence> |
Minimum confidence of the model | 0.1 |
-d <debug_mode> |
Debug mode (True/False). | True |
-s <strategy> |
Tracking strategy (e.g., WHEN_LOST, WHEN_FREE, etc.). |
WHEN_LOST |
--minInterval |
Minimum time interval (in milliseconds). | 500 |
--maxInterval |
Maximum time interval (in milliseconds). | 0 |
--strategyInterval |
Interval for applying strategy (in milliseconds). | 0 |
--resize |
Scale the video to the target size. | 1920 1080 |
Use the .\dist\tracker_test.exe --help command to know more |
The YOLO model is used for pet detection and classification. The classification IDs are defined in the file:
You can find YOLO models at the following web sites:
Ensure that this file is downloaded and correctly referenced in your project.
This project uses pyInstaller for packaging, the following is the packaging command
pyinstaller --onefile --add-binary "~\env\conda\envs\my_project_env\Library\bin\*.dll;." .\tests\csrt\tracker_test.pypyinstaller --onefile --add-binary "~/env/conda/envs/my_project_env/lib/*.so;." .\tests\csrt\tracker_test.py- Environment Compatibility: This project is designed for Python 3.10 and OpenCV 4.5.5. Ensure your environment matches these versions.
- Debug Mode: If you encounter unexpected behavior, enable debug mode (
-d True) to log additional details, This outputs the processed video stream. - Model Dependencies: Make sure all YOLO dependencies and weights are properly downloaded and configured.
- Performance: Adjust parameters like
max_distanceandiou_thresholdto optimize tracking performance for your specific video input.
This project is licensed under the MIT License - see the LICENSE file for details.
For additional information or issues, feel free to contact us or raise an issue in the project repository.