Skip to content

Commit a51cf8d

Browse files
committed
feat(examples): added README with example images
1 parent 5e0812d commit a51cf8d

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

examples/advanced/stereo_matching_with_projector/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
1-
# Stereo Matching
2-
![](../../../images/stereo_matching_stereo_pair.jpg)
3-
![](../../../images/stereo_matching_stereo_depth.jpg)
1+
# Stereo Matching with Random Pattern Projector
2+
![](../../../images/stereo_with_projector.png)
43

5-
In the first row we can see the rendered stereo RGB images, left and right respectively, and beneath them we can view
6-
the computed depth image using stereo matching. Note that due to a high discrepancy between the TV and the rest
7-
of the rendered scene, the visualization is not descriptive enough. This discrepancy or high depth values at the TV
8-
is due to a lack of gradient or useful features for stereo matching in this area. However, the depth values in other
9-
areas are consistent and close to the rendered depth images.
4+
On the left side we can see the rendered RGB image (right) without a pattern and the corresponding stereo depth estimation on the bottom.
5+
On the right side we can see the rendered RGB image (right) with a projected random pattern adding 25600 points to the image and the corresponding stereo depth estimation on the bottom.
6+
Adding a random pattern to the image increases available features for the stereo matching algorithm, making it easier to discern small details, such as the chair's arm rest.
7+
Furthermore, the added random pattern is projected through a SPOT light source in blender, which loses intensity the further away from the source it gets.
108

119
## Usage
1210

1311
Execute in the BlenderProc main directory:
1412

1513
```
16-
blenderproc run examples/advanced/stereo_matching/main.py <path to cam_pose file> <path to house.json> examples/advanced/stereo_matching/output
14+
blenderproc run examples/advanced/stereo_matching_with_projector/main.py <path to cam_pose file> <path to house.json> <path to projector image> examples/advanced/stereo_matching/output
1715
```
1816

19-
* `examples/advanced/stereo_matching/main.py`: path to the main python file to run.
17+
* `examples/advanced/stereo_matching_with_projector/main.py`: path to the main python file to run.
2018
* `<path to cam_pose file>`: Should point to a file which describes one camera pose per line (here the output of `scn2cam` from the `SUNCGToolbox` can be used).
2119
* `<path to house.json>`: Path to the house.json file of the SUNCG scene you want to render. Which should be either located inside the SUNCG directory, or the SUNCG directory path should be added to the config file.
22-
* `examples/advanced/stereo_matching/output`: path to the output directory.
20+
* `<path to projector image>`: Path to image to be projected onto scene. Examples of random patterns are available in [/patterns](examples/advanced/stereo_matching_with_projector/patterns)
21+
* `examples/advanced/stereo_matching_with_projector/output`: path to the output directory.
2322

2423
## Visualizaton
2524
Visualize the generated data:
2625
```
27-
blenderproc vis hdf5 examples/advanced/stereo_matching/output/1.hdf5
26+
blenderproc vis hdf5 examples/advanced/stereo_matching_with_projector/output/0.hdf5
2827
```
2928

3029
## Implementation
3130

31+
```python
32+
# Define a new light source and set it as projector
33+
light = bproc.types.Light()
34+
light.set_type('SPOT')
35+
light.set_energy(3000)
36+
light.setup_as_projector(args.projector)
37+
```
38+
Here we setup the projector:
39+
* Setting the energy of the light source
40+
* Using the spot light as projector for specified image file `args.projector`:
41+
* Set projector location to camera via `COPY TRANSFORMS`
42+
* Link image as texture
43+
> for further details see implementation at [blenderproc/python/types/LightUtility.py](blenderproc/python/types/LightUtility.py)
44+
3245
```python
3346
# Enable stereo mode and set baseline
3447
bproc.camera.set_stereo_parameters(interocular_distance=0.05, convergence_mode="PARALLEL")

examples/advanced/stereo_matching_with_projector/config.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Args: <cam_file> <obj_file> <output_dir>
1+
# Args: <cam_file> <obj_file> <pattern_path> <output_dir>
22
{
33
"version": 3,
44
"setup": {
@@ -17,7 +17,7 @@
1717
"module": "main.Initializer",
1818
"config": {
1919
"global": {
20-
"output_dir": "<args:2>"
20+
"output_dir": "<args:3>"
2121
}
2222
}
2323
},
@@ -48,6 +48,19 @@
4848
},
4949
}
5050
},
51+
{ # Projector Light (needs to be after camera loader)
52+
"module": "lighting.LightLoader",
53+
"config": {
54+
"lights": [
55+
{
56+
"type": "SPOT",
57+
"energy": 3000,
58+
"use_projector": True,
59+
"path": "<args:2>"
60+
}
61+
]
62+
}
63+
},
5164
{
5265
"module": "lighting.SuncgLighting",
5366
"config": {}

examples/advanced/stereo_matching_with_projector/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# Enable stereo mode and set baseline
2727
bproc.camera.set_stereo_parameters(interocular_distance=0.05, convergence_mode="PARALLEL", convergence_distance=0.00001)
2828

29-
# define a new light and set it as projector
29+
# Define a new light source and set it as projector
3030
light = bproc.types.Light()
3131
light.set_type('SPOT')
3232
light.set_energy(3000)

images/stereo_with_projector.png

7.49 MB
Loading

0 commit comments

Comments
 (0)