The result is obtained using the Brute-Force matcher in OpenCV. It can be seen that there are a few wrong matches obtained. These can
affect the results. To filter these wrong feature pairs, we will use RANSAC in the next step.
The fundamental matrix is calculated using the 8-point algorithm. If the F matrix estimation is good, then terms
x T 2 .F.x 1 should be close to 0, where x 1 and x 2 are features from image1 and image2. Using this criterion, RANSAC can
be used to filter the outliers.
Since we know the camera calibration matrix, we can use it to obtain the essential matrix.
camera pose(R and C) can be estimated using the essential matrix E. We will be estimating the pose for camera 2 with respect to camera 1 which is assumed to be of world origin. We will get four solutions for which we will use the Chirality condition to choose the correct set.
Using the fundamental matrix and the feature points, we can obtain the epipolar lines for both images. The
epipolar lines need to be parallel for further computations to obtain depth. This can be done by reprojecting image planes
onto a common plane parallel to the line between camera centers.
For every pixel in image 1, we try to find a corresponding match along the epipolar line in image 2. We will consider a a window of a predefined size for this purpose, so this method is called block matching. Essentially, we will be taking a small region of pixels in the left image, and searching for the closest matching region of pixels in the right. Following methods can be used for block comparison:
- Sum of Absolute Differences (SAD)
- Sum of Squared Differences (SSD)
- Normalized Cross-Correlation (NCC)
After we get the matching pixel location, the disparity can be found by take the absolute of the difference between the source and matched pixel location
If we know the focal length(f) and basline(b), the depth can be calculated.
- Change the location to the root directory
- Run the following command:
python3 Code/stereo.py --DataPath ./Data/Project\ 3/Dataset\ 3 --DataNumber 3
- DataPath: Absolute path where the images are located. Be careful about the spaces.
- DataNumber: The dataset number. used to choose the intrinsic parameters.