使用 Intel RealSense D455 相机采集箱体 RGB-D 数据集。
bash
python scripts/collect_v2.py
按键功能S保存 1 张(RGB + Depth)A自动保存 10 张(每 5 秒 1 张)Q退出并打开数据目录
text
box_dataset/
└── box_YYYYMMDD_HHMMSS/
├── camera_intrinsic.json # 相机内参
├── dataset_config.json # 数据集配置
├── capture_stats.json # 采集统计
└── raw_data/
├── 000001_Color.png # RGB 彩色图
├── 000001_Depth.raw # 深度图 (uint16)
└── ...
文件格式说明XXX_Color.pngPNG 8位 RGB彩色图像XXX_Depth.rawuint16 raw深度数据 (640×480×2 bytes)camera_intrinsic.jsonJSON相机内参 (fx, fy, cx, cy)
python
import numpy as np
depth = np.fromfile("000001_Depth.raw", dtype=np.uint16)
depth = depth.reshape(480, 640)
depth_m = depth / 1000.0 # 转换为米
python
import json
with open("camera_intrinsic.json") as f:
intr = json.load(f)
def pixel_to_3d(u, v, depth_m):
X = (u - intr['ppx']) * depth_m / intr['fx']
Y = (v - intr['ppy']) * depth_m / intr['fy']
Z = depth_m
return X, Y, Z
bash
pip install pyrealsense2 opencv-python numpy
作者:Robot_Qu
版本:v2.0