Skip to main content

visu3d - 3D geometry made easy

Unittests PyPI version Documentation Status

visu3d is an abstraction layer between Torch/TF/Jax/Numpy and your program. It provides:

  • Standard primitives for 3d geometry (Ray, Camera, Transform,...). You can combine those standard primitives with your custom ones.
  • Everything is trivially visualizable with zero boilerplate. Inspect & debug camera poses, trajectories,...
  • All primitives are dataclass_array, dataclasses which can be reshaped, sliced,... as if they were numpy arrays.
  • Everything is extensible, you can gradually opt-in only for the features you need, and replace any standard primitive by your custom ones.

Core features

Everything is a v3d.DataclassArray: dataclass behave like np.array (with indexing, slicing, shape manipulation, vectorization,...).

# Single ray
ray = v3d.Ray(pos=[0, 0, 0], dir=[1, 1, 1])
assert rays.shape == ()

# Multiple rays batched together
rays = v3d.Ray(pos=np.zeros((B, H, W, 3)), dir=np.ones((B, H, W, 3)))
assert rays.shape == (B, H, W)

rays = rays.reshape('b h w -> b (h w)')  #  Native `einops` support

top_left_ray = rays[..., 0, 0]  #  (b, h, w) -> (b,)

rays = rays.flatten()
rays = rays[rays.norm() > 0]  # Filter invalid rays

Everything is visualizable interactively

Every object has a .fig property for interactive visualization:

rays.fig  # Plot the rays

Display multiple objects together:

v3d.make_fig([cam, rays, point_cloud])

Auto-plot figures with Colab magic:

v3d.auto_plot_figs()  # Once at the start of the Colab

cam, rays, point_cloud  # Tuple auto-displayed without `v3d.make_fig` call

Same code seamlessly works across Torch, Jax, TensorFlow, Numpy.

rays = rays.as_jax()  # .as_tf(), as_np(), .as_jax()
assert isinstance(rays.pos, jnp.ndarray)
assert rays.xnp is jnp

rays = rays.as_torch()
assert isinstance(rays.pos, torch.Tensor)
assert rays.xnp is torch

With native support for auto-diff, jax.vmap, jax.tree_utils,...

Privitives

Common primitives (Ray, Camera, Transform,...), so user can express intent, instead of math.

H, W = (256, 1024)
cam_spec = v3d.PinholeCamera.from_focal(
    resolution=(H, W),
    focal_in_px=35.,
)
cam = v3d.Camera.from_look_at(
    spec=cam_spec,
    pos=[5, 5, 5],
    target=[0, 0, 0],  # Camera looks at the scene center
)

rays = cam.rays()  # Rays in world coordinates

# Project `(*shape, 3)` world coordinates into `(*shape, 2)` pixel coordinates.
px_coords = cam.px_from_world @ point_cloud

See the API for a full list of primitive.

Creating your own primitives is trivial.

Converting any dataclass to dataclass array is trivial:

  • Inherit from v3d.DataclassArray
  • Use etils.array_types to annotate the array fields (or exlicitly use my_field: Any = dca.field(shape=, dtype=) instead of dataclasses.field)
from etils.array_types import FloatArray


class MyRay(v3d.DataclassArray):
  pos: FloatArray[..., 3]
  dir: FloatArray[..., 3]


rays = MyRay(pos=jnp.zeros((H, W, 3)), dir=jnp.ones((H, W, 3)))
assert rays.shape == (H, W)

v3d makes it easy to opt-in to the feature you need by implementing the corresponding protocol.

Documentation

The best way to get started is to try the Colab tutorials (in the documentation):

Installation:

pip install visu3d

Usage:

import visu3d as v3d

Installation

pip install visu3d

This is not an official Google product.

Metadata

Release files for visu3d 1.5.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 visu3d 1.5.3
File Size Uploaded Provenance Actions
visu3d-1.5.3.tar.gz 34.5 kB Without provenance Details for visu3d-1.5.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for visu3d 1.5.3
File Interpreter ABI Platform Actions
visu3d-1.5.3-py3-none-any.whl Python 3 none any Details for visu3d-1.5.3-py3-none-any.whl

Total release size: 83.9 kB

Release files / visu3d-1.5.3.tar.gz

Download URL visu3d-1.5.3.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8bcf1f935d4ca45becad745edf83840ac544476c7feed047a20db13657ea49f5
BLAKE2b-256 checksum
How to use checksums
ab48c052e6df66e5079009871f6722ab9b0acccfa66ea5522961ba7dace9c290
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / visu3d-1.5.3-py3-none-any.whl

Download URL visu3d-1.5.3-py3-none-any.whl
Size 49.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
16564695d365911ffc9900c8c786d7c91c7abea1fa7907f62553136250da4289
BLAKE2b-256 checksum
How to use checksums
8b33d1a3feedec734e56ebb171c5fdf3ac6d1a509751b67f962b0bf7f6ca6b32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for visu3d 1.5.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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