A collection of Python scripts for detecting cats using a webcam, with varying levels of complexity and features.
This project provides implementations of a cat detection system that:
- Uses your webcam to detect cats
- Plays a sound when a cat is detected
- Saves photos of detected cats
- Provides visual feedback with bounding boxes around detected cats
The project includes the following implementations:
basic_cat_detector.py- Simple implementation using Haar Cascade classifier
safe_cat_detector.py- Implementation with additional safety featuresadvanced_cat_detector.py- Most sophisticated implementation using YOLOv3-tiny for better detection
download_model.py- Downloads required model filesdownload_yolo.py- Downloads YOLOv3-tiny model filesbuild_windows.py- Script for building Windows executable
- Clone this repository
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
- Windows:
- Install dependencies:
pip install -r requirements.txt - Download required models:
For advanced detection:
python scripts/utils/download_model.pypython scripts/utils/download_yolo.py
The easiest way to run any version of the cat detector is to use the main.py script:
python main.py --version [VERSION]
Where [VERSION] can be one of:
basic- Basic implementationsafe- Safe implementationadvanced- Advanced implementation (default)
Example:
python main.py --version basic
Or simply run the advanced version (default):
python main.py
You can also run any script directly:
python scripts/basic_cat_detector.py
python scripts/advanced/safe_cat_detector.py
python scripts/advanced/advanced_cat_detector.py
You can run the batch file:
run_cat_detector.bat
Or build your own executable:
python scripts/utils/build_windows.py
cat-detector/
├── scripts/
│ ├── advanced/
│ │ ├── safe_cat_detector.py
│ │ └── advanced_cat_detector.py
│ ├── utils/
│ │ ├── download_model.py
│ │ ├── download_yolo.py
│ │ └── build_windows.py
│ └── basic_cat_detector.py
├── resources/
│ ├── haarcascade_frontalcatface.xml
│ ├── pug-woof-2-103762.mp3
│ └── models/
│ ├── coco.names
│ ├── yolov3-tiny.cfg
│ ├── yolov3-tiny.weights
│ ├── yolov3.cfg
│ └── yolov3.weights
├── detected_cats/
├── main.py
├── requirements.txt
├── run_cat_detector.bat
└── README.md
- Python 3.6+
- OpenCV
- NumPy
See requirements.txt for complete list.
MIT
- OpenCV for computer vision capabilities
- YOLOv3-tiny model for advanced detection
- Haar Cascade classifiers for basic detection