OpenStereo

repository·v2·Indexed 21 days ago

https://github.com/xiandaguo/openstereo

A comprehensive and extensible benchmark and framework for stereo matching. It supports a wide variety of state-of-the-art models and datasets, including Argoverse, CREStereo, Driving Stereo, DynamicReplica, ETH3D, Falling Things, FoundationStereo, InStereo2K, KITTI 2012/2015, Middlebury, and SceneFlow, providing optimized training and testing pipelines.

Tokens
15.5K
Snippets
43
Records
56
Agent score
75%

What's inside OpenStereo

  1. Browse the Stereo Matching Paper List

    v2
    The Stereo_Matching_Paper_List.md file serves as a curated bibliography of research papers related to stereo matching, organized by year (2026, 2025, 2024, 2023) and publication type (Conference or Journal). Each entry typically provides the paper title, authors, links to the full paper (e.g., arXiv, IEEE, AAAI), and links to the official code repositories where available. This is a useful resource for developers looking for state-of-the-art (SOTA) models, zero-shot stereo matching techniques, or foundation models for depth estimation.
  2. Dataset Usage Rules for StereoCarla

    v2

    The StereoCarla dataset and its subsets are subject to the following restrictions:

    • Academic Use Only: The dataset is strictly for academic research.
    • No Commercial Use: Commercial use of the dataset or its subsets is prohibited.
    • No Distribution: You may not forward, publish, or distribute the dataset or its subsets to any organization or individual without explicit permission.
    • Requests: All requests for copies or sharing must be directed to the official contact email.

    If the dataset is used in your research, please cite the following paper:

    @article{guo2025stereocarla,
          title={StereoCarla: A High-Fidelity Driving Dataset for Generalizable Stereo}, 
          author={Xianda Guo and Chenming Zhang and Ruilin Wang and Youmin Zhang and Wenzhao Zheng and Matteo Poggi and Hao Zhao and Qin Zou and Long Chen},
          year={2025},
          journal={arXiv preprint arXiv:2509.12683}
    }
  3. Core features of OpenStereo

    v2

    OpenStereo includes several high-performance features for stereo matching research and deployment:

    • DDP Support: Uses PyTorch Distributed Data Parallel (DDP) for both training and testing phases.
    • AMP Support: Supports Auto Mixed Precision (AMP) for optimized training.
    • TensorRT Support: Integrated for high-performance deployment.
    • Logging: Uses tensorboard and standard logging for comprehensive experiment tracking.
  4. Register and configure a new model

    v2

    To make your new model available to the OpenStereo pipeline, follow these three steps:

    1. File Placement: Place your newmodel.py and trainer.py files inside the openstereo/modeling/models directory.
    2. Registration: Import your model in openstereo/modeling/__init__.py. The name of the class you import is the identifier used in your configuration files.
    3. Configuration: Specify the model in your YAML configuration file under the MODEL key using the NAME field.

    Example YAML configuration:

    MODEL:
      NAME: NewModel
      param1: ...
      param2: ...
    MODEL:
      NAME: newmodel
      param1: ...
      param2: ...
      param3: ...
  5. Evaluate a trained model

    v2

    Use tools/eval.py to evaluate a model on specific datasets or for generalization testing.

    Arguments:

    • --cfg_file: The path to the model configuration file.
    • --eval_data_cfg_file: The dataset configuration file for evaluation (e.g., cfgs/eth3d_eval.yaml).
    • --pretrained_model: Path to your pre-trained checkpoint.

    Tip: Most arguments used in the training phase are also available during evaluation.

    # Standard evaluation
    python tools/eval.py --cfg_file cfgs/lightstereo/lightstereo_s_sceneflow.yaml --eval_data_cfg_file cfgs/sceneflow_eval.yaml --pretrained_model your_pretrained_ckpt_path
    
    # Generalization evaluation (e.g., ETH3D)
    python tools/eval.py --cfg_file cfgs/lightstereo/lightstereo_s_sceneflow.yaml --eval_data_cfg_file cfgs/eth3d_eval.yaml --pretrained_model your_pretrained_ckpt_path
  6. Define your own trainer by inheriting from TrainerTemplate

    v2

    To implement custom training logic, you must create a class that inherits from openstereo.stereo.modeling.trainer_template.TrainerTemplate. You can then override specific methods or define new ones required for your training workflow.

    Once defined, you must 'mount' your custom trainer to your model. This is typically done within the trainer's __init__ method by instantiating the model using the configuration and passing it to the super().__init__ call.

    from stereo.modeling.trainer_template import TrainerTemplate
    from .psmnet import PSMNet
    
    __all__ = {
        'PSMNet': PSMNet,
    }
    
    class Trainer(TrainerTemplate):
        def __init__(self, args, cfgs, local_rank, global_rank, logger, tb_writer):
            # Instantiate the model using the name provided in the config
            model = __all__[cfgs.MODEL.NAME](cfgs.MODEL)
            # Pass the model to the base TrainerTemplate
            super().__init__(args, cfgs, local_rank, global_rank, logger, tb_writer, model)
  7. Download and structure the StereoCarla dataset

    v2

    StereoCarla is a synthetic stereo dataset for autonomous driving built on the CARLA simulator. It includes various camera configurations (baselines, viewpoints, sensor placements) and environmental conditions (lighting, weather, road geometry).

    1. Download: Obtain the dataset from https://xiandaguo.net/StereoCarla/.
    2. Directory Structure: Ensure your dataset follows this specific hierarchy to be compatible with the project:
    StereoCarla
    └───normal
         └───town01
              ├───left
              ├───baseline_010
              │    ├───rgb
              │    ├───depth
              │    └───pose
              └───town10
         ├───pitch00
         ├───pitch30
         ├───roll05
         ├───roll15
         ├───roll30
         └───weather

    Note: You can optionally provide your own .txt file to specify which parts of the dataset to use.

    StereoCarla
    └───normal
        └───town01
             └───left
             └───baseline_010
                 └───rgb
                 └───depth
                 └───pose
         └───town10
    └───pitch00
    └───pitch30
    └───roll05
    └───roll15
    └───roll30
    └───weather
  8. Set up and build the C++ deployment example

    v2

    The C++ deployment example requires specific system dependencies and NVIDIA libraries.

    1. Install System Dependencies

    apt-get update
    apt-get install libyaml-cpp-dev libopencv-dev python3-opencv

    2. Prerequisites

    Ensure you have installed:

    3. Build Process

    Navigate to deploy/cpp and create a build directory. You can build using the system's TensorRT or a specific TensorRT installation from a tar package.

    Build with system TensorRT:

    cmake .. && make

    Build with a specific TensorRT path:

    cmake -DTENSORRT_ROOT=<path_to_tensorrt> .. && make

    Build with specific TensorRT path and CUDA architecture:

    cmake -DTENSORRT_ROOT=<path_to_tensorrt> -DCMAKE_CUDA_ARCHITECTURES=<your_cuda_architecture> .. && make

    4. Running Inference

    Once built, run the ./main executable with the following arguments: ./main <cfg_path> <engine_path> <left_image_path> <right_image_path> <options>

    Note: If using a TensorRT tar package, ensure LD_LIBRARY_PATH is correctly set. You can verify the links using ldd main | grep libnv*.

    cd deploy/cpp
    mkdir build && cd build
    cmake -DTENSORRT_ROOT=/path/to/tensorrt -DCMAKE_CUDA_ARCHITECTURES=86 .. && make
    ./main config.yaml model.engine left.png right.png
  9. Download and structure the DynamicReplica dataset

    v2

    DynamicReplica is a dataset containing 145,200 stereo frames (524 videos) featuring humans and animals in motion.

    1. Download: Obtain the dataset from the official source: https://github.com/facebookresearch/dynamic_stereo.
    2. Directory Structure: Ensure your local files follow this specific hierarchy to be compatible with the project:
    DynamicReplica
    └───disparity
    |   └───train
    |   └───valid
    └───real
    └───test
    └───train
    └───valid
  10. Prepare the KITTI 2012 dataset

    v2

    To use the KITTI 2012 dataset with OpenStereo, you must manually download the data from the official KITTI website and organize it within the project's datasets/kitti12 directory. The project expects a specific subdirectory structure containing calibration files, colored images, disparity maps, and flow data.

    data
    |   kitti12
    |   |   ├── calib
    |   |   |   ├── calib
    |   |   |   ├── colored_0
    |   |   |   ├── colored_1
    |   |   |   ├── disp_noc
    |   |   |   ├── disp_occ
    |   |   |   ├── disp_refl_noc
    |   |   |   ├── disp_refl_occ
    |   |   |   ├── flow_noc
    |   |   |   ├── flow_occ
    |   |   |   ├── image_0
    |   |   |   ├── image_1
    ...
    |   |   ├── testing
    |   |   |   ├── calib
    |   |   |   ├── colored_0
    |   |   |   ├── colored_1
    |   |   |   ├── image_0
    |   |   |   ├── image_1
    ...
  11. Prepare the VirtualKitti2 Dataset

    v2

    To use the VirtualKitti2 dataset with this project, download the dataset from the official source and organize it into a specific directory structure. The dataset contains 21,260 image pairs with high-accuracy disparity maps.

    Download Link: https://europe.naverlabs.com/research/computer-vision/proxy-virtual-worlds-vkitti-2

    Required Directory Structure: Ensure the root folder (e.g., virtualkitti2) contains the scene subdirectories directly:

    virtualkitti2
    ├── Scene01
    ├── Scene02
    ├── Scene06
    ├── Scene18
    ├── Scene20

    Note: You can optionally provide a custom .txt file to specify which parts of the dataset to use.

  12. Implement a new model class

    v2

    To design a new stereo model, create a class that inherits from nn.Module. You must implement at least the forward() and get_loss() methods:

    1. forward(self, input_data): Receives a dictionary input_data containing 'left' and 'right' images. It must return a dictionary containing the prediction, typically with the key 'disp_pred'.
    2. get_loss(self, model_preds, input_data): Receives model_preds (the dictionary returned by forward) and input_data. Use input_data['disp'] to access the ground truth disparity for loss calculation.
    class NewModel(nn.Module):
        def __init__(self, *args, **kwargs):
            super().__init__()
    
        def forward(self, input_data):
            left_img = input_data['left']
            right_img = input_data['right']
            
            # ... model logic ...
            
            return {'disp_pred': disp_pred}
        
        def get_loss(self, model_preds, input_data):
            disp_gt = input_data["disp"] 
            disp_pred = model_preds['disp_pred']
            # ... loss calculation ...