Skip to main content

mesh2depth_gpu

License: MIT versions Code style: black

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

Metadata

Release files for mesh2depth-gpu 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mesh2depth-gpu 0.0.3
File Size Uploaded
mesh2depth_gpu-0.0.3.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mesh2depth-gpu 0.0.3
File Interpreter ABI Platform
mesh2depth_gpu-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / mesh2depth_gpu-0.0.3.tar.gz

Download URL mesh2depth_gpu-0.0.3.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5c30055a9550f71e49a9ad55f02118943382f68c1921de08eac26553b813c08a
BLAKE2b-256 checksum
How to use checksums
55af0fa94da305545fb2d988cadd49955dc5f6e8055efa3a2a3b2b75e02dd1a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release files / mesh2depth_gpu-0.0.3-py3-none-any.whl

Download URL mesh2depth_gpu-0.0.3-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95f9b03620241349832d878edf1c950e0bad1f98ba63c764c667f6706f1c1ebc
BLAKE2b-256 checksum
How to use checksums
1f5d23fd09d38aef96313ddd9b05547dc299d788e312a2f79f2d415d96c904fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page