Skip to content

Commit baefa0e

Browse files
authored
Merge pull request #208 from Visual-Behavior/scene_flow
Scene flow in frame
2 parents ccf93c2 + 297c7b5 commit baefa0e

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

aloscene/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .bounding_boxes_2d import BoundingBoxes2D
1313
from .bounding_boxes_3d import BoundingBoxes3D
1414
from .oriented_boxes_2d import OrientedBoxes2D
15+
from .scene_flow import SceneFlow
1516
from .frame import Frame
1617
from .tensors.spatial_augmented_tensor import SpatialAugmentedTensor
1718

aloscene/frame.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66

77
import aloscene
88
from aloscene.renderer import View
9-
from aloscene import BoundingBoxes2D, BoundingBoxes3D, Depth, Disparity, Flow, Mask, Labels, Points2D, Points3D, Pose
9+
from aloscene import (
10+
BoundingBoxes2D,
11+
BoundingBoxes3D,
12+
Depth,
13+
Disparity,
14+
Flow,
15+
Mask,
16+
Labels,
17+
Points2D,
18+
Points3D,
19+
Pose,
20+
SceneFlow,
21+
)
1022

1123
# from aloscene.camera_calib import CameraExtrinsic, CameraIntrinsic
1224
from aloscene.io.image import load_image
@@ -114,6 +126,7 @@ def __new__(
114126
tensor.add_child("segmentation", segmentation, align_dim=["B", "T"], mergeable=False)
115127
tensor.add_child("labels", labels, align_dim=["B", "T"], mergeable=True)
116128
tensor.add_child("pose", labels, align_dim=["B", "T"], mergeable=True)
129+
tensor.add_child("scene_flow", labels, align_dim=["B", "T"], mergeable=False)
117130

118131
# Add other tensor property
119132
tensor.add_property("normalization", normalization)
@@ -318,6 +331,25 @@ def append_pose(self, pose: Pose, name: str = None):
318331
"""
319332
self._append_child("pose", pose, name)
320333

334+
def append_scene_flow(self, scene_flow: SceneFlow, name: str = None):
335+
"""Attach a scene flow to the frame.
336+
337+
Parameters
338+
----------
339+
scene_flow : :mod:`SceneFlow <aloscene.SceneFlow>`
340+
Depth to attach to the Frame
341+
name : str
342+
If none, the scene flow will be attached without name (if possible). Otherwise if no other unnamed
343+
scene flow is attached to the frame, the scene flow will be added to the set of scene flows.
344+
345+
Examples
346+
--------
347+
>>> frame = aloscene.Frame("/path/to/image.jpeg")
348+
>>> scene_flow = aloscene.SceneFlow(np.random.rand((3, frame.H, frame.W)))
349+
>>> frame.append_scene_flow(scene_flow)
350+
"""
351+
self._append_child("scene_flow", scene_flow, name)
352+
321353
@staticmethod
322354
def _get_mean_std_tensor(shape, names, mean_std: tuple, device="cpu"):
323355
"""Utils method to a get the mean and the std

aloscene/scene_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def from_optical_flow(
123123
if not has_batch:
124124
scene_flow_vector = scene_flow_vector.squeeze(0)
125125
optical_flow = optical_flow.squeeze(0)
126-
occlusion = occlusion.squeeze(0)
126+
occlusion = occlusion.squeeze(0) if occlusion is not None else None
127127

128128
# Create the scene flow object
129129
tensor = cls(

0 commit comments

Comments
 (0)