Skip to main content

D2NT: A High-Performing Depth-to-Normal Translator

Project description

D2NT: A High-Performing Depth-to-Normal Translator

This repo is the official implementation of the paper:

"D2NT: A High-Performing Depth-to-Normal Translator"

[arXiv] [homepage] [video]

trade-off

trade-off

Installation

Install from PyPI (Recommended)

pip install d2nt

Install from Source

# Clone the repository
git clone https://github.com/fengyi233/depth-to-normal-translator.git
cd depth-to-normal-translator

# Install in development mode
pip install -e .

# Or install normally
pip install .

Prerequisites

  • Python >= 3.7
  • numpy >= 1.20.0
  • opencv-python >= 4.5.0
  • matplotlib >= 3.5.0 (optional, for visualization)

Dataset Preparation

Public real-world datasets generally obtain surface normals by local plane fitting, which makes the surface normal ground truth unreliable. Therefore, we use the synthesis 3F2N dataset provided in this paper to evaluate estimation performance.

The 3F2N dataset can be downloaded from:
BaiduDisk
GoogleDrive
The dataset is organized as follows:

3F2N
 |-- Easy
 |  |-- android
 |  |  |-- depth
 |  |  |-- normal
 |  |  |-- params.txt
 |  |  |-- pose.txt
 |  |-- cube
 |  |-- ...
 |  |-- torusknot
 |-- Medium
 |  |-- ...
 |-- Hard
 |  |-- ...

Usage

Python Package Usage

After installation, you can use the depth2normal() function directly:

import numpy as np
from d2nt import depth2normal

# Prepare depth map (example)
depth = np.random.rand(480, 640) * 10.0

# Camera intrinsic matrix
# Format: [[fx,  0, u0],
#          [ 0, fy, v0],
#          [ 0,  0,  1]]
cam_intrinsic = np.array([
    [525.0, 0, 320.0],  # fx=525.0, u0=320.0
    [0, 525.0, 240.0],  # fy=525.0, v0=240.0
    [0, 0, 1]
])

# Convert depth to normal
normal = depth2normal(depth, cam_intrinsic, version='d2nt_v3')

print(f"Normal map shape: {normal.shape}")  # (480, 640, 3)

Algorithm Versions

  • d2nt_basic: Basic version without any optimization method
  • d2nt_v2: With Discontinuity-Aware Gradient (DAG) filter
  • d2nt_v3: With DAG filter and MRF-based Normal Refinement (MNR) module (recommended)

Python Demo

Navigate to python/ directory and run demo.py, a result and the corresponding error map (degrees) will be displayed. We also implement 3F2N SNE in python. The matlab and c++ implementation can be found in this repository.

It is recommended to run 'demo.py' in your Python Console instead of the Terminal for the sake of visualization. You can change the parameter 'VERSION' to select the D2NT version.
'd2nt_basic' represents for the depth-to-normal translator without any optimization method.
'd2nt_v2' represents for the D2NT with Discontinuity-Aware Gradient (DAG) filter.
'd2nt_v3' represents for the D2NT with DAG filter and MRF-based Normal Refinement (MNR) module.

Cite

This code is for non-commercial use. If you find our work useful in your research, please consider citing our paper:

@inproceedings{icra_2023_d2nt,
	author      = {{Yi Feng, Bohuan Xue, Ming Liu, Qijun Chen, and Rui Fan}},
	title       = {{D2NT: A High-Performing Depth-to-Normal Translator}},
	booktitle   = {{IEEE International Conference on Robotics and Automation (ICRA)}},
	year        = {{2023}}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

d2nt-0.1.0.tar.gz (6.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

d2nt-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file d2nt-0.1.0.tar.gz.

File metadata

  • Download URL: d2nt-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for d2nt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c71e4ad7feba139e5d79390eb899cc1ac52e8ec8245b981816d942098f0ea1e
MD5 2d06616b9a66d82b6e11419a841d0a64
BLAKE2b-256 cbda55f1d96ca1250f96e263692e1cdbd2c64b6586f8dde6673fb02c09fecd46

See more details on using hashes here.

File details

Details for the file d2nt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: d2nt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for d2nt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f22efba71b41ea532db82c8bae8e5ea8701838e062c97d68c393513c6b3a6c0
MD5 30c0d119ccbcd10f32abecdcdbd58769
BLAKE2b-256 931770e3134fc8cfb2f720063ff2b0ccd914d5ed8ebd6a99316fe06365931d27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page