cauphe commited on
Commit
e4c53f2
·
verified ·
1 Parent(s): 7045e31

Add files using upload-large-folder tool

Browse files
MultiCamVideo-Dataset.tar.part.aa ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:beb23c7aac8cb4e103c1e4234e4d53cf3cd0c914b156feade3b3dc59c59c84c2
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ab ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa78d9f88c544988658b8281240d63a25e7e23b677e2f98bd31206381d7cdda1
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ac ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c2128469190b57ef398ff59c69ce4353d991d5dcc4f4ff768e1ac007ed43a1d
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ad ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80c92c60ea6efe14ce4f9b7083096ec1aa2a6863bf09d7fc1b5e082fe2000574
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ae ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb08f73d0240358656532a726aef2370fa500ed7c8cf24b362fe1b02fdbf5187
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.af ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5900dbf9397aac5614e7c1cffe9a976a4038df8e88df32ae429cdc4bfe253b3
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ag ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0c8ff01982b19d18bec350c4977c12bcde445d723d88f17db2693c8ca518bee
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ah ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8c6058c3cabcabc7c4e8d68e309d8a0cac8fd86d5f71ea09c884580272589873
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ai ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df133ec37dceb57e3ace1de2bdd2b858808cd70425e7908d777c92f87b7e0cf4
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.aj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5e1b70835ff95f1a0df88a2398c24ed8f4942d441bc26198116382a20bd3b71
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ak ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe4ae1454baeec2613d90519fb2cfbb0939dfd73fe4cea745c7fb439918c16f4
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.al ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6367f72a019a325486988142712297173512831a110a7c13c716ffb894e04a03
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.am ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86464c153b38bc145ccd7131e1418d16f51f63b41bf41315d40f099ba44201a
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.an ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d09ae4e5fa289c7a33ba37c91ec50b49cfcf0bb05a38ecf1d14f2d33ccffff2
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ao ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7844ede63498880c05dec2b6964aa8799f44745a833aa98b13d9390e919a9a2c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ap ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8f4c327b32e6f7c7846d6f828fcc6c8b4bac15e1094fa69856d7686bd60d7cb
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.aq ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:541cfdf18465a94ee671251d89e957bb9756c776c4113dffe2738a2c251121f2
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:347e4f19d76757098fb6f02fdf65f41869186c8bbfa70bfec211ef51f60e3fa8
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.as ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccc701a270a73ad84fa3d046ccacb3c53d1d0114024a2d51ab91f0670e1e8e61
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.at ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c99e100654a096d7d74153ed205b950a5452e09032ba0eec1ac2e6d39f78585
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.au ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89d4a2a658b915af8c454f16e67c9b4d4fc6de5f574b751ca64f48d9f62ec715
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.av ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e46c224c0058572d34ab432dcd4d33cc68467fe0f5a83ca6fb8238e2fcd34dd0
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.aw ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:94f216c4098588557270b54e252336370efa1d705a2a841a1e8aa2e76b11d75e
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ax ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb4b5a535ec5ffebc821d9e4bf4687532225c07f74560ef3e6bbd4c5e189edb3
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ay ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e59a85b16d846d461488705d53d8dc86542c717f7d6da4d0a55aba5db7b02a8c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.az ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea35ff0c2d7d26fb8a435278a5eb448f891d8b57c6ca7f6e6e21414a73a7734c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.ba ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:95c77e6d8c47f2bb0f801f77b9ec9210fff9892c4f07e3bf221f8d5a46b9c76c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c1d30841d0090bf1de57f5f8d7305876dc6f9e032b80a4b4c9d7c53a9aeb644
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45e9b3fe40d632e4aa7cfd1c6611c1cdd9f59ed7c5e956fbb39a399a27b8881c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afdbb417c72644f3316ef4531892eb4d7bd50b72063de8391de4811c99a8680c
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.be ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1940da8f4db9eb373bee1c8879c2004fe2ec01a263b92af6615c772631cec2f
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b248270140837eef83424bb2151bc7845b4b84a8fea16f4cd174f96c6fb4489d
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bg ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d400988a28dccd02d152ba8fa93261e5efb2fc6d181fb8ca455c6935443a179d
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27a39572e498d3c62b5b71d5fab852b8361734ec3c8d661e64e7346c33588078
3
+ size 42949672960
MultiCamVideo-Dataset.tar.part.bi ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fff833e4fef5599f60e199b1e837b0b0c85b0c17e7c050148307caaf9697b9eb
3
+ size 17820764160
README.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ [Github](https://github.com/KwaiVGI/ReCamMaster)
5
+
6
+ [Project Page](https://jianhongbai.github.io/ReCamMaster/)
7
+
8
+ [Paper](https://arxiv.org/abs/2503.11647)
9
+
10
+ ## 📷 MultiCamVideo Dataset
11
+ ### 1. Dataset Introduction
12
+
13
+ **TL;DR:** The MultiCamVideo Dataset, introduced in [ReCamMaster](https://arxiv.org/abs/2503.11647), is a multi-camera synchronized video dataset rendered using Unreal Engine 5. It includes synchronized multi-camera videos and their corresponding camera trajectories. The MultiCamVideo Dataset can be valuable in fields such as camera-controlled video generation, synchronized video production, and 3D/4D reconstruction.
14
+
15
+ <div align="center">
16
+ <video controls autoplay style="width: 70%;" src="https://cdn-uploads.huggingface.co/production/uploads/6530bf50f145530101ec03a2/r-cc03Z6b5v_X5pkZbIZR.mp4"></video>
17
+ </div>
18
+
19
+ The MultiCamVideo Dataset is a multi-camera synchronized video dataset rendered using Unreal Engine 5. It includes synchronized multi-camera videos and their corresponding camera trajectories.
20
+ It consists of 13.6K different dynamic scenes, each captured by 10 cameras, resulting in a total of 136K videos and 112K different camera trajectories. Each dynamic scene is composed of four elements: {3D environment, character, animation, camera}. Specifically, we use animation to drive the character
21
+ and position the animated character within the 3D environment. Then, Time-synchronized cameras are set up to move along predefined trajectories to render the multi-camera video data.
22
+
23
+ <p align="center">
24
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6530bf50f145530101ec03a2/Ea0Feqy7uBTLczyPal-CE.png" alt="Example Image" width="70%">
25
+ </p>
26
+
27
+ **3D Environment:** We collect 37 high-quality 3D environments assets from [Fab](https://www.fab.com). To minimize the domain gap between rendered data and real-world videos, we primarily select visually realistic 3D scenes, while choosing a few stylized or surreal 3D scenes as a supplement. To ensure data diversity, the selected scenes cover a variety of indoor and outdoor settings, such as city streets, shopping malls, cafes, office rooms, and the countryside.
28
+
29
+ **Character:** We collect 66 different human 3D models as characters from [Fab](https://www.fab.com) and [Mixamo](https://www.mixamo.com).
30
+
31
+ **Animation:** We collect 93 different animations from [Fab](https://www.fab.com) and [Mixamo](https://www.mixamo.com), including common actions such as waving, dancing, and cheering. We use these animations to drive the collected characters and create diverse datasets through various combinations.
32
+
33
+ **Camera:** To ensure camera movements are diverse and closely resemble real-world distributions, we create a wide range of camera trajectories and parameters to cover various situations. To achieve this by designing rules to batch-generate random camera starting positions and movement trajectories:
34
+
35
+ 1. Camera Starting Position.
36
+
37
+ We take the character's position as the center of a hemisphere with a radius of {3m, 5m, 7m, 10m} based on the size of the 3D scene and randomly sample within this range as the camera's starting point, ensuring the closest distance to the character is greater than 0.5m and the pitch angle is within 45 degrees.
38
+
39
+ 2. Camera Trajectories.
40
+
41
+ - **Pan & Tilt**:
42
+ The camera rotation angles are randomly selected within the range, with pan angles ranging from 5 to 45 degrees and tilt angles ranging from 5 to 30 degrees, with directions randomly chosen left/right or up/down.
43
+
44
+ - **Basic Translation**:
45
+ The camera translates along the positive and negative directions of the xyz axes, with movement distances randomly selected within the range of \\([\frac{1}{4}, 1] \times\\) distance2character.
46
+
47
+ - **Basic Arc Trajectory**:
48
+ The camera moves along an arc, with rotation angles randomly selected within the range of 15 to 75 degrees.
49
+
50
+ - **Random Trajectories**:
51
+ 1-3 points are sampled in space, and the camera moves from the initial position through these points as the movement trajectory, with the total movement distance randomly selected within the range of \\([\frac{1}{4}, 1] \times\\) distance2character. The polyline is smoothed to make the movement more natural.
52
+
53
+ - **Static Camera**:
54
+ The camera does not translate or rotate during shooting, maintaining a fixed position.
55
+
56
+ 3. Camera Movement Speed.
57
+
58
+ To further enhance the diversity of trajectories, 50% of the training data uses constant-speed camera trajectories, while the other 50% uses variable-speed trajectories generated by nonlinear functions. Consider a camera trajectory with a total of \\(f\\) frames, starting at location \\(L_{start}\\) and ending at position \\(L_{end}\\). The location at the \\(i\\)-th frame is given by:
59
+
60
+ \\(L_i = L_{start} + (L_{end} - L_{start}) \cdot \left( \frac{1 - \exp(-a \cdot i/f)}{1 - \exp(-a)} \right),\\)
61
+
62
+ where \\(a\\) is an adjustable parameter to control the trajectory speed. When \\(a > 0\\), the trajectory starts fast and then slows down; when \\(a < 0\\), the trajectory starts slow and then speeds up. The larger the absolute value of \\(a\\), the more drastic the change.
63
+
64
+
65
+
66
+ 4. Camera Parameters.
67
+
68
+ We chose four set of camera parameters: {focal=18mm, aperture=10}, {focal=24mm, aperture=5}, {focal=35mm, aperture=2.4} and {focal=50mm, aperture=2.4}.
69
+
70
+ ### 2. Statistics and Configurations
71
+
72
+ Dataset Statistics:
73
+ | Number of Dynamic Scenes | Camera per Scene | Total Videos |
74
+ |:------------------------:|:----------------:|:------------:|
75
+ | 13,600 | 10 | 136,000 |
76
+
77
+ Video Configurations:
78
+
79
+ | Resolution | Frame Number | FPS |
80
+ |:-----------:|:------------:|:------------------------:|
81
+ | 1280x1280 | 81 | 15 |
82
+
83
+ Note: You can use 'center crop' to adjust the video's aspect ratio to fit your video generation model, such as 16:9, 9:16, 4:3, or 3:4.
84
+
85
+ Camera Configurations:
86
+
87
+ | Focal Length | Aperture | Sensor Height | Sensor Width |
88
+ |:-----------------------:|:------------------:|:-------------:|:------------:|
89
+ | 18mm, 24mm, 35mm, 50mm | 10.0, 5.0, 2.4 | 23.76mm | 23.76mm |
90
+
91
+
92
+
93
+ ### 3. File Structure
94
+ ```
95
+ MultiCamVideo-Dataset
96
+ ├── train
97
+ │ ├── f18_aperture10
98
+ │ │ ├── scene1 # one dynamic scene
99
+ │ │ │ ├── videos
100
+ │ │ │ │ ├── cam01.mp4 # synchronized 81-frame videos at 1280x1280 resolution
101
+ │ │ │ │ ├── cam02.mp4
102
+ │ │ │ │ ├── ...
103
+ │ │ │ │ └── cam10.mp4
104
+ │ │ │ └── cameras
105
+ │ │ │ └── camera_extrinsics.json # 81-frame camera extrinsics of the 10 cameras
106
+ │ │ ├── ...
107
+ │ │ └── scene3400
108
+ │ ├── f24_aperture5
109
+ │ │ ├── scene1
110
+ │ │ ├── ...
111
+ │ │ └── scene3400
112
+ │ ├── f35_aperture2.4
113
+ │ │ ├── scene1
114
+ │ │ ├── ...
115
+ │ │ └── scene3400
116
+ │ └── f50_aperture2.4
117
+ │ ├── scene1
118
+ │ ├── ...
119
+ │ └── scene3400
120
+ └── val
121
+ └── 10basic_trajectories
122
+ ├── videos
123
+ │ ├── cam01.mp4 # example videos corresponding to the validation cameras
124
+ │ ├── cam02.mp4
125
+ │ ├── ...
126
+ │ └── cam10.mp4
127
+ └── cameras
128
+ └── camera_extrinsics.json # 10 different trajectories for validation
129
+ ```
130
+
131
+ ### 4. Useful scripts
132
+ - Data Extraction
133
+ ```bash
134
+ sudo apt-get install git-lfs
135
+ git lfs install
136
+ git clone https://huggingface.co/datasets/KwaiVGI/MultiCamVideo-Dataset
137
+ cat MultiCamVideo-Dataset.part* > MultiCamVideo-Dataset.tar.gz
138
+ tar --zstd -xvf CamCloneDataset.tar.gz
139
+ ```
140
+
141
+ - Camera Visualization
142
+ ```python
143
+ python vis_cam.py
144
+ ```
145
+
146
+ The visualization script is modified from [CameraCtrl](https://github.com/hehao13/CameraCtrl/blob/main/tools/visualize_trajectory.py), thanks for their inspiring work.
147
+
148
+ <p align="center">
149
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6530bf50f145530101ec03a2/q5whL09UsZnrtD4xO9EbR.png" alt="Example Image" width="40%">
150
+ </p>
151
+
152
+ ## Citation
153
+ If you found this dataset useful, please cite our [paper](https://arxiv.org/abs/2503.11647).
154
+ ```bibtex
155
+ @misc{bai2025recammaster,
156
+ title={ReCamMaster: Camera-Controlled Generative Rendering from A Single Video},
157
+ author={Jianhong Bai and Menghan Xia and Xiao Fu and Xintao Wang and Lianrui Mu and Jinwen Cao and Zuozhu Liu and Haoji Hu and Xiang Bai and Pengfei Wan and Di Zhang},
158
+ year={2025},
159
+ eprint={2503.11647},
160
+ archivePrefix={arXiv},
161
+ primaryClass={cs.CV},
162
+ url={https://arxiv.org/abs/2503.11647},
163
+ }
164
+ ```
165
+
166
+ ## Contact
167
+
168
+ [jianghongbai@zju.edu.cn](jianghongbai@zju.edu.cn)
169
+
170
+ # Acknowledgments
171
+ We thank Jinwen Cao, Yisong Guo, Haowen Ji, Jichao Wang, and Yi Wang from Kuaishou Technology for their invaluable help in constructing the MultiCamVideo Dataset.
vis_cam.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import numpy as np
3
+ import matplotlib as mpl
4
+ import matplotlib.pyplot as plt
5
+ from matplotlib.patches import Patch
6
+ from mpl_toolkits.mplot3d.art3d import Poly3DCollection
7
+ import json
8
+
9
+ class CameraPoseVisualizer:
10
+ def __init__(self, xlim, ylim, zlim):
11
+ self.fig = plt.figure(figsize=(18, 7))
12
+ self.ax = self.fig.add_subplot(projection='3d')
13
+ self.plotly_data = None
14
+ self.ax.set_aspect("auto")
15
+ self.ax.set_xlim(xlim)
16
+ self.ax.set_ylim(ylim)
17
+ self.ax.set_zlim(zlim)
18
+ self.ax.set_xlabel('x')
19
+ self.ax.set_ylabel('y')
20
+ self.ax.set_zlabel('z')
21
+ print('initialize camera pose visualizer')
22
+
23
+ def extrinsic2pyramid(self, extrinsic, color_map='red', hw_ratio=9/16, base_xval=1, zval=3):
24
+ vertex_std = np.array([[0, 0, 0, 1],
25
+ [base_xval, -base_xval * hw_ratio, zval, 1],
26
+ [base_xval, base_xval * hw_ratio, zval, 1],
27
+ [-base_xval, base_xval * hw_ratio, zval, 1],
28
+ [-base_xval, -base_xval * hw_ratio, zval, 1]])
29
+ vertex_transformed = vertex_std @ extrinsic.T
30
+ meshes = [[vertex_transformed[0, :-1], vertex_transformed[1][:-1], vertex_transformed[2, :-1]],
31
+ [vertex_transformed[0, :-1], vertex_transformed[2, :-1], vertex_transformed[3, :-1]],
32
+ [vertex_transformed[0, :-1], vertex_transformed[3, :-1], vertex_transformed[4, :-1]],
33
+ [vertex_transformed[0, :-1], vertex_transformed[4, :-1], vertex_transformed[1, :-1]],
34
+ [vertex_transformed[1, :-1], vertex_transformed[2, :-1], vertex_transformed[3, :-1], vertex_transformed[4, :-1]]]
35
+
36
+ color = color_map if isinstance(color_map, str) else plt.cm.rainbow(color_map)
37
+
38
+ self.ax.add_collection3d(
39
+ Poly3DCollection(meshes, facecolors=color, linewidths=0.3, edgecolors=color, alpha=0.35))
40
+
41
+ def customize_legend(self, list_label):
42
+ list_handle = []
43
+ for idx, label in enumerate(list_label):
44
+ color = plt.cm.viridis(idx / len(list_label))
45
+ patch = Patch(color=color, label=label)
46
+ list_handle.append(patch)
47
+ plt.legend(loc='right', bbox_to_anchor=(1.8, 0.5), handles=list_handle)
48
+
49
+ def colorbar(self, max_frame_length):
50
+ cmap = mpl.cm.rainbow
51
+ norm = mpl.colors.Normalize(vmin=0, vmax=max_frame_length)
52
+ self.fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), ax=self.ax, orientation='vertical', label='Frame Number')
53
+
54
+ def show(self):
55
+ plt.title('Extrinsic Parameters')
56
+ plt.savefig('extrinsic_parameters.jpg', format='jpg', dpi=300)
57
+ plt.show()
58
+
59
+
60
+ def get_args():
61
+ parser = argparse.ArgumentParser()
62
+ parser.add_argument('--pose_file_path', default='/Users/baijianhong/Documents/python_scripts/camera_extrinsics (1).json', type=str, help='the path of the pose file')
63
+ parser.add_argument('--hw_ratio', default=9/16, type=float, help='the height over width of the film plane')
64
+ parser.add_argument('--total_frame', type=int, default=81)
65
+ parser.add_argument('--stride', type=int, default=4)
66
+ parser.add_argument('--cam_idx', type=str, default="05")
67
+ parser.add_argument('--base_xval', type=float, default=0.08)
68
+ parser.add_argument('--zval', type=float, default=0.15)
69
+ parser.add_argument('--x_min', type=float, default=-2)
70
+ parser.add_argument('--x_max', type=float, default=2)
71
+ parser.add_argument('--y_min', type=float, default=-2)
72
+ parser.add_argument('--y_max', type=float, default=2)
73
+ parser.add_argument('--z_min', type=float, default=-1.)
74
+ parser.add_argument('--z_max', type=float, default=1)
75
+ return parser.parse_args()
76
+
77
+ def get_c2w(w2cs, transform_matrix, relative_c2w=True):
78
+ if relative_c2w:
79
+ target_cam_c2w = np.array([
80
+ [1, 0, 0, 0],
81
+ [0, 1, 0, 0],
82
+ [0, 0, 1, 0],
83
+ [0, 0, 0, 1]
84
+ ])
85
+ abs2rel = target_cam_c2w @ w2cs[0]
86
+ ret_poses = [target_cam_c2w, ] + [abs2rel @ np.linalg.inv(w2c) for w2c in w2cs[1:]]
87
+ else:
88
+ ret_poses = [np.linalg.inv(w2c) for w2c in w2cs]
89
+ ret_poses = [transform_matrix @ x for x in ret_poses]
90
+ return np.array(ret_poses, dtype=np.float32)
91
+
92
+ def parse_matrix(matrix_str):
93
+ rows = matrix_str.strip().split('] [')
94
+ matrix = []
95
+ for row in rows:
96
+ row = row.replace('[', '').replace(']', '')
97
+ if len((list(map(float, row.split())))) == 3:
98
+ matrix.append((list(map(float, row.split()))) +[0.])
99
+ else:
100
+ matrix.append(list(map(float, row.split())))
101
+ return np.array(matrix)
102
+
103
+ if __name__ == '__main__':
104
+ args = get_args()
105
+
106
+ with open(args.pose_file_path, 'r') as file:
107
+ data = json.load(file)
108
+ cameras = [parse_matrix(data[f"frame{i}"][f"cam{args.cam_idx}"]) for i in range(0, args.total_frame, args.stride)]
109
+ cameras = np.transpose(np.stack(cameras), (0, 2, 1))
110
+
111
+ w2cs = []
112
+ for cam in cameras:
113
+ if cam.shape[0] == 3:
114
+ cam = np.vstack((cam, np.array([[0, 0, 0, 1]])))
115
+ cam = cam[:, [1, 2, 0, 3]]
116
+ cam[:3, 1] *= -1.
117
+ w2cs.append(np.linalg.inv(cam))
118
+ transform_matrix = np.array([[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]])
119
+ c2ws = get_c2w(w2cs, transform_matrix, True)
120
+ scale = max(max(abs(c2w[:3, 3])) for c2w in c2ws)
121
+ if scale > 1e-3: # otherwise, pan or tilt
122
+ for c2w in c2ws:
123
+ c2w[:3, 3] /= scale
124
+
125
+ visualizer = CameraPoseVisualizer([args.x_min, args.x_max], [args.y_min, args.y_max], [args.z_min, args.z_max])
126
+ for frame_idx, c2w in enumerate(c2ws):
127
+ visualizer.extrinsic2pyramid(c2w, frame_idx / len(cameras), hw_ratio=args.hw_ratio, base_xval=args.base_xval,
128
+ zval=(args.zval))
129
+ visualizer.colorbar(len(cameras))
130
+ visualizer.show()