Depth + object_pose: refresh tasks.json, README, loader
Browse files- README.md +13 -2
- examples/react_video_dataset.py +21 -9
- tasks.json +18 -12
README.md
CHANGED
|
@@ -49,11 +49,22 @@ data/<task>/
|
|
| 49 |
|---|---|---|
|
| 50 |
| `frame_idx` | int | 0…T-1, matches MP4 frame index |
|
| 51 |
| `timestamp` | float64 | camera clock (s) |
|
| 52 |
-
| `sensor_left_pose`, `sensor_right_pose` | list[7] | OptiTrack world pose (xyz + quat wxyz) |
|
|
|
|
| 53 |
| `tactile_{L,R}_{intensity,area,mixed}` | float32 | contact metrics (computed at full 640×480) |
|
| 54 |
| `source_h5_frame` | int | index into the original recording |
|
| 55 |
|
| 56 |
-
**Decoded frames are RGB** (standard decoder convention) for all five streams.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## Tasks
|
| 59 |
|
|
|
|
| 49 |
|---|---|---|
|
| 50 |
| `frame_idx` | int | 0…T-1, matches MP4 frame index |
|
| 51 |
| `timestamp` | float64 | camera clock (s) |
|
| 52 |
+
| `sensor_left_pose`, `sensor_right_pose` | list[7] | OptiTrack world pose of each GelSight (xyz + quat wxyz) |
|
| 53 |
+
| `object_pose` | list[7] | OptiTrack world pose of the manipulated object (NaN where the object body was not tracked — e.g. all pushT) |
|
| 54 |
| `tactile_{L,R}_{intensity,area,mixed}` | float32 | contact metrics (computed at full 640×480) |
|
| 55 |
| `source_h5_frame` | int | index into the original recording |
|
| 56 |
|
| 57 |
+
**Decoded frames are RGB** (standard decoder convention) for all five RGB streams.
|
| 58 |
+
|
| 59 |
+
### depth (optional, `data/<task>/depth/`)
|
| 60 |
+
Per-camera depth is shipped as **lossless FFV1 16-bit video** (`gray16le`):
|
| 61 |
+
```
|
| 62 |
+
data/<task>/depth/<date>/episode_NNN/depth_{left,middle,right}.mkv
|
| 63 |
+
```
|
| 64 |
+
- uint16, **millimeters**; `0` = no return / invalid.
|
| 65 |
+
- Frame `i` aligns to the RGB video frame `i` and parquet row `i`.
|
| 66 |
+
- Decode with PyAV (`frame.to_ndarray()` → `(480, 640)` uint16). cv2 cannot read 16-bit video.
|
| 67 |
+
- Load via `ReactVideoDataset(..., load_depth=True)`.
|
| 68 |
|
| 69 |
## Tasks
|
| 70 |
|
examples/react_video_dataset.py
CHANGED
|
@@ -46,18 +46,21 @@ except Exception:
|
|
| 46 |
VIEW_STREAMS = ("view_left", "view_middle", "view_right")
|
| 47 |
TACTILE_STREAMS = ("tactile_left", "tactile_right")
|
| 48 |
ALL_STREAMS = VIEW_STREAMS + TACTILE_STREAMS
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
-
def _decode_frames(mp4_path: Path, frame_indices):
|
| 52 |
-
"""Return (N, H, W, 3) uint8 RGB
|
| 53 |
want = list(frame_indices)
|
| 54 |
-
if
|
|
|
|
| 55 |
container = av.open(str(mp4_path))
|
| 56 |
stream = container.streams.video[0]
|
| 57 |
out, wantset, got = {}, set(want), 0
|
| 58 |
for fi, frame in enumerate(container.decode(stream)):
|
| 59 |
if fi in wantset:
|
| 60 |
-
|
|
|
|
| 61 |
got += 1
|
| 62 |
if got == len(wantset):
|
| 63 |
break
|
|
@@ -77,7 +80,7 @@ def _decode_frames(mp4_path: Path, frame_indices):
|
|
| 77 |
class ReactVideoDataset:
|
| 78 |
def __init__(self, task_root, window_length=16, stride=1, window_step=None,
|
| 79 |
mode="segment", streams=ALL_STREAMS, skip_bad=True,
|
| 80 |
-
which_sensors="any"):
|
| 81 |
self.root = Path(task_root)
|
| 82 |
self.W = window_length
|
| 83 |
self.stride = stride
|
|
@@ -86,6 +89,8 @@ class ReactVideoDataset:
|
|
| 86 |
self.streams = tuple(streams)
|
| 87 |
self.skip_bad = skip_bad
|
| 88 |
self.which = which_sensors
|
|
|
|
|
|
|
| 89 |
|
| 90 |
self.segments = json.loads((self.root / "segments.json").read_text())["segments"]
|
| 91 |
self.bad = json.loads((self.root / "bad_frames.json").read_text())["episodes"]
|
|
@@ -141,13 +146,20 @@ class ReactVideoDataset:
|
|
| 141 |
idx = list(range(start, start + (self.W - 1) * self.stride + 1, self.stride))
|
| 142 |
vd = self._video_dir(ek)
|
| 143 |
out = {s: _decode_frames(vd / f"{s}.mp4", idx) for s in self.streams}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
tbl = pq.read_table(self._parquet(ek)).slice(start, idx[-1] - start + 1)
|
| 145 |
# subsample by stride
|
| 146 |
rows = [r - start for r in idx]
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
for c in ("tactile_left_intensity", "tactile_right_intensity",
|
| 152 |
"tactile_left_mixed", "tactile_right_mixed"):
|
| 153 |
out[c] = np.array(tbl.column(c).to_pylist(), np.float32)[rows]
|
|
|
|
| 46 |
VIEW_STREAMS = ("view_left", "view_middle", "view_right")
|
| 47 |
TACTILE_STREAMS = ("tactile_left", "tactile_right")
|
| 48 |
ALL_STREAMS = VIEW_STREAMS + TACTILE_STREAMS
|
| 49 |
+
DEPTH_STREAMS = ("depth_left", "depth_middle", "depth_right") # optional, uint16 mm
|
| 50 |
|
| 51 |
|
| 52 |
+
def _decode_frames(mp4_path: Path, frame_indices, depth=False):
|
| 53 |
+
"""Return (N, H, W, 3) uint8 RGB, or (N, H, W) uint16 mm if depth=True."""
|
| 54 |
want = list(frame_indices)
|
| 55 |
+
fmt = None if depth else "rgb24" # depth: native gray16le ndarray
|
| 56 |
+
if _BACKEND == "av" or depth: # depth requires PyAV (16-bit)
|
| 57 |
container = av.open(str(mp4_path))
|
| 58 |
stream = container.streams.video[0]
|
| 59 |
out, wantset, got = {}, set(want), 0
|
| 60 |
for fi, frame in enumerate(container.decode(stream)):
|
| 61 |
if fi in wantset:
|
| 62 |
+
a = frame.to_ndarray(format=fmt) if fmt else frame.to_ndarray()
|
| 63 |
+
out[fi] = a
|
| 64 |
got += 1
|
| 65 |
if got == len(wantset):
|
| 66 |
break
|
|
|
|
| 80 |
class ReactVideoDataset:
|
| 81 |
def __init__(self, task_root, window_length=16, stride=1, window_step=None,
|
| 82 |
mode="segment", streams=ALL_STREAMS, skip_bad=True,
|
| 83 |
+
which_sensors="any", load_depth=False):
|
| 84 |
self.root = Path(task_root)
|
| 85 |
self.W = window_length
|
| 86 |
self.stride = stride
|
|
|
|
| 89 |
self.streams = tuple(streams)
|
| 90 |
self.skip_bad = skip_bad
|
| 91 |
self.which = which_sensors
|
| 92 |
+
# depth only if requested AND present on disk for this task
|
| 93 |
+
self.load_depth = load_depth and (self.root / "depth").is_dir()
|
| 94 |
|
| 95 |
self.segments = json.loads((self.root / "segments.json").read_text())["segments"]
|
| 96 |
self.bad = json.loads((self.root / "bad_frames.json").read_text())["episodes"]
|
|
|
|
| 146 |
idx = list(range(start, start + (self.W - 1) * self.stride + 1, self.stride))
|
| 147 |
vd = self._video_dir(ek)
|
| 148 |
out = {s: _decode_frames(vd / f"{s}.mp4", idx) for s in self.streams}
|
| 149 |
+
if self.load_depth:
|
| 150 |
+
date, ep = ek.split("/")
|
| 151 |
+
dd = self.root / "depth" / date / ep
|
| 152 |
+
for s in DEPTH_STREAMS:
|
| 153 |
+
p = dd / f"{s}.mkv"
|
| 154 |
+
if p.exists():
|
| 155 |
+
out[s] = _decode_frames(p, idx, depth=True) # (T,H,W) uint16 mm
|
| 156 |
tbl = pq.read_table(self._parquet(ek)).slice(start, idx[-1] - start + 1)
|
| 157 |
# subsample by stride
|
| 158 |
rows = [r - start for r in idx]
|
| 159 |
+
for c in ("sensor_left_pose", "sensor_right_pose"):
|
| 160 |
+
out[c] = np.array(tbl.column(c).to_pylist(), np.float32)[rows]
|
| 161 |
+
if "object_pose" in tbl.column_names:
|
| 162 |
+
out["object_pose"] = np.array(tbl.column("object_pose").to_pylist(), np.float32)[rows]
|
| 163 |
for c in ("tactile_left_intensity", "tactile_right_intensity",
|
| 164 |
"tactile_left_mixed", "tactile_right_mixed"):
|
| 165 |
out[c] = np.array(tbl.column(c).to_pylist(), np.float32)[rows]
|
tasks.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"dataset": "React",
|
| 3 |
-
"format": "video (LeRobot-style: per-camera MP4 + per-episode parquet)",
|
| 4 |
"resolution": "640x480",
|
| 5 |
"fps": 30,
|
| 6 |
"video_streams": [
|
|
@@ -10,15 +10,21 @@
|
|
| 10 |
"tactile_left",
|
| 11 |
"tactile_right"
|
| 12 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"parquet_columns": [
|
| 14 |
"frame_idx",
|
| 15 |
"timestamp",
|
| 16 |
"sensor_left_pose",
|
| 17 |
"sensor_right_pose",
|
|
|
|
| 18 |
"tactile_{L,R}_{intensity,area,mixed}",
|
| 19 |
"source_h5_frame"
|
| 20 |
],
|
| 21 |
-
"decoded_color": "RGB
|
| 22 |
"tasks": {
|
| 23 |
"motherboard": {
|
| 24 |
"n_episodes": 32,
|
|
@@ -39,15 +45,12 @@
|
|
| 39 |
"calibration_id": "may-12",
|
| 40 |
"calibration_created": "2026-05-12",
|
| 41 |
"calibration_rmse_unit": "mm",
|
| 42 |
-
"
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
0.175
|
| 47 |
-
]
|
| 48 |
-
},
|
| 49 |
"gelsight_left_serial": "2BGLKZNT/2DUPB53G",
|
| 50 |
-
"note": "Bimanual handheld tactile-visual interaction. 05-19 has a redefined OptiTrack world origin;
|
| 51 |
},
|
| 52 |
"pushT": {
|
| 53 |
"n_episodes": 4,
|
|
@@ -66,9 +69,12 @@
|
|
| 66 |
"calibration_id": "june-26",
|
| 67 |
"calibration_created": "2026-06-26",
|
| 68 |
"calibration_rmse_unit": "px",
|
| 69 |
-
"
|
|
|
|
|
|
|
|
|
|
| 70 |
"gelsight_left_serial": "2DUPB53G",
|
| 71 |
-
"note": "Push-T manipulation. Recalibrated cameras (June-26).
|
| 72 |
}
|
| 73 |
}
|
| 74 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"dataset": "React",
|
| 3 |
+
"format": "video (LeRobot-style: per-camera MP4 + per-episode parquet; depth as FFV1 16-bit MKV)",
|
| 4 |
"resolution": "640x480",
|
| 5 |
"fps": 30,
|
| 6 |
"video_streams": [
|
|
|
|
| 10 |
"tactile_left",
|
| 11 |
"tactile_right"
|
| 12 |
],
|
| 13 |
+
"depth_streams": [
|
| 14 |
+
"depth_left",
|
| 15 |
+
"depth_middle",
|
| 16 |
+
"depth_right"
|
| 17 |
+
],
|
| 18 |
"parquet_columns": [
|
| 19 |
"frame_idx",
|
| 20 |
"timestamp",
|
| 21 |
"sensor_left_pose",
|
| 22 |
"sensor_right_pose",
|
| 23 |
+
"object_pose",
|
| 24 |
"tactile_{L,R}_{intensity,area,mixed}",
|
| 25 |
"source_h5_frame"
|
| 26 |
],
|
| 27 |
+
"decoded_color": "RGB",
|
| 28 |
"tasks": {
|
| 29 |
"motherboard": {
|
| 30 |
"n_episodes": 32,
|
|
|
|
| 45 |
"calibration_id": "may-12",
|
| 46 |
"calibration_created": "2026-05-12",
|
| 47 |
"calibration_rmse_unit": "mm",
|
| 48 |
+
"object_tracked_episodes": 32,
|
| 49 |
+
"depth_available_episodes": 32,
|
| 50 |
+
"depth_units": "mm",
|
| 51 |
+
"depth_invalid_value": 0,
|
|
|
|
|
|
|
|
|
|
| 52 |
"gelsight_left_serial": "2BGLKZNT/2DUPB53G",
|
| 53 |
+
"note": "Bimanual handheld tactile-visual interaction. Object pose (the board) tracked. 05-19 has a redefined OptiTrack world origin; offset (0.23,0,0.175)m baked into poses."
|
| 54 |
},
|
| 55 |
"pushT": {
|
| 56 |
"n_episodes": 4,
|
|
|
|
| 69 |
"calibration_id": "june-26",
|
| 70 |
"calibration_created": "2026-06-26",
|
| 71 |
"calibration_rmse_unit": "px",
|
| 72 |
+
"object_tracked_episodes": 0,
|
| 73 |
+
"depth_available_episodes": 4,
|
| 74 |
+
"depth_units": "mm",
|
| 75 |
+
"depth_invalid_value": 0,
|
| 76 |
"gelsight_left_serial": "2DUPB53G",
|
| 77 |
+
"note": "Push-T manipulation. Recalibrated cameras (June-26). Object rigid body was not tracked (object_pose = NaN). episode_004 source H5 corrupt, excluded."
|
| 78 |
}
|
| 79 |
}
|
| 80 |
}
|