Skip to content

Utility for converting 3D models to depth maps using Open3D

License

Notifications You must be signed in to change notification settings

martivilella/3DtoDepthmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

The goal of this utility is to provide a simple way to generate depth maps (Z-Buffers) from 3D models, to be used as synthetic inputs for neural networks and other relevant tasks. It provides:

  • Depth map in [m] as a 3D npy file;
  • Depth map in png format with a user-defined scaling factor (default = 1000.0), so that 255RGB corresponds to 255[mm] depth;
  • Segmentation mask in png format;
  • Intrinsic camera parameters in format used in the CQCNN package by Berkeley Automation

There are numerous standards used to express depth data, so the code is designed to be modular and easy to edit for custom implementations

Sample outputs for a small frog object:

Depth map Seg mask
Depth map of a small frog object, scaling=5000.0 Segmentation mask of the same object

Getting started

This project is developed with Python 3.8, although >=3.6 should be compatible.

To set up the project:

  1. (Optional) create a virtual environment to avoid dependencies conflicts with other projects
  2. Install pip dependencies from requirements.txt

Usage

Run main.py with 1 arg providing the relative path to the 3D model file. A 2nd arg that is the depth png image scaling factor can also be provided:

python3 main.py <3dmodel.obj> [depthPNG_scaling{=1000.0}]

If using a Python virtual environment, don't forget to activate it by sourcing from the terminal:

source <venv_name>/bin/activate

Supported 3D model file types

The script is using the Open3D library, which supports 3D geometry file formats:

  • OBJ
  • PLY
  • STL
  • ASSIMP
  • FBX
  • GLTF
  • OFF

Additionally, pointcloud formats are supported. These require editing the import call to convert them to a mesh:

  • PCD
  • PTS
  • XYZ
  • XYZN
  • XYZRGB

About

Utility for converting 3D models to depth maps using Open3D

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages