utils3d
A collection of useful functions for 3D computer vision and graphics researchers in Python.
- NumPy / PyTorch pairs: most functions have both implementations.
- Flat & non-modular: standalone functions only, no classes, no hierarchies.
- Native types: always use raw Python / NumPy / PyTorch / SciPy.sparse types.
- Vectorized only: no Python loops beyond O(log N).
⚠️ This repo changes quickly. Functions may be added, removed, or modified at any time.
- Copy code if you only need a single function.
- Use commit id or fork if you need stability.
Install
Install via pip + git
pip install git+https://github.com/EasternJournalist/utils3d.git
or clone the repo and install
git clone https://github.com/EasternJournalist/utils3d.git
pip install ./utils3d
Documentation
- Use
utils3d.{function}to call the function automatically selecting the backend based on the input type (Numpy ndarray or Pytorch tensor). - Use
utils3d.{np/pt}.{function}to specifically call the Numpy or Pytorch version.
The links below will take you to the source code of each function with detailed documentation and type hints.
Transforms
Maps
| Function | Numpy | Pytorch |
|---|---|---|
utils3d.bounding_rect_from_maskGet bounding rectangle of a mask |
- | utils3d.pt.bounding_rect_from_mask(mask) |
utils3d.build_mesh_from_depth_mapGet a mesh by lifting depth map to 3D, while removing depths of large depth difference. |
utils3d.np.build_mesh_from_depth_map(depth, other_maps, intrinsics, extrinsics, atol, rtol, tri) |
utils3d.pt.build_mesh_from_depth_map(depth, other_maps, intrinsics, extrinsics, atol, rtol, tri) |
utils3d.build_mesh_from_mapGet a mesh regarding image pixel uv coordinates as vertices and image grid as faces. |
utils3d.np.build_mesh_from_map(maps, mask, tri) |
utils3d.pt.build_mesh_from_map(maps, mask, tri) |
utils3d.chessboardGet a chessboard image |
utils3d.np.chessboard(size, grid_size, color_a, color_b) |
utils3d.pt.chessboard(size, grid_size, color_a, color_b) |
utils3d.colorize_depth_mapColorize depth map for visualization. |
utils3d.np.colorize_depth_map(depth, mask, near, far, cmap) |
- |
utils3d.colorize_normal_mapColorize normal map for visualization. Value range is [-1, 1]. |
utils3d.np.colorize_normal_map(normal, mask, flip_yz) |
- |
utils3d.depth_map_aliasingCompute the map that indicates the aliasing of x depth map, identifying pixels which neither close to the maximum nor the minimum of its neighbors. |
utils3d.np.depth_map_aliasing(depth, atol, rtol, kernel_size, mask) |
utils3d.pt.depth_map_aliasing(depth, atol, rtol, kernel_size, mask) |
utils3d.depth_map_edgeCompute the edge mask from depth map. The edge is defined as the pixels whose neighbors have large difference in depth. |
utils3d.np.depth_map_edge(depth, atol, rtol, ltol, kernel_size, mask) |
utils3d.pt.depth_map_edge(depth, atol, rtol, kernel_size, mask) |
utils3d.depth_map_to_normal_mapCalculate normal map from depth map. Value range is [-1, 1]. Normal direction in OpenCV identity camera's coordinate system. |
utils3d.np.depth_map_to_normal_map(depth, intrinsics, mask, edge_threshold) |
utils3d.pt.depth_map_to_normal_map(depth, intrinsics, mask) |
utils3d.depth_map_to_point_mapUnproject depth map to 3D points. |
utils3d.np.depth_map_to_point_map(depth, intrinsics, extrinsics) |
utils3d.pt.depth_map_to_point_map(depth, intrinsics, extrinsics) |
utils3d.masked_area_resizeResize 2D map by area sampling with mask awareness. |
utils3d.np.masked_area_resize(image, mask, size) |
utils3d.pt.masked_area_resize(image, mask, size) |
utils3d.masked_nearest_resizeResize image(s) by nearest sampling with mask awareness. |
utils3d.np.masked_nearest_resize(image, mask, size, return_index) |
utils3d.pt.masked_nearest_resize(image, mask, size, return_index) |
utils3d.normal_map_edgeCompute the edge mask from normal map. |
utils3d.np.normal_map_edge(normals, tol, kernel_size, mask) |
- |
utils3d.pixel_coord_mapGet image pixel coordinates map, where (0, 0) is the top-left corner of the top-left pixel, and (width, height) is the bottom-right corner of the bottom-right pixel. |
utils3d.np.pixel_coord_map(size, top, left, convention, dtype) |
utils3d.pt.pixel_coord_map(size, top, left, convention, dtype, device) |
utils3d.point_map_to_normal_mapCalculate normal map from point map. Value range is [-1, 1]. |
utils3d.np.point_map_to_normal_map(point, mask, edge_threshold) |
utils3d.pt.point_map_to_normal_map(point, mask) |
utils3d.screen_coord_mapGet screen space coordinate map, where (0., 0.) is the bottom-left corner of the image, and (1., 1.) is the top-right corner of the image. |
utils3d.np.screen_coord_map(size, top, left, bottom, right, dtype) |
utils3d.pt.screen_coord_map(size, top, left, bottom, right, dtype, device) |
utils3d.uv_mapGet image UV space coordinate map, where (0., 0.) is the top-left corner of the image, and (1., 1.) is the bottom-right corner of the image. |
utils3d.np.uv_map(size, top, left, bottom, right, dtype) |
utils3d.pt.uv_map(size, top, left, bottom, right, dtype, device) |
Mesh
Rasterization
Utils
Io
| Function | Numpy | Pytorch |
|---|---|---|
utils3d.read_extrinsics_from_colmapRead extrinsics from colmap images.txt file. |
utils3d.np.read_extrinsics_from_colmap(file) |
- |
utils3d.read_intrinsics_from_colmapRead intrinsics from colmap cameras.txt file. |
utils3d.np.read_intrinsics_from_colmap(file, normalize) |
- |
utils3d.read_objRead wavefront .obj file, without preprocessing. |
utils3d.np.read_obj(file, encoding, ignore_unknown) |
- |
utils3d.write_extrinsics_as_colmapWrite extrinsics to colmap images.txt file. |
utils3d.np.write_extrinsics_as_colmap(file, extrinsics, image_names, camera_ids) |
- |
utils3d.write_intrinsics_as_colmapWrite intrinsics to colmap cameras.txt file. Currently only support PINHOLE model (no distortion) |
utils3d.np.write_intrinsics_as_colmap(file, intrinsics, width, height, normalized) |
- |
utils3d.write_obj |
utils3d.np.write_obj(file, obj, encoding) |
- |
utils3d.write_simple_objWrite wavefront .obj file, without preprocessing. |
utils3d.np.write_simple_obj(file, vertices, faces, encoding) |
- |
Metadata
Release files for dlr-utils3d 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dlr_utils3d-1.3.tar.gz | 135.0 kB | Without provenance | Details for dlr_utils3d-1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dlr_utils3d-1.3-py3-none-any.whl | Python 3 | none | any | Details for dlr_utils3d-1.3-py3-none-any.whl |
Total release size: 265.4 kB
Release files / dlr_utils3d-1.3.tar.gz
| Download URL | dlr_utils3d-1.3.tar.gz |
|---|---|
| Size | 135.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8608ec5ba3ab3ca08f42da38ad2bc759d1c6da5a76db23f3a3cf063ee0a2823
|
|
BLAKE2b-256 checksum How to use checksums |
9a67f3f784d3f9e4af9d549d0ebda6434015f64666d8db58e4cb777f8d1c7a53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / dlr_utils3d-1.3-py3-none-any.whl
| Download URL | dlr_utils3d-1.3-py3-none-any.whl |
|---|---|
| Size | 130.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8ec2e1266182469b386b49af38aed118ec4b21c3a0ab55d22272f1ce2d32d4c
|
|
BLAKE2b-256 checksum How to use checksums |
62aa333ebbd95a85bd775b1858c946e4c60fbe882ff0402fcb44142a82b83640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for dlr-utils3d 1.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.