This project implements a robust and efficient system for real-time stop sign detection and distance estimation using a combination of deep learning (YOLO) and classical stereo vision techniques.
Developed with affordability and high performance in mind, this solution is ideal for applications in autonomous driving, advanced driver-assistance systems (ADAS), and robotics — where accurate environmental perception is critical.
Unlike traditional object detection systems that only identify objects, this project leverages stereoscopic triangulation to provide precise depth information, giving vehicles or robots a crucial understanding of their surroundings in 3D space.
-
Hybrid Approach for Enhanced Perception
Combines YOLO for real-time object detection with Stereo Vision for precise distance estimation. -
High Detection Accuracy
The YOLO model achieves over 80% accuracy in detecting stop signs, even in complex scenes. -
Accurate Distance Estimation
Uses theStereo SGBM (Semi-Global Block Matching)algorithm to compute disparity maps and apply the triangulation formula:
Z = (f × B) / d -
Cost-Effective Alternative
Requires only stereo cameras — making it significantly cheaper than LIDAR or RADAR. -
Rich Visual Data
Unlike LIDAR or RADAR, stereo cameras offer full-color and texture-rich images, enabling deeper scene understanding. -
Real-Time Performance
Efficient YOLO inference + optimized stereo algorithms enable fast processing. -
Modular and Maintainable Codebase
Built around theStereoYOLOProcessorclass for clarity, modularity, and ease of future updates.
- YOLO (You Only Look Once) – Fast and accurate object detection for bounding boxes and labels.
- Stereo SGBM (Semi-Global Block Matching) – Computes pixel-wise disparity between stereo pairs.
- Triangulation Formula – Converts disparity to distance:
Z = (focal_length × baseline) / disparity
- Stereo Image Capture – Left and right frames are captured from a calibrated stereo camera pair.
- Image Rectification – Aligns images along epipolar lines to prepare for matching.
- Stop Sign Detection (YOLO) – YOLO processes one image (typically left) to detect and localize stop signs.
- Disparity Map Generation (SGBM) – Disparity computed from stereo image pair using SGBM.
- Distance Estimation – The average disparity inside the bounding box is used to calculate the distance.
STOP_SIGN_PYTHON/
├── .pycache__/
├── .venv/ # Python virtual environment
├── extracted_tesla_frames/ # Processed or raw frame data
├── STOP_LEFT_frames/ # Left image frames
├── STOP_RIGHT_frames/ # Right image frames
├── scene0/
├── scene1/
├── video/
│ ├── LEFT.mp4
│ └── RIGHT.mp4
├── config.txt # Configuration (model paths, thresholds, etc.)
├── detection.py # Main processing script (detection + depth)
├── last.pt # YOLO model weights
├── packages.py # Custom modules
├── README.md # This file
└── video.py # Video capture/processing
.gitattributes
.gitignore
Note: The main class
StereoYOLOProcessoris likely defined indetection.py.
Make sure the following are installed:
- Python 3.8+
- Git
git clone https://github.com/HodayaMoyal/Streo_Stop_Sign.git
cd STOP_SIGN_PYTHONpython -m venv .venvWindows:
.\.venv\Scripts\activatemacOS/Linux:
source ./.venv/bin/activateIf you have a requirements.txt:
pip install -r requirements.txtOtherwise, install manually:
pip install opencv-python numpy ultralytics configparserEnsure the following:
last.pt(YOLO weights) is in the project root.camera_calibration.ymlis available (with intrinsic/extrinsic params).
If not calibrated yet — see the Calibration section.
Update settings such as:
model_path=last.pt
confidence_threshold=0.5
calibration_file=camera_calibration.yml
num_disparities=64
block_size=11
Run the main script:
python detection.pyThe script will output detected stop signs, bounding boxes, and estimated distances. You can optionally modify it to save output frames.
Stereo calibration is essential. Use OpenCV’s calibration tools or a dedicated script (e.g., calibrate.py) to generate camera_calibration.yml.
We welcome contributions!
# Fork and clone
git checkout -b feature/my-feature
# Make your changes
git commit -m "Add new feature"
git push origin feature/my-feature
# Open a Pull RequestThis project is licensed under the MIT License — see the LICENSE file for details.