|
1 | | -# Stereo Matching |
2 | | - |
3 | | - |
| 1 | +# Stereo Matching with Random Pattern Projector |
| 2 | + |
4 | 3 |
|
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. |
10 | 8 |
|
11 | 9 | ## Usage |
12 | 10 |
|
13 | 11 | Execute in the BlenderProc main directory: |
14 | 12 |
|
15 | 13 | ``` |
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 |
17 | 15 | ``` |
18 | 16 |
|
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. |
20 | 18 | * `<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). |
21 | 19 | * `<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. |
23 | 22 |
|
24 | 23 | ## Visualizaton |
25 | 24 | Visualize the generated data: |
26 | 25 | ``` |
27 | | -blenderproc vis hdf5 examples/advanced/stereo_matching/output/1.hdf5 |
| 26 | +blenderproc vis hdf5 examples/advanced/stereo_matching_with_projector/output/0.hdf5 |
28 | 27 | ``` |
29 | 28 |
|
30 | 29 | ## Implementation |
31 | 30 |
|
| 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 | +
|
32 | 45 | ```python |
33 | 46 | # Enable stereo mode and set baseline |
34 | 47 | bproc.camera.set_stereo_parameters(interocular_distance=0.05, convergence_mode="PARALLEL") |
|
0 commit comments