A computer vision application for detecting available parking slots using YOLOv8 and ROI (Region of Interest) analysis.
- Car Detection: Uses YOLOv8 model to detect vehicles in video streams
- ROI Management: Define regions of interest for parking areas
- Multiple Input Sources: Support for video files and RealSense cameras
- CLI Interface: Easy-to-use command-line interface
-
Clone the repository:
git clone <repository-url> cd car_parking_slot
-
Install dependencies (using uv):
uv sync
Or using pip:
pip install -r requirements.txt
The application provides two main commands: set-roi
for configuring regions of interest and detect
for running car detection.
Before running detection, you need to define the parking areas (ROI) in your video source.
python main.py set-roi --source <video_source> --output <roi_file>
Parameters:
--source
: Path to video file or 'realsense' for RealSense camera--output
: Output file to save ROI configuration (default:roi.json
)
Examples:
# Set ROI from a video file
uv run main.py set-roi --source resources/parking_lot.mp4 --output my_roi.json
# Set ROI from RealSense camera
uv run main.py set-roi --source realsense --output camera_roi.json
ROI Setup Process:
- The video will open in a window
- Click and drag to draw rectangles around parking areas
- Press 'q' to quit and save the ROI configuration
- The ROI data will be saved to the specified output file
Once you have configured the ROI, you can run car detection:
uv run main.py detect --source <video_source> --roi-config <roi_file>
Parameters:
--source
: Path to video file or 'realsense' for RealSense camera--roi-config
: ROI configuration file (default:roi.json
)
Examples:
# Run detection with default ROI file
uv run main.py detect --source resources/parking_lot.mp4
# Run detection with custom ROI file
uv run main.py detect --source resources/parking_lot.mp4 --roi-config my_roi.json
# Run detection with RealSense camera
uv run main.py detect --source realsense --roi-config camera_roi.json
- Python 3.8+
- OpenCV
- YOLOv8
- Typer (for CLI)
- RealSense SDK (optional, for RealSense camera support)