Skip to content

Commit 06f6076

Browse files
committed
add code and update README
1 parent e94b50e commit 06f6076

File tree

88 files changed

+18474
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+18474
-6
lines changed

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -198,4 +199,4 @@
198199
distributed under the License is distributed on an "AS IS" BASIS,
199200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200201
See the License for the specific language governing permissions and
201-
limitations under the License.
202+
limitations under the License.

README.md

Lines changed: 192 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,194 @@
1-
# Objects With Lighting
1+
# Objects with Lighting
2+
3+
## [Paper](https://arxiv.org/abs/2401.09126)
4+
5+
This repo is the code distribution for the _Objects with Lighting_ dataset.
6+
It contains the evaluation script (`scripts/evaluation.py`) and the tools used for building the dataset.
7+
8+
If you find the data or code useful please cite
9+
```bibtex
10+
@inproceedings{Ummenhofer2024OWL,
11+
author = {Benjamin Ummenhofer and
12+
Sanskar Agrawal and
13+
Rene Sep{\'{u}}lveda and
14+
Yixing Lao and
15+
Kai Zhang and
16+
Tianhang Cheng and
17+
Stephan R. Richter and
18+
Shenlong Wang and
19+
Germ{\'{a}}n Ros},
20+
title = {Objects With Lighting: {A} Real-World Dataset for Evaluating Reconstruction
21+
and Rendering for Object Relighting},
22+
booktitle = {3DV},
23+
publisher = {{IEEE}},
24+
year = {2024}
25+
}
26+
```
27+
28+
## Downloads
29+
30+
Please download the dataset from the current release or use the links below for the latest version. Extracting the files in the repository root will create the `dataset` directory.
31+
32+
- [objects-with-lighting-dataset-v1_1.tgz](https://github.com/isl-org/objects-with-lighting/releases/download/v1/objects-with-lighting-dataset-v1_1.tgz)
33+
- [objects-with-lighting-dataset-v1_2.tgz](https://github.com/isl-org/objects-with-lighting/releases/download/v1/objects-with-lighting-dataset-v1_2.tgz)
34+
35+
```bash
36+
wget https://github.com/isl-org/objects-with-lighting/releases/download/v1/objects-with-lighting-dataset-v1_{1,2}.tgz
37+
```
38+
39+
## Directory structure
40+
41+
```
42+
├─ calibration # Data files for calibration and generated calibration parameters
43+
├─ dataset # Contains the data meant for consumption
44+
├─ docs # Images and markdown for documentation
45+
├─ methods # Documentation and scripts for the baseline method and other state-of-the-art methods
46+
├─ scripts # This dir contains scripts for creating data and evaluation
47+
├─ utils # Utility python modules used by all scripts
48+
```
49+
50+
## Evaluation script
51+
52+
The script `scripts/evaluate.py` can be used to compute the common metrics PSNR, SSIM, LPIPS for predicted images.
53+
The results will be stored in a json file.
54+
- Supported image file formats are `.png`, `.exr`, and `.npy`.
55+
- We assume `.exr` and `.npy` files store unclipped linear images, while `.png` stores values after applying the tonemapping as used for the dataset.
56+
- For linear images the evaluation script computes the optimal exposure value minimizing the least squares error before computing the error metrics.
57+
- The predicted images have to be stored with the same folder structure as the dataset and should be named `pr_image_xxxx.{npy,exr,png}`.
58+
59+
The script can be invoked as
60+
```bash
61+
python scripts/evaluate.py -p path/to/predictions results.json
62+
```
63+
64+
## Dataset format
65+
66+
```
67+
├─ dataset
68+
├─ object_name # The dataset is grouped into objects
69+
├─ test # Files in the test dir are meant for evaluation
70+
├─ inputs # The inputs dir contains all files that are allowed to be used by the methods
71+
```
72+
73+
Each of the test directories contains the following data.
74+
75+
| File | Description |
76+
| --- | --- |
77+
| `inputs/` | This directory contains all data for reconstructing the object. For a fair evaluation only data inside this folder may be used. |
78+
| `inputs/image_xxxx.png` | Image files with 8-bit RGB images after tonemapping. |
79+
| `inputs/camera_xxxx.txt` | Camera parameters for the corresponding image file. |
80+
| `inputs/mask_xxxx.png` | An approximate mask for methods that require it. |
81+
| `inputs/exposure.txt` | The exposure value that has been used in the tonemapping. |
82+
| `inputs/object_bounding_box.txt` | The axis aligned bounding box of the object. This box is not a tight bounding box. |
83+
| `env.hdr` | An equirectangular image of the environment where the input images have been taken. This image is provided for debugging purposes and should not be used for reconstruction or evaluation. |
84+
| `env_512_rotated.hdr` | This environment map is downscaled to 1024x512 and has been rotated with the 'world_to_env' transform for easier usage. This image is provided for debugging purposes and should not be used for reconstruction or evaluation. |
85+
| `world_to_env.txt` | The 4x4 world to camera transform that transforms a point into the coordinate system of the equirectangular image 'env.hdr'. |
86+
| `gt_image_xxxx.png` | A ground truth image used in evaluation. |
87+
| `gt_camera_xxxx.txt` | The corresponding camera parameters for a ground truth image. |
88+
| `gt_mask_xxxx.png` | The mask used for evaluation. Valid pixels are marked with the value 255. |
89+
| `gt_exposure_xxxx.txt` | The exposure used in the tonemapping of the corresponding ground truth image. |
90+
| `gt_env_xxxx.hdr` | An equirectangular image of the environment where the corresponding ground truth image was taken. |
91+
| `gt_world_to_env_xxxx.txt` | The 4x4 world to camera transform that transforms a point into the coordinate system of the equirectangular image 'gt_env_xxxx.hdr'. |
92+
| `gt_env_512_rotated_xxxx.hdr` | This environment map is downscaled to 1024x512 and has been rotated with the 'world_to_env' transform for easier usage. |
93+
94+
### Tone mapping
95+
96+
We generate the tonemapped 8-bit images with the following function.
97+
98+
$$ y = 255 (x 2^\text{exposure})^\gamma $$
99+
100+
We use $\gamma=1/2.2$ for all images in the dataset.
101+
The exposure values used may differ for input and test images. The exposure values can be found in the corresponding `exposure.txt` files.
102+
The values $y$ are clipped to the range 0 to 255.
103+
104+
### `.txt` files
105+
106+
#### Camera parameters
107+
The camera parameters are defined by the intrinsic matrix $K$, and the extrinsics $R,t$.
108+
We can project a 3D point $X$ to the camera coordinate system with
109+
110+
$$ x = K(R X + t) $$
111+
112+
Note that $x$ is in homogeneous coordinates.
113+
The camera parameters are stored in the `*camera_xxx.txt` files in the following format.
114+
```
115+
k11 k12 k13
116+
k21 k22 k23
117+
k31 k32 k33
118+
r11 r12 r13
119+
r21 r22 r23
120+
r31 r32 r33
121+
tx ty tz
122+
width height channels
123+
```
124+
125+
The following snippet can be used to parse the file with numpy.
126+
```python
127+
params = np.loadtxt('path/to/camera_xxxx.txt')
128+
K, R, t, (width, height, channels) = params[:3], params[3:6], params[6], params[7].astype(int)
129+
```
130+
131+
#### Object bounding box
132+
The `object_bounding_box.txt` files describe an axis aligned bounding box.
133+
The format used in the text file is
134+
```
135+
xmin xmax ymin ymax zmin zmax
136+
```
137+
138+
#### World to environment map transforms
139+
The `*world_to_env*.txt` files describe a transformation from the world coordinate system into the coordinate system of the omnidirectional camera that captures the environment.
140+
The text file stores a 4x4 transformation matrix and transforms a homogeneous 3D point to the camera coordinate system.
141+
Usually we make the assumption that the environment is infinitely far away from the object and we are only interested in directions.
142+
In this case we only the rotational part of the 4x4 matrix in the upper left corner is of interest.
143+
With $R$ as the rotation and $t$ as the translation the format of the text file is
144+
```
145+
r11 r12 r13 tx
146+
r21 r22 r23 ty
147+
r31 r32 r33 tz
148+
0 0 0 1
149+
```
150+
151+
#### Exposure
152+
The exposure values are single scalars stored in the `*exposure*.txt` files.
153+
154+
## Coordinate systems
155+
156+
The dataset uses right-handed coordinate systems.
157+
158+
### Cameras
159+
Cameras look in positive z-direction.
160+
The intrinsic and extrinsic camera parameters can be used to directly project a 3D point $X$ to image space coordinates.
161+
162+
$$ x = K(R X + t) $$
163+
164+
$x$ is a homogeneous point describing a position in the image.
165+
166+
167+
### Images
168+
The x-axis for images points to the right and the y-axis points down following the memory order.
169+
The coordinates $(x,y)$ of the top left corner are $(0,0)$.
170+
The center of the first pixel is at $(0.5, 0,5)$.
171+
The bottom right corner for an image with witdth $w$ and height $h$ is at $(w, h)$.
172+
173+
174+
### Environment maps
175+
Environment maps are stored as equirectangular images.
176+
We use a normalized coordinate system similar to regular images.
177+
The u-axis points to the right and the v-axis points down following the memory order.
178+
The coordinates $(u,v)$ of the top left corner are $(0,0)$.
179+
The bottom right corner is at $(1, 1)$ irrespective of the size of the environment map.
180+
This corresponds to the texture coordinate convention used by DirectX.
181+
182+
![Equirectangular uv coordinates](docs/images/equirect_coords1.png)
183+
184+
Directions map to the equirectangular image as shown in the image below.
185+
The direction +Z $(0,0,1)$ maps to the upper border of the environment map and -Z $(0,0,-1)$ to the lower border.
186+
+X $(1,0,0)$ maps to the center and -X $(-1,0,0)$ maps to the vertically centered point on the right and left border.
187+
+Y $(0,1,0)$ and -Y $(0,-1,0)$ map to the uv coordinates $(0.25,0.5)$ and $(0.75,0.5)$ respectively.
188+
189+
![Equirectangular xyz directions](docs/images/equirect_coords2.png)
190+
191+
The following shows the left half of the environment map mapped to a sphere.
192+
![xyz directions with sphere mapped equirectangular image](docs/images/sphere_directions.png)
2193

3-
This is the repository for the paper _Objects With Lighting: A Real-World Dataset for Evaluating Reconstruction and Rendering for Object Relighting_.
4194

5-
## TODOs
6-
- [ ] Code for evaluation and dataset creation
7-
- [ ] Upload dataset
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.395296136706085030e-02 1.296499703681861047e-03 1.873509458958052859e-04
2+
-3.780099064391110805e-03 1.124387368021347554e-02 9.833983419795452874e-04
3+
1.974805264306137790e-03 -1.998499422070082866e-04 1.065255577973303613e-02
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.537416332420910858e-01 1.417908997397511646e-02 1.341531951197547350e-03
2+
-4.326455047072624849e-02 1.229526531999921707e-01 7.063342058748769969e-03
3+
2.217579919984779754e-02 -3.933207846438259089e-03 1.209818695892059953e-01
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6.936005635577023598e-03 6.069567868976031427e-04 5.363830447564449600e-05
2+
-1.918221804478201838e-03 5.645104132183957103e-03 5.525334345413131058e-04
3+
9.269149543259147701e-04 -2.245523645808016793e-04 5.167599107275024084e-03
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4.503985349671151689e-03 4.117778554999114698e-04 4.807029340357996794e-05
2+
-1.266068589016416121e-03 3.636929855187648677e-03 3.342844793383778143e-04
3+
5.731625967925495137e-04 -1.283951704963701482e-04 3.421848290720163124e-03
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
6.289920340398877374e-02 5.989769682043516973e-03 8.111168215522625985e-04
2+
-1.730149418944995632e-02 4.990574939938621779e-02 4.010673489420267523e-03
3+
9.454023743463390445e-03 -9.412456589485911724e-04 4.852574589143844597e-02
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2.095289375202849438e-03 1.991256304950709221e-04 3.179490255994356585e-05
2+
-5.837361111847496221e-04 1.675642306626312856e-03 1.516999247522994067e-04
3+
3.008858817500313643e-04 -3.593445281422978199e-05 1.586576156932782439e-03
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2.807759482776742838e-02 2.513098971642670036e-03 2.823983904470497483e-04
2+
-7.867633287587591506e-03 2.262510365043172642e-02 1.982277948859361913e-03
3+
4.033590404060006900e-03 -6.398339957334430979e-04 2.133600414741858298e-02
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.000000000000000021e-02 0.000000000000000000e+00 0.000000000000000000e+00
2+
0.000000000000000000e+00 1.000000000000000021e-02 0.000000000000000000e+00
3+
0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000021e-02

0 commit comments

Comments
 (0)