Skip to content

Commit cc7bbb0

Browse files
committed
fix(cam): depth scaling corrected
1 parent 479d5c5 commit cc7bbb0

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

extensions/rcs_realsense/src/rcs_realsense/camera.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def to_ts(frame: rs.frame) -> float:
286286
elif rs.stream.depth == stream.stream_type():
287287
frame = frameset.get_depth_frame()
288288
depth = DataFrame(
289-
data=(to_numpy(frame).astype(np.float64) * device.depth_scale / BaseCameraSet.DEPTH_SCALE).astype(
290-
np.int16
289+
data=(to_numpy(frame).astype(np.float64) * device.depth_scale * BaseCameraSet.DEPTH_SCALE).astype(
290+
np.uint16
291291
),
292292
timestamp=to_ts(frame),
293293
intrinsics=device.depth_intrinsics,

python/rcs/camera/sim.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from rcs._core.sim import FrameSet as _FrameSet
1111
from rcs._core.sim import SimCameraConfig
1212
from rcs._core.sim import SimCameraSet as _SimCameraSet
13-
from rcs.camera.interface import CameraFrame, DataFrame, Frame, FrameSet
13+
from rcs.camera.interface import BaseCameraSet, CameraFrame, DataFrame, Frame, FrameSet
1414

1515
from rcs import sim
1616

@@ -77,13 +77,15 @@ def _cpp_to_python_frames(self, cpp_frameset: _FrameSet | None) -> FrameSet | No
7777
data=color_np_frame,
7878
timestamp=cpp_frameset.timestamp,
7979
intrinsics=self._intrinsics(color_name),
80-
extrinsics=self._extrinsics(color_frame),
80+
extrinsics=self._extrinsics(color_name),
8181
),
8282
depth=DataFrame(
83-
data=depth_np_frame,
83+
data= (depth_np_frame * BaseCameraSet.DEPTH_SCALE).astype(
84+
np.uint16
85+
),
8486
timestamp=cpp_frameset.timestamp,
85-
intrinsics=self._intrinsics(depth_frame),
86-
extrinsics=self._extrinsics(depth_frame),
87+
intrinsics=self._intrinsics(depth_name),
88+
extrinsics=self._extrinsics(depth_name),
8789
),
8890
)
8991
frame = Frame(camera=cameraframe, avg_timestamp=cpp_frameset.timestamp)

python/rcs/envs/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,13 @@ def __init__(self, env, camera_set: BaseCameraSet, include_depth: bool = False):
604604
params.update(
605605
{
606606
f"/{name}/{self.DEPTH_KEY}/frame": {
607+
# values metric but scaled with factor rcs.BaseCameraSet.DEPTH_SCALE to fit into uint16
607608
"height": camera_set.config(name).resolution_height,
608609
"width": camera_set.config(name).resolution_width,
609610
"color_dim": 1,
610611
"dtype": np.uint16,
611-
"low": -np.inf,
612-
"high": np.inf,
612+
"low": 0,
613+
"high": 65535,
613614
}
614615
for name in camera_set.camera_names
615616
}

0 commit comments

Comments
 (0)