How jnr-10/stereovision_depthestimation-objectdetection works
1. Overall shape
- This is an inference/demo repository for stereo depth estimation, not a single model project.
- The architecture is centered on a model selector + demo pipeline that can run multiple stereo disparity networks and then convert disparity into depth/point-cloud outputs.
2. Main entry point
- demo.py is the top-level orchestrator.
- It reads runtime settings from config.py, loads the selected stereo model, processes KITTI left/right images, and drives visualization/output generation.
3. Configuration boundary
- config.py is the main control plane for the whole repo.
- It holds:
- KITTI image and calibration paths
- pretrained checkpoint paths
- device selection (cuda vs CPU)
- feature flags for disparity display, 3D projection, and point-cloud export
- the active architecture choice from the supported model list
- This means the repo’s behavior is mostly changed by configuration rather than code changes.
4. Disparity estimation subsystem
- disparity_estimator/ acts as the adapter layer between the demo and the individual model implementations.
- Each file there is a wrapper for one supported architecture:
- RAFT-Stereo
- FastACVNet
- BGNet
- GwcNet
- PAM/PSMNet family
- CREStereo
- HITNet
- This layer likely normalizes different model APIs into a common “estimate disparity for a stereo pair” interface.
5. Model zoo organization
- networks/ contains the actual upstream model implementations, separated by architecture.
- Each subdirectory is largely self-contained and mirrors the internal structure of that model family:
- models/, core/, or nets/
- attention/correlation/update/extractor modules where relevant
- model-specific utilities, losses, metrics, and preprocessing
- Architecturally, this is a vendorized model library rather than a shared framework.
6. Primary data flow
- The core runtime flow is:
- read stereo image pair
- run chosen disparity network
- produce disparity map
- use calibration files to convert disparity into depth
- optionally overlay object detection results and/or generate 3D point cloud
- The README explicitly notes that depth estimation depends on the stereo disparity map.
7. Object detection integration
- object_detector.py is a separate subsystem that likely loads YOLO weights for 2D object detection.
- In the demo, detection is combined with depth estimation so bounding boxes can be annotated with distance information.
- This is a parallel consumer of the input frames, not part of the stereo network itself.
8. 3D output / visualization
- The repo supports two notable outputs:
- a disparity visualization video
- a point-cloud / 3D projection output
- assets/demo_output.mp4 and assets/point_cloud.mp4 show the intended output style.
- The 3D projection depends on the KITTI calibration files and the computed depth values.
9. Model-specific implementation boundaries
- Each architecture package contains its own internal dependencies:
- RAFT-Stereo: correlation, extractor, update, dataset utilities
- CREStereo: attention, transformer, corr, update
- HITNet: tile warping/update and feature extraction
- BGNet / FastACVNet / PSMNet / GwcNet / PASMNet: custom submodules and losses
- These packages are not meant to be mixed; the estimator wrapper is the boundary that isolates them.
10. Runtime and dependencies
- The project is Python-based and appears to run on PyTorch with GPU support as the intended path.
- environment.yml, requirements.txt, and the setup scripts indicate a reproducible local environment workflow.
- This is important architecturally because model selection and inference speed are tied to CUDA-enabled execution.
11. External assets and checkpoints
- The repo does not bundle model weights; pretrained checkpoints must be downloaded separately and referenced from config.py.
- It also depends on a downloadable YOLO object detector and the KITTI stereo dataset plus calibration files.
- So the repo is a thin runtime over external assets rather than a self-contained training package.
12. Utility and packaging layer
- utils.py and the model-specific utils/ folders provide supporting functions such as preprocessing, metrics, visualization, file I/O, and persistence.
- scripts/ contains environment/bootstrap helpers and a demo test script, which suggests the expected workflow is: prepare environment, download weights, set config, run demo.
13. What an architecture diagram should show
- A good diagram would show:
- Input layer: KITTI stereo images + calibration
- Control layer: config.py selecting one of several disparity engines
- Inference layer: disparity_estimator/ dispatching into one of the networks/* model stacks
- Post-processing layer: disparity-to-depth conversion, object detection, 3D projection/point cloud generation
- Outputs: disparity video, annotated demo video, point cloud visualization
- The key architectural idea is a single demo pipeline fronting a pluggable multi-model stereo backend.
Main entry points: demo.py Demo runner · config.py Config · raftstereo_disparity_estimator.py RAFT-Stereo adapter · fastacv_disparity_estimator.py FastACV adapter
Components 20
Control
Runtime configuration and orchestration
- Demo runner · Top-level pipeline that loads inputs, selects a model, and drives inference/output generation
demo.py - Config · Central control plane for paths, device choice, model selection, and feature flags
config.py
Disparity adapters
Thin wrappers that normalize model-specific stereo inference
- RAFT-Stereo adapter · Adapter entry for the RAFT-Stereo backend
disparity_estimator/raftstereo_disparity_estimator.py - FastACV adapter · Adapter entry for the FastACVNet backend
disparity_estimator/fastacv_disparity_estimator.py - BGNet adapter · Adapter entry for the BGNet backend
disparity_estimator/bgnet_disparity_estimator.py - GwcNet adapter · Adapter entry for the GwcNet backend
disparity_estimator/gwcnet_disparity_estimator.py - PSM/PASM adapter · Adapter entry for the PSMNet and PASMNet backends
disparity_estimator/psmnet_disparity_estimator.py - PASM adapter · Adapter entry for the PASMNet backend
disparity_estimator/pasmnet_disparity_estimator.py - CREStereo adapter · Adapter entry for the CREStereo backend
disparity_estimator/crestereo_disparity_estimator.py - HITNet adapter · Adapter entry for the HITNet backend
disparity_estimator/hitnet_disparity_estimator.py
Model zoo
Vendorized stereo network implementations
- RAFT core · Correlation, feature extraction, and iterative update core for RAFT-Stereo
networks/RAFTStereo/core/raft_stereo.py - FastACVNet · Fast ACVNet model stack for disparity prediction
networks/FastACVNet/models/Fast_ACV.py - BGNet · BGNet model family with feature extraction and 2D/3D submodules
networks/BGNet/models/bgnet.py - GwcNet · Group-wise correlation stereo network
networks/GwcNet/models/gwcnet.py - PSMNet · PSMNet stack-hourglass stereo model
networks/PSMNet/models/stackhourglass.py - PASMNet · PASMNet model implementation and modules
networks/PASMNet/models/PASMnet.py - CREStereo · CREStereo network with attention, correlation, and update blocks
networks/CREStereo/nets/crestereo.py - HITNet · HITNet stereo network with tile warping and tile updates
networks/HitNet/models/HITNet.py
Post-processing
Detection, depth conversion, and visualization outputs
- Object detector · Separate 2D detection subsystem used to annotate frames with distance-aware boxes
object_detector.py - Shared utils · Cross-cutting helpers for preprocessing, I/O, and visualization support
utils.py
Connections 21
- Config → Demo runner: runtime settings · Demo reads model choice, paths, device, and output flags from configuration
- Demo runner → RAFT-Stereo adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → FastACV adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → BGNet adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → GwcNet adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → PSM/PASM adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → PASM adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → CREStereo adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → HITNet adapter: selects · Demo dispatches to the chosen disparity adapter
- Demo runner → Object detector: runs · Object detection is applied alongside stereo inference for annotated demo output
- Demo runner → Shared utils: uses · Shared helpers support I/O, preprocessing, and visualization
- RAFT-Stereo adapter → RAFT core: adapts · Wrapper normalizes the RAFT-Stereo backend into the demo interface
- FastACV adapter → FastACVNet: adapts · Wrapper normalizes the FastACVNet backend into the demo interface
- BGNet adapter → BGNet: adapts · Wrapper normalizes the BGNet backend into the demo interface
- GwcNet adapter → GwcNet: adapts · Wrapper normalizes the GwcNet backend into the demo interface
- PSM/PASM adapter → PSMNet: adapts · Wrapper normalizes the PSMNet backend into the demo interface
- PASM adapter → PASMNet: adapts · Wrapper normalizes the PASMNet backend into the demo interface
- CREStereo adapter → CREStereo: adapts · Wrapper normalizes the CREStereo backend into the demo interface
- HITNet adapter → HITNet: adapts · Wrapper normalizes the HITNet backend into the demo interface
- Demo runner → Config: controls · Selected architecture and feature flags determine the runtime path
- Demo runner → Shared utils: outputs · Shared utilities help produce disparity video, depth overlay, and point-cloud artifacts