|
|
@ -5,14 +5,14 @@ Goal |
|
|
|
---- |
|
|
|
---- |
|
|
|
|
|
|
|
|
|
|
|
In this session, |
|
|
|
In this session, |
|
|
|
- We will learn to create depth map from stereo images. |
|
|
|
- We will learn to create a depth map from stereo images. |
|
|
|
|
|
|
|
|
|
|
|
Basics |
|
|
|
Basics |
|
|
|
------ |
|
|
|
------ |
|
|
|
|
|
|
|
|
|
|
|
In last session, we saw basic concepts like epipolar constraints and other related terms. We also |
|
|
|
In the last session, we saw basic concepts like epipolar constraints and other related terms. We also |
|
|
|
saw that if we have two images of same scene, we can get depth information from that in an intuitive |
|
|
|
saw that if we have two images of same scene, we can get depth information from that in an intuitive |
|
|
|
way. Below is an image and some simple mathematical formulas which proves that intuition. (Image |
|
|
|
way. Below is an image and some simple mathematical formulas which prove that intuition. (Image |
|
|
|
Courtesy : |
|
|
|
Courtesy : |
|
|
|
|
|
|
|
|
|
|
|
 |
|
|
|
 |
|
|
@ -24,7 +24,7 @@ following result: |
|
|
|
|
|
|
|
|
|
|
|
\f$x\f$ and \f$x'\f$ are the distance between points in image plane corresponding to the scene point 3D and |
|
|
|
\f$x\f$ and \f$x'\f$ are the distance between points in image plane corresponding to the scene point 3D and |
|
|
|
their camera center. \f$B\f$ is the distance between two cameras (which we know) and \f$f\f$ is the focal |
|
|
|
their camera center. \f$B\f$ is the distance between two cameras (which we know) and \f$f\f$ is the focal |
|
|
|
length of camera (already known). So in short, above equation says that the depth of a point in a |
|
|
|
length of camera (already known). So in short, the above equation says that the depth of a point in a |
|
|
|
scene is inversely proportional to the difference in distance of corresponding image points and |
|
|
|
scene is inversely proportional to the difference in distance of corresponding image points and |
|
|
|
their camera centers. So with this information, we can derive the depth of all pixels in an image. |
|
|
|
their camera centers. So with this information, we can derive the depth of all pixels in an image. |
|
|
|
|
|
|
|
|
|
|
@ -35,7 +35,7 @@ how we can do it with OpenCV. |
|
|
|
Code |
|
|
|
Code |
|
|
|
---- |
|
|
|
---- |
|
|
|
|
|
|
|
|
|
|
|
Below code snippet shows a simple procedure to create disparity map. |
|
|
|
Below code snippet shows a simple procedure to create a disparity map. |
|
|
|
@code{.py} |
|
|
|
@code{.py} |
|
|
|
import numpy as np |
|
|
|
import numpy as np |
|
|
|
import cv2 |
|
|
|
import cv2 |
|
|
@ -49,7 +49,7 @@ disparity = stereo.compute(imgL,imgR) |
|
|
|
plt.imshow(disparity,'gray') |
|
|
|
plt.imshow(disparity,'gray') |
|
|
|
plt.show() |
|
|
|
plt.show() |
|
|
|
@endcode |
|
|
|
@endcode |
|
|
|
Below image contains the original image (left) and its disparity map (right). As you can see, result |
|
|
|
Below image contains the original image (left) and its disparity map (right). As you can see, the result |
|
|
|
is contaminated with high degree of noise. By adjusting the values of numDisparities and blockSize, |
|
|
|
is contaminated with high degree of noise. By adjusting the values of numDisparities and blockSize, |
|
|
|
you can get a better result. |
|
|
|
you can get a better result. |
|
|
|
|
|
|
|
|
|
|
|