A collection of useful functions for 3D computer vision and graphics researchers in Python
Project description
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) |
- |
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 dlr_utils3d-1.3.tar.gz.
File metadata
- Download URL: dlr_utils3d-1.3.tar.gz
- Upload date:
- Size: 135.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8608ec5ba3ab3ca08f42da38ad2bc759d1c6da5a76db23f3a3cf063ee0a2823
|
|
| MD5 |
68b7a7ced43cbe8d3ee10f2039dbc0fd
|
|
| BLAKE2b-256 |
9a67f3f784d3f9e4af9d549d0ebda6434015f64666d8db58e4cb777f8d1c7a53
|
File details
Details for the file dlr_utils3d-1.3-py3-none-any.whl.
File metadata
- Download URL: dlr_utils3d-1.3-py3-none-any.whl
- Upload date:
- Size: 130.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8ec2e1266182469b386b49af38aed118ec4b21c3a0ab55d22272f1ce2d32d4c
|
|
| MD5 |
6fd4d35f4d0ed436cecf322805966418
|
|
| BLAKE2b-256 |
62aa333ebbd95a85bd775b1858c946e4c60fbe882ff0402fcb44142a82b83640
|