mmhuman3d安装及读取.smc文件
mmhuman3d下载安装
为了防止冲突以及保持项目的独立性,直接将所有package都搞到本地文件夹下,不装到dist-packages下面
mmhuman3d
git clone https://github.com/open-mmlab/mmhuman3d.git
cd mmhuman3d
python setup.py build_ext --inplace
mmcv
wget https://files.pythonhosted.org/packages/bc/8d/19cad8c32db1ed832ea49026eb6a1fd9d6255d6f856a87ea2828a1555905/mmcv-1.7.0.tar.gz
tar -zxvf mmcv-1.7.0.tar.gz
cd mmcv-1.7.0
python setup.py build_ext --inplace
cp -r mmcv …/
einops
cd mmhuman3d
wget https://files.pythonhosted.org/packages/12/59/4fea1764008e4cfa5f7cae68e07b882e972d5c0bb6479139075cb1123e19/einops-0.4.0.tar.gz
tar -zxvf einops-0.4.0.tar.gz
cd ein*/
python setup.py build_ext --inplace
cp -r einops …
下载文件
需要下载的数据集在这里
下载解压以后,用如下代码测试结果:
import syssys.path.append('/your/path/to/mmhuman3d') # setup以后会生成一个mmhuman3d的文件夹from mmhuman3d.data.data_structures.smc_reader import SMCReader# Initialize a smc readersmc_reader = SMCReader('/your/path/to/xxx.smc')# Get calibration# Kinect IDs: from 0 to 9# iPhone ID: 0; vertical: images are transformed from landscape to vertical# 4x4 matrixkinect_extrinsics = smc_reader.get_kinect_color_extrinsics(kinect_id=0)iphone_extrinsics = smc_reader.get_iphone_extrinsics(iphone_id=0)# Get images# frame_num * height * width * 3kinect_images = smc_reader.get_color(device='Kinect', device_id=0) # n * 1080 * 1920 * 3iphone_images = smc_reader.get_color(device='iPhone', device_id=0, vertical=True) # n * 1920 * 1440 * 3# Get depth maps# frame_num * height * widthkinect_depth = smc_reader.get_kinect_depth(kinect_id=0) # n * 576 * 640iphone_depth = smc_reader.get_iphone_depth(iphone_id=0) # n * 256 * 192# Get 2D keypoints# frame_num * keypoint_num * 3 (x, y, confidence)kinect_keypoints2d, kinect_keypoints2d_mask = smc_reader.get_keypoints2d(device='Kinect', device_id=0)iphone_keypoints2d, iphone_keypoints2d_mask = smc_reader.get_keypoints2d(device='iPhone', device_id=0, vertical=True)# Get 3D keypoints# frame_num * keypoint_num * 4 (x, y, z, confidence)keypoints3d, keypoints3d_mask = smc_reader.get_keypoints3d(device='Kinect', device_id=0)
注意,图片是BGR格式的,想要改成RGB可以用
kinect_images = smc_reader.get_color(device='Kinect', device_id=0)[..., ::-1]
如果想要预览这个数据集的视频,可以用如下函数保存成mp4:
def numpy_array_to_video(numpy_array,video_out_path): # 将BGR转换为RGB numpy_array = numpy_array[..., ::-1] video_height = numpy_array.shape[1] video_width = numpy_array.shape[2] out_video_size = (video_width,video_height) output_video_fourcc = int(cv2.VideoWriter_fourcc(*'mp4v')) video_write_capture = cv2.VideoWriter(video_out_path, output_video_fourcc, 30, out_video_size) for frame in numpy_array: video_write_capture.write(frame) video_write_capture.release()
例如:
numpy_array_to_video(kinect_images,'1_out.mp4')
深度相机
一共有0-9共10个深度相机,device_id从小到大依次为:
0: 前
1: 右前
2: 右上
3: 右下
4: 右后
5: 后
6: 左后
7: 左上
8: 左下
9: 左前
其中共8个方位角,左右两侧各两个深度相机,位于上/下。其余位置1个深度相机。
本人正在研究smplx相关替代方案。如果您对此方面感兴趣,可以和我联系。