Skip to content

Optimized (very fast) stereo matching algorithms in Python. It includes implementations of Block Matching, Dynamic Programming, Semi-Global Matching, Semi-Global Block Matching and Belief Propagation.

License

Notifications You must be signed in to change notification settings

bollasap/stereo-matching-algorithms-python

Repository files navigation

Stereo Matching Algorithms in Python

Optimized (very fast) stereo matching algorithms in Python. It includes implementations of Block Matching, Dynamic Programming, Semi-Global Matching, Semi-Global Block Matching and Belief Propagation.

This project is a Python port of Stereo Matching Algorithms in MATLAB.

Features

Multiple stereo vision algorithms

  • Block Matching (BM)
  • Dynamic Programming (DP)
  • Semi-Global Matching (SGM)
  • Semi-Global Block Matching (SGBM)
  • Belief Propagation (BP)

Two different versions of Dynamic Programming

  • Dynamic Programming with Left–Right Axes DSI
  • Dynamic Programming with Left–Disparity Axes DSI

Three different versions of Belief Propagation

  • Belief Propagation with accelerated message update schedule
  • Belief Propagation with synchronous message update schedule
  • Belief Propagation with synchronous message update schedule (alternative approach)

All algorithms are accelerated for performance using NumPy.

Installation

Download the project as ZIP file, unzip it, and run the scripts.

Requirements

  • NumPy
  • Matplotlib
  • OpenCV (opencv-python)

Usage

The project contains eight Python scripts, each implementing a different stereo matching algorithm. The files left.png and right.png contain the stereo image pair used as input. To use a different stereo pair, replace these two images with your own. In this case, you must also adjust the disparity levels parameter in the script you are running. You may optionally modify other parameters as needed. If the input images contain little or no noise, it is recommended not to use the Gaussian filter.

Results

Below are the disparity maps produced by the different algorithms when using the Tsukuba stereo pair.

Tsukuba Stereo Image Tsukuba Stereo Image

Block Matching

Block Matching Disparity Map

Dynamic Programming (Left-Right)

Dynamic Programming (Left-Right) Disparity Map

Dynamic Programming (Left-Disparity)

Dynamic Programming (Left-Disparity) Disparity Map

Semi-Global Matching

Semi-Global Matching Disparity Map

Semi-Global Block Matching

Semi-Global Block Matching Disparity Map

Belief Propagation (Accelerated)

Belief Propagation Accelerated Disparity Map

Belief Propagation (Synchronous)

Belief Propagation Synchronous Disparity Map

The two different approaches to Belief Propagation produce the same result.

Related Repositories

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Optimized (very fast) stereo matching algorithms in Python. It includes implementations of Block Matching, Dynamic Programming, Semi-Global Matching, Semi-Global Block Matching and Belief Propagation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages