mesh-to-point 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. mesh_to_point-0.1/.github/workflows/python-publish.yml +68 -0
  2. mesh_to_point-0.1/.gitignore +207 -0
  3. mesh_to_point-0.1/.pre-commit-config.yaml +12 -0
  4. mesh_to_point-0.1/.python-version +1 -0
  5. mesh_to_point-0.1/LICENSE +21 -0
  6. mesh_to_point-0.1/PKG-INFO +198 -0
  7. mesh_to_point-0.1/README.md +174 -0
  8. mesh_to_point-0.1/assets/cameras.json +851 -0
  9. mesh_to_point-0.1/assets/lights.json +13 -0
  10. mesh_to_point-0.1/assets/suzanne.glb +0 -0
  11. mesh_to_point-0.1/mesh_to_point/__init__.py +14 -0
  12. mesh_to_point-0.1/mesh_to_point/camera.py +263 -0
  13. mesh_to_point-0.1/mesh_to_point/io/__init__.py +0 -0
  14. mesh_to_point-0.1/mesh_to_point/io/data.py +59 -0
  15. mesh_to_point-0.1/mesh_to_point/lights.py +104 -0
  16. mesh_to_point-0.1/mesh_to_point/main.py +145 -0
  17. mesh_to_point-0.1/mesh_to_point/pointcloud/__init__.py +5 -0
  18. mesh_to_point-0.1/mesh_to_point/pointcloud/misc.py +162 -0
  19. mesh_to_point-0.1/mesh_to_point/pointcloud/multiview.py +107 -0
  20. mesh_to_point-0.1/mesh_to_point/render/__init__.py +8 -0
  21. mesh_to_point-0.1/mesh_to_point/render/compositor.py +44 -0
  22. mesh_to_point-0.1/mesh_to_point/render/config.py +21 -0
  23. mesh_to_point-0.1/mesh_to_point/render/render.py +100 -0
  24. mesh_to_point-0.1/mesh_to_point/render/scene.py +251 -0
  25. mesh_to_point-0.1/mesh_to_point/utils.py +98 -0
  26. mesh_to_point-0.1/mesh_to_point.egg-info/PKG-INFO +198 -0
  27. mesh_to_point-0.1/mesh_to_point.egg-info/SOURCES.txt +34 -0
  28. mesh_to_point-0.1/mesh_to_point.egg-info/dependency_links.txt +1 -0
  29. mesh_to_point-0.1/mesh_to_point.egg-info/entry_points.txt +2 -0
  30. mesh_to_point-0.1/mesh_to_point.egg-info/requires.txt +13 -0
  31. mesh_to_point-0.1/mesh_to_point.egg-info/scm_file_list.json +30 -0
  32. mesh_to_point-0.1/mesh_to_point.egg-info/scm_version.json +8 -0
  33. mesh_to_point-0.1/mesh_to_point.egg-info/top_level.txt +1 -0
  34. mesh_to_point-0.1/pyproject.toml +44 -0
  35. mesh_to_point-0.1/setup.cfg +4 -0
  36. mesh_to_point-0.1/uv.lock +802 -0
@@ -0,0 +1,68 @@
1
+ # This workflow will upload a Python Package to PyPI when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ push:
13
+ tags:
14
+ - 'v*'
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ release-build:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: actions/setup-python@v5
27
+
28
+ - name: Build release distributions
29
+ run: |
30
+ python -m pip install build
31
+ python -m build
32
+
33
+ - name: Upload distributions
34
+ uses: actions/upload-artifact@v4
35
+ with:
36
+ name: release-dists
37
+ path: dist/
38
+
39
+ pypi-publish:
40
+ runs-on: ubuntu-latest
41
+ needs:
42
+ - release-build
43
+ permissions:
44
+ # IMPORTANT: this permission is mandatory for trusted publishing
45
+ id-token: write
46
+
47
+ # Dedicated environments with protections for publishing are strongly recommended.
48
+ # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
49
+ environment:
50
+ name: pypi
51
+ # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
52
+ url: https://pypi.org/p/mesh-to-point
53
+ #
54
+ # ALTERNATIVE: if your GitHub Release name is the PyPI project version string
55
+ # ALTERNATIVE: exactly, uncomment the following line instead:
56
+ # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
57
+
58
+ steps:
59
+ - name: Retrieve release distributions
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ name: release-dists
63
+ path: dist/
64
+
65
+ - name: Publish release distributions to PyPI
66
+ uses: pypa/gh-action-pypi-publish@release/v1
67
+ with:
68
+ packages-dir: dist/
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,12 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v2.3.0
4
+ hooks:
5
+ - id: check-yaml
6
+ - id: end-of-file-fixer
7
+ - id: trailing-whitespace
8
+ - repo: https://github.com/psf/black-pre-commit-mirror
9
+ rev: 26.5.1
10
+ hooks:
11
+ - id: black
12
+ language_version: python3.13
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Giorgio Mariani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,198 @@
1
+ Metadata-Version: 2.4
2
+ Name: mesh-to-point
3
+ Version: 0.1
4
+ Summary: RGB point-cloud generation from meshes.
5
+ Project-URL: Homepage, https://github.com/giorgio-mariani/mesh-to-point
6
+ Project-URL: Repository, https://github.com/giorgio-mariani/mesh-to-point
7
+ Project-URL: Issues, https://github.com/giorgio-mariani/mesh-to-point/issues
8
+ Requires-Python: >=3.13
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: numpy
12
+ Requires-Dist: scipy
13
+ Requires-Dist: click
14
+ Requires-Dist: bpy
15
+ Requires-Dist: mathutils>=5.1.0
16
+ Requires-Dist: openexr>=3.4.12
17
+ Requires-Dist: pillow>=12.2.0
18
+ Requires-Dist: scikit-learn>=1.9.0
19
+ Requires-Dist: plotly>=6.8.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pre-commit; extra == "dev"
22
+ Requires-Dist: pytest; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # Mesh‑to‑Point
26
+
27
+ ## Overview
28
+ `mesh-to-point` is a lightweight Python library that converts 3D meshes into dense RGB point clouds.
29
+
30
+ It is built on top of **NumPy**, and **scikit‑learn** for data handling, and uses **Blender** (via the `bpy` API) for rendering synthetic views.
31
+
32
+ The project ships a small command‑line interface that can render a mesh from multiple camera viewpoints and generate a point cloud from the rendered RGB-D images.
33
+
34
+
35
+ ## Installation
36
+ The package is published on PyPI and can be installed with `pip`:
37
+
38
+ ```bash
39
+ pip install mesh-to-point
40
+ ```
41
+
42
+ Note that this will also install a headless version of blender 5.0 to be used for rendering.
43
+
44
+ **Development install.** If you want to contribute or run the test suite, install the optional development dependencies:
45
+
46
+ ```bash
47
+ pip install .[dev]
48
+ pre-commit install
49
+ ```
50
+
51
+ ## Quick start
52
+ ### Command Line Interface
53
+ ```bash
54
+ # Render a mesh and generate a point cloud with 8192 points
55
+ mesh-to-point --mesh assets/suzanne.glb \
56
+ --cameras assets/cameras.json \
57
+ --lights assets/lights.json \
58
+ --output-dir output \
59
+ --points 8192 \
60
+ --html
61
+ ```
62
+
63
+ The command will:
64
+
65
+ * Render the mesh from the specified camera viewpoints using Blender Cycles.
66
+ * Store the rendered RGB-D images in the chosen output directory.
67
+ * Build a dense RGB point cloud from the rendered images.
68
+ * Write the point cloud as a NumPy ``.npy`` array or (optionally) as a text ``.ply`` file.
69
+ * Optionally generate an interactive Plotly HTML visualization of the point cloud.
70
+
71
+ **Output directory.** The output directory contains the rendered images, camera transforms, point cloud data, and an optional HTML visualization. Images are stored under ``<output_dir>/images`` as ``<index>_rgb.png`` and ``<index>_depth.exr``. Extrinsic and intrinsic camera parameters are saved in ``transforms.json``. The point cloud is written as ``pointcloud.npy`` (or ``pointcloud.ply`` if ``--as-ply`` is used). If ``--html`` is enabled, an interactive Plotly visualization is generated as ``pointcloud.html``.
72
+
73
+ Overview of output directory structure:
74
+
75
+ ```
76
+ <output-dir>
77
+ |- images/
78
+ | |- 0000_depth.exr
79
+ | |- 0000_rgb.png
80
+ | | ...
81
+ | |- <num-views>_rgb.png
82
+ |
83
+ |- transforms.json # Camera parameters
84
+ |- pointcloud.npy # Point cloud data (`pointcloud.ply` if --as-ply is used)
85
+ |- pointcloud.html # Point cloud visualization script (only if --html is used)
86
+ ```
87
+
88
+ **Configuration files.** Lighting and camera information are provided to the CLI through JSON files; These describe the extrinsic camera poses and the intrinsic camera parameters, together with the amount of point lights in the scene and the background light color and intensity. If these are not provided, `mesh-to-point` will default to [[assets/cameras.json]] and [[assets/lights.json]] for cameras and lights respectively.
89
+ - *Camera configuration.* The file should follow the format used by the `mesh_to_point.read_camera_config` helper. It contains intrinsic parameters (focal length, principal point, image size) and a list of extrinsic pose matrices.
90
+ - *Lights configuration.* It specifies an optional environment color and intensity, together with a list of point lights. Each light has an origin, color, intensity, and a flag for shadows. The file is parsed by `mesh_to_point.read_light_config`, take a look at the function docstring for a more in-depth description.
91
+
92
+ > **NOTE ⚠**
93
+ When loaded into the scene, the input geometry mesh is automatically normalized to match the size of a unit cube, and placed at the origin. Camera and light parameters should take this into consideration.
94
+
95
+
96
+ Below are two minimal examples; one for a camera configuration file and another for a light configuration file.
97
+
98
+ *Minimal cameras config file:*
99
+ ```json
100
+ {
101
+ "camera_model": "PINHOLE", # Only PINHOLE or SIMPLE_PINHOLE are supported
102
+ "fl_x": 1422.22,
103
+ "fl_y": 1422.22,
104
+ "cx": 512,
105
+ "cy": 512,
106
+ "h": 1024,
107
+ "w": 1024,
108
+ "frames": [
109
+ {
110
+ "transform_matrix": [ # Camera-to-world transformation matrix
111
+ [1, 0, 0, 0],
112
+ [0, 1, 0, 0],
113
+ [0, 0, 1, 0],
114
+ [0, 0, 0, 1]
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ```
120
+
121
+ *Minimal lights config file:*
122
+ ```json
123
+ lights.json
124
+ {
125
+ "environment_color": [1, 1, 1, 1], # RGB-Alpha
126
+ "environment_intensity": 0.5, # Between [0.0, 1.0]
127
+ "lights": [
128
+ {
129
+ "origin": [0, 0, 2],
130
+ "color": [1, 1, 1],
131
+ "intensity": 10, # Between [0.0, +inf)
132
+ "use_shadows": true
133
+ }
134
+ ]
135
+ }
136
+ ```
137
+
138
+ Examples for both configuration file types can found in the `./assets` directory.
139
+
140
+ ### API reference
141
+ The library exposes a small set of public functions that can be used programmatically:
142
+
143
+ * ``mesh_to_point.render_dataset`` – Render a dataset of RGB-D images from a mesh.
144
+ * ``mesh_to_point.create_pointcloud_from_multiview`` – Build a point cloud from a directory of rendered RGB-D images.
145
+ * ``mesh_to_point.create_pointcloud_figure`` – Create a Plotly figure for visualising a point cloud.
146
+
147
+ #### Examples
148
+ If necessary, it is possible to directly invoke the python rendering function instead of using the [command-line interface](#command-line-interface). For example, by calling the `render_dataset` function directly:
149
+ ```python
150
+ from mesh_to_point import render_dataset, GlobalConfig, read_camera_config, read_light_config
151
+
152
+ # Load camera and lights configuration
153
+ camera, camera_poses = read_camera_config("path-to-camera-cfg")
154
+ background_light, lights = read_light_config("path-to-light-cfg")
155
+
156
+ # Setup rendering config
157
+ cfg = GlobalConfig(
158
+ mesh="path-to-mesh",
159
+ output_dir="output",
160
+ lights=lights,
161
+ background_light=background_light,
162
+ camera=camera,
163
+ camera_poses=camera_poses,
164
+ use_gpu=True,
165
+ samples=16,
166
+ depth_pass=True,
167
+ )
168
+
169
+ # Render views
170
+ render_dataset(cfg)
171
+ ```
172
+ Once the multiple views have been rendered, it is possible to construct a point cloud from them by
173
+ using the `create_pointcloud_from_multiview` utility:
174
+ ```python
175
+ from mesh_to_point import create_pointcloud_from_multiview
176
+
177
+ # Path to the folder that contains the rendered images.
178
+ # The folder must follow the CLI output layout:
179
+ # <output_dir>/images/<idx>_rgb.png
180
+ # <output_dir>/images/<idx>_depth.exr
181
+ render_dir = "output"
182
+ pointcloud = create_pointcloud_from_multiview(
183
+ render_dir, num_points=8192,
184
+ )
185
+
186
+ print(f"Point cloud shape: {pointcloud.shape}") # (8192, 6)
187
+
188
+ ```
189
+ Finally, it is also possible to produce an HTML/javascript file to visualize the point cloud on a browser of your choice.
190
+ ```python
191
+ from mesh_to_point import create_pointcloud_figure
192
+ # Visualise the point cloud with Plotly.
193
+ fig = create_pointcloud_figure(pointcloud)
194
+ fig.write_html("pointcloud.html") # open in a browser to visualize the point cloud
195
+ ```
196
+
197
+ ## License
198
+ MIT – see the [LICENSE](LICENSE) file.
@@ -0,0 +1,174 @@
1
+ # Mesh‑to‑Point
2
+
3
+ ## Overview
4
+ `mesh-to-point` is a lightweight Python library that converts 3D meshes into dense RGB point clouds.
5
+
6
+ It is built on top of **NumPy**, and **scikit‑learn** for data handling, and uses **Blender** (via the `bpy` API) for rendering synthetic views.
7
+
8
+ The project ships a small command‑line interface that can render a mesh from multiple camera viewpoints and generate a point cloud from the rendered RGB-D images.
9
+
10
+
11
+ ## Installation
12
+ The package is published on PyPI and can be installed with `pip`:
13
+
14
+ ```bash
15
+ pip install mesh-to-point
16
+ ```
17
+
18
+ Note that this will also install a headless version of blender 5.0 to be used for rendering.
19
+
20
+ **Development install.** If you want to contribute or run the test suite, install the optional development dependencies:
21
+
22
+ ```bash
23
+ pip install .[dev]
24
+ pre-commit install
25
+ ```
26
+
27
+ ## Quick start
28
+ ### Command Line Interface
29
+ ```bash
30
+ # Render a mesh and generate a point cloud with 8192 points
31
+ mesh-to-point --mesh assets/suzanne.glb \
32
+ --cameras assets/cameras.json \
33
+ --lights assets/lights.json \
34
+ --output-dir output \
35
+ --points 8192 \
36
+ --html
37
+ ```
38
+
39
+ The command will:
40
+
41
+ * Render the mesh from the specified camera viewpoints using Blender Cycles.
42
+ * Store the rendered RGB-D images in the chosen output directory.
43
+ * Build a dense RGB point cloud from the rendered images.
44
+ * Write the point cloud as a NumPy ``.npy`` array or (optionally) as a text ``.ply`` file.
45
+ * Optionally generate an interactive Plotly HTML visualization of the point cloud.
46
+
47
+ **Output directory.** The output directory contains the rendered images, camera transforms, point cloud data, and an optional HTML visualization. Images are stored under ``<output_dir>/images`` as ``<index>_rgb.png`` and ``<index>_depth.exr``. Extrinsic and intrinsic camera parameters are saved in ``transforms.json``. The point cloud is written as ``pointcloud.npy`` (or ``pointcloud.ply`` if ``--as-ply`` is used). If ``--html`` is enabled, an interactive Plotly visualization is generated as ``pointcloud.html``.
48
+
49
+ Overview of output directory structure:
50
+
51
+ ```
52
+ <output-dir>
53
+ |- images/
54
+ | |- 0000_depth.exr
55
+ | |- 0000_rgb.png
56
+ | | ...
57
+ | |- <num-views>_rgb.png
58
+ |
59
+ |- transforms.json # Camera parameters
60
+ |- pointcloud.npy # Point cloud data (`pointcloud.ply` if --as-ply is used)
61
+ |- pointcloud.html # Point cloud visualization script (only if --html is used)
62
+ ```
63
+
64
+ **Configuration files.** Lighting and camera information are provided to the CLI through JSON files; These describe the extrinsic camera poses and the intrinsic camera parameters, together with the amount of point lights in the scene and the background light color and intensity. If these are not provided, `mesh-to-point` will default to [[assets/cameras.json]] and [[assets/lights.json]] for cameras and lights respectively.
65
+ - *Camera configuration.* The file should follow the format used by the `mesh_to_point.read_camera_config` helper. It contains intrinsic parameters (focal length, principal point, image size) and a list of extrinsic pose matrices.
66
+ - *Lights configuration.* It specifies an optional environment color and intensity, together with a list of point lights. Each light has an origin, color, intensity, and a flag for shadows. The file is parsed by `mesh_to_point.read_light_config`, take a look at the function docstring for a more in-depth description.
67
+
68
+ > **NOTE ⚠**
69
+ When loaded into the scene, the input geometry mesh is automatically normalized to match the size of a unit cube, and placed at the origin. Camera and light parameters should take this into consideration.
70
+
71
+
72
+ Below are two minimal examples; one for a camera configuration file and another for a light configuration file.
73
+
74
+ *Minimal cameras config file:*
75
+ ```json
76
+ {
77
+ "camera_model": "PINHOLE", # Only PINHOLE or SIMPLE_PINHOLE are supported
78
+ "fl_x": 1422.22,
79
+ "fl_y": 1422.22,
80
+ "cx": 512,
81
+ "cy": 512,
82
+ "h": 1024,
83
+ "w": 1024,
84
+ "frames": [
85
+ {
86
+ "transform_matrix": [ # Camera-to-world transformation matrix
87
+ [1, 0, 0, 0],
88
+ [0, 1, 0, 0],
89
+ [0, 0, 1, 0],
90
+ [0, 0, 0, 1]
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+ ```
96
+
97
+ *Minimal lights config file:*
98
+ ```json
99
+ lights.json
100
+ {
101
+ "environment_color": [1, 1, 1, 1], # RGB-Alpha
102
+ "environment_intensity": 0.5, # Between [0.0, 1.0]
103
+ "lights": [
104
+ {
105
+ "origin": [0, 0, 2],
106
+ "color": [1, 1, 1],
107
+ "intensity": 10, # Between [0.0, +inf)
108
+ "use_shadows": true
109
+ }
110
+ ]
111
+ }
112
+ ```
113
+
114
+ Examples for both configuration file types can found in the `./assets` directory.
115
+
116
+ ### API reference
117
+ The library exposes a small set of public functions that can be used programmatically:
118
+
119
+ * ``mesh_to_point.render_dataset`` – Render a dataset of RGB-D images from a mesh.
120
+ * ``mesh_to_point.create_pointcloud_from_multiview`` – Build a point cloud from a directory of rendered RGB-D images.
121
+ * ``mesh_to_point.create_pointcloud_figure`` – Create a Plotly figure for visualising a point cloud.
122
+
123
+ #### Examples
124
+ If necessary, it is possible to directly invoke the python rendering function instead of using the [command-line interface](#command-line-interface). For example, by calling the `render_dataset` function directly:
125
+ ```python
126
+ from mesh_to_point import render_dataset, GlobalConfig, read_camera_config, read_light_config
127
+
128
+ # Load camera and lights configuration
129
+ camera, camera_poses = read_camera_config("path-to-camera-cfg")
130
+ background_light, lights = read_light_config("path-to-light-cfg")
131
+
132
+ # Setup rendering config
133
+ cfg = GlobalConfig(
134
+ mesh="path-to-mesh",
135
+ output_dir="output",
136
+ lights=lights,
137
+ background_light=background_light,
138
+ camera=camera,
139
+ camera_poses=camera_poses,
140
+ use_gpu=True,
141
+ samples=16,
142
+ depth_pass=True,
143
+ )
144
+
145
+ # Render views
146
+ render_dataset(cfg)
147
+ ```
148
+ Once the multiple views have been rendered, it is possible to construct a point cloud from them by
149
+ using the `create_pointcloud_from_multiview` utility:
150
+ ```python
151
+ from mesh_to_point import create_pointcloud_from_multiview
152
+
153
+ # Path to the folder that contains the rendered images.
154
+ # The folder must follow the CLI output layout:
155
+ # <output_dir>/images/<idx>_rgb.png
156
+ # <output_dir>/images/<idx>_depth.exr
157
+ render_dir = "output"
158
+ pointcloud = create_pointcloud_from_multiview(
159
+ render_dir, num_points=8192,
160
+ )
161
+
162
+ print(f"Point cloud shape: {pointcloud.shape}") # (8192, 6)
163
+
164
+ ```
165
+ Finally, it is also possible to produce an HTML/javascript file to visualize the point cloud on a browser of your choice.
166
+ ```python
167
+ from mesh_to_point import create_pointcloud_figure
168
+ # Visualise the point cloud with Plotly.
169
+ fig = create_pointcloud_figure(pointcloud)
170
+ fig.write_html("pointcloud.html") # open in a browser to visualize the point cloud
171
+ ```
172
+
173
+ ## License
174
+ MIT – see the [LICENSE](LICENSE) file.