Minimal stereo pipeline to estimate object distances from rectified stereo pairs. It supports classical stereo (SGBM) or deep stereo (CREStereo ONNX), then runs YOLO detection or segmentation and reports per-object distance.
run_stereo_depth_od.py— main entry pointutils/— helper functions and CREStereo ONNX wrapper
- Python 3.10
- NumPy
- OpenCV (
opencv-python) - Matplotlib
- Ultralytics YOLO (
ultralytics) - Open3D
- ONNXRuntime (
onnxruntime) only if using--stereo deep
Conda:
conda env create -f environment.yml
conda activate merged_3dcv_crestereoPip:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtFrom this folder:
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seqUse deep stereo (CREStereo):
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seq \
--stereo deep \
--crestereo_model /path/to/crestereo_model.onnxRun segmentation mode:
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seq \
--detector seg \
--seg_weights /path/to/yolo11n-seg.ptSave depth maps and visualizations:
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seq \
--save_depth --save_visualsThe --data_root should contain the KITTI RAW rectified structure:
<seq> /
image_02/data/*.png
image_03/data/*.png
calib/calib_cam_to_cam.txt
label_2_from_tracklets/*.txt (optional, for MAE)
All outputs go to --out_dir (default: output_pipeline under data_root).
summary.csv— per-frame stats and optional MAE vs labelsdepth_map_*.npy— depth maps (if--save_depth)depth_vis_*.png— colored depth images (if--save_visuals)result_with_depth_*.pngorresult_with_depth_mask_*.png(if--save_visuals)
- Default detector weights expect
yolo11n.ptin this folder, or pass--det_weights. - Segmentation uses
yolo11n-seg.ptif provided via--seg_weights. - If the CREStereo model output shape differs, update
utils/crestereo_onnx.py.
Classical stereo, single frame:
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seq \
--index 13SGBM tuning (example):
python3 run_stereo_depth_od.py \
--data_root /path/to/KITTI_RAW_seq \
--sgbm_params "numDisparities=160,blockSize=7,uniquenessRatio=5"