Giter Site home page Giter Site logo

naitri / depth-estimation-stereo-images Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 2.0 64.97 MB

A python implementation of computing depth from stereo pair of images.

Python 100.00%
depth-estimation depth-map disparity-map fundamental-matrix pose-estimation ransac-algorithm stereo-vision triangulation

depth-estimation-stereo-images's Introduction

Depth-estimation-Stereo-Images

This repository implements how to compute depth from stereo images. This is being tested on three different datasets, each containing two images of the same sceanrio but different camera angles. The baseline of the stereo setup is given.

Original Undistorted

Run Instructions

python depth.py

Feature Matching

For feature matching, we first need to locate features. Here, SIFT (Scale Invariant Feature Transform) is used. This detector is scale and rotation invariant. The algorithm is stated below:

  1. Convert images into grayscale.
  2. Compute SIFT features for both the images.
  3. Use Brute Force matcher to match the features. It uses L2 NORM distance for the same.
  4. Sort the matches in ascending order of least distance and for this project purpose only 150 matches were used.
  5. Inbuilt function of cv2.BFmatcher.match gives list of ob- jects. All points were collected from this object.

Undistorted

Calculation of Fundamnetal Matrix using RANSAC

We use 8 point algorithm to estimate fundamental matrix. The algorithm is stated as follows:

  1. From the matches that are computed, 8 pairs are taken to estimate initial fundamental matrix.
  2. Before computing initial F matrix, we normalize image coordinates and compute is done using equations.

3)All of the pairs from both the images are tested against this fundamental matrix x ′ ∗ F ∗ x T and error was computed.

4)If the error is below some threshold value then that point pair will be inlier and corresponding Fundamental matrix will be considered as good.

  1. The above steps were repeated for 1000 iterations and outliers were discarded.

Estimation of Essential Matrix

If we have calibrated cameras, we can get essential matrix from which we can easily estimate pose.

Estimation of Camera Pose

The Essential matrix is composed of Rotation and Translation of camera. If we decompose Essential matrix using singular value decomposition then we get four camera pose configurations.

Stereo Rectification

To compute disparity, we need to have both the images in the same plane so that rotation does not come in to picture. To accomplish this, we will rectify the image pairs and also verify that they are coplanar by drawing epipolar lines. If epipolar lines are parallel then they are considered as coplanar. Inbuilt function of cv2.stereoRectifyUncalibrated() is used to get homography matrices of both the images.

Undistorted

## Correspondence The rectified images are available, and for each corresponding pixel on the epipolar line, we will search for the same in another image. Here, block matching algorithm is used where a fixed window is selected and slided over in the other image epipolar line and Sum of Sqaured Distances is computed.

Disparity

Undistorted

Depth

Undistorted

Undistorted

depth-estimation-stereo-images's People

Contributors

naitri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mandeepsingh396

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.