miop.raft_flow¶
Classes
|
Computes dense optical flow (displacement maps) between image pairs using the RAFT model. |
- class miop.raft_flow.RaftFlow(device=None)[source]¶
Bases:
DAGNodeComputes dense optical flow (displacement maps) between image pairs using the RAFT model.
- device¶
The device (CPU, CUDA, MPS) used for inference.
- Type:
torch.device
- disp_maps¶
The computed displacement maps for each image pair in each face of the collection. Each displacement map is a 2D flow field of shape (2, H, W), where:
disp[0, :, :] is the x-direction displacement,
disp[1, :, :] is the y-direction displacement.
- Type:
list of list of np.ndarray or None
- compute_flow(image_1, image_2)[source]¶
Computes the dense optical flow (displacement map) between two RGB images using the RAFT model.
- Parameters:
image_1 (np.ndarray) – The first image of shape (H, W, 3) in uint8 or float format.
image_2 (np.ndarray) – The second image of shape (H, W, 3) in uint8 or float format.
- Returns:
A displacement map of shape (2, H, W), where the first channel is x-displacement and the second channel is y-displacement.
- Return type:
np.ndarray
- eval(img_collection)[source]¶
Evaluates the optical flow for each image pair in the image collection.
- Parameters:
img_collection (ImageCollection) – An image collection containing pairs of images organized by faces.
- Returns:
A nested list where each element corresponds to a face, and contains the displacement maps for each image pair in that face.
- Return type:
list of list of np.ndarray
- show(face=0, pair=0, cmap='Spectral')[source]¶
Visualizes the displacement map for a specific image pair using matplotlib.
- Parameters:
face (int, optional) – Index of the face to visualize (default: 0).
pair (int, optional) – Index of the image pair within the face to visualize (default: 0).
cmap (str, optional) – Colormap to use for the visualization (default: “Spectral”).
- Raises:
AttributeError – If self.disp_maps is not available.