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, 1, 1],
"cam_lookat": [0, 0, 0],
"cam_up": [0, 1, 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)
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
mesh2depth_gpu-0.0.2.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for mesh2depth_gpu-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b7bef24ba6f2fefde0d07bd8cd3396971cf7d4fa56c7bbb12edacdfe8a47ee9 |
|
MD5 | 2a8a8f24d02f003d47ee991d477743b5 |
|
BLAKE2b-256 | cda1b237437ef46aca22b2fa75ac48e7f0e2d864275c188d05bcef5a84054154 |