This project performs depth estimation on a set of images using the MiDaS (Mixed Data Sampling) model.
- OpenCV (
cv2
) - PyTorch (
torch
) - Matplotlib (
matplotlib.pyplot
) - NumPy (
numpy
) - OS (
os
)
-
Clone the repository:
git clone https://github.com/the-y9/depth_estimation.git
-
Install dependencies:
pip install torch torchvision matplotlib numpy
or
pip install -r requirements.txt
-
Run the script:
python main.py
The script loads a set of images from a specified folder and performs depth estimation using the MiDaS model. It then displays the original image along with its corresponding depth map.
- Load the MiDaS model.
- Load images from the specified folder.
- Resize each image to a desired height while maintaining the aspect ratio.
- Transform the input image for MiDaS.
- Perform depth prediction using MiDaS.
- Normalize the depth values.
- Display the original image and its depth map.
The quality of the image and the complexity of the background can affect the accuracy of the depth estimation. For best results, use high-quality images with clear and distinct foreground objects, as these factors can impact the accuracy of depth estimation.
- MiDaS: GitHub Repository