Fast depthmap generation using headless rendering
Project description
mesh2depth_gpu
Fast depthmap generation using PyOpenGL.
Inspired by the CPU-only mesh-to-depth package, this project aims to generate depth data from 3D triangular meshes in Python scripts while leveraging GPU-acceleration.
On a Linux system, mesh2depth_gpu supports EGL headless rendering, allowing it to be used without any display device.
Installation
pip install mesh2depth_gpu
Example
import numpy as np
import mesh2depth_gpu as m2d
# camera parameters, type1
# same as https://github.com/daeyun/mesh-to-depth except for the 'is_depth' option.
param1 = {
"cam_pos": [1.0, 1.0, 1.0],
"cam_lookat": [0.0, 0.0, 0.0],
"cam_up": [0.0, 1.0, 0.0],
"x_fov": 0.349, # End-to-end field of view in radians
"near": 0.01,
"far": 100.0,
"height": 1024,
"width": 1024,
}
# camera parameters, type2
param2 = {
"K": np.array([
750.0, 0.0, 512.0,
0.0, 750.0, 512.0,
0.0, 0.0, 1.0
]).astype(np.float32), # np.array, 3x3 intrinsic matrix
"m2c": np.array([
[1.0, 0.0, 0.0, 0.0],
[0.0, -1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 1.0]
]).astype(np.float32), # np.array, 4x4 extrinsic matrix
"near": 0.01,
"far": 100.0,
"height": 1024,
"width": 1024,
}
params = [param1, param2]
# load mesh data
vertices = ... # An array of shape (num_vertices, 3) and type np.float32.
faces = ... # An array of shape (num_faces, 3) and type np.uint32.
# depthmap generation
depth_maps = m2d.convert(vertices, faces, params, empty_pixel_value=np.nan, gpu_id=0)
Test
Please follow the instructions in test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mesh2depth_gpu-0.0.3.tar.gz.
File metadata
- Download URL: mesh2depth_gpu-0.0.3.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c30055a9550f71e49a9ad55f02118943382f68c1921de08eac26553b813c08a
|
|
| MD5 |
a797af08799511d7e78a776715b8846b
|
|
| BLAKE2b-256 |
55af0fa94da305545fb2d988cadd49955dc5f6e8055efa3a2a3b2b75e02dd1a9
|
File details
Details for the file mesh2depth_gpu-0.0.3-py3-none-any.whl.
File metadata
- Download URL: mesh2depth_gpu-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f9b03620241349832d878edf1c950e0bad1f98ba63c764c667f6706f1c1ebc
|
|
| MD5 |
4d14aa6fb706bff13886f172d72e7f62
|
|
| BLAKE2b-256 |
1f5d23fd09d38aef96313ddd9b05547dc299d788e312a2f79f2d415d96c904fb
|