MiDaS<T>
Models & Types · AiDotNet.Video.Depth
MiDaS: Towards Robust Monocular Depth Estimation.
Inheritance: NeuralNetworkBase<T> → MiDaS<T>
For Beginners
MiDaS estimates depth from a single image (monocular depth estimation). Unlike stereo vision which uses two cameras, MiDaS uses deep learning to predict depth from visual cues like texture, perspective, and object sizes.
Key capabilities:
- Single image to depth map conversion
- Works on arbitrary images without camera parameters
- Outputs relative depth (closer objects have higher values)
- Robust across different scenes and domains
Example usage:
How It Works
Technical Details:
- ViT-based encoder for feature extraction
- Multi-scale fusion decoder
- Scale and shift invariant loss for training
- Trained on diverse mixed datasets for robustness
Reference: “Towards Robust Monocular Depth Estimation: Mixing Datasets for Zero-shot Cross-dataset Transfer”
https://arxiv.org/abs/1907.01341
Constructors
| Constructor | Summary |
|---|---|
MiDaS() |
Creates a MiDaS model with default configuration. |
MiDaS(NeuralNetworkArchitecture<T> architecture, MiDaSOptions options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Creates a MiDaS model using native layers for training and inference. |
MiDaS(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, MiDaSOptions options) |
Creates a MiDaS model using a pretrained ONNX model for inference. |
Properties
| Property | Summary |
|---|---|
bool SupportsTraining { get; } |
Methods
| Method | Summary |
|---|---|
List<Tensor<T>> EstimateDepthForVideo(List<Tensor<T>> frames) |
Estimates depth for multiple video frames. |
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> EstimateDepth(Tensor<T> image) |
Estimates depth from an input image. |
Tensor<T> NormalizeDepthMap(Tensor<T> depthMap) |
Normalizes depth map to 0-1 range for visualization. |