• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use python3 to convert depth image into hha image

Depth2HHA-python

News

  • [July 20 2021] We have optimized the code and the running speed is much faster. Thank hongfz16 for his useful suggestions.

Introduction

This repo implements HHA-encoding algorithm in python3. HHA image is an encoding algorithm to make better use of depth images, which was proposed by s-gupta in this paper: Learning Rich Features from RGB-D Images for Object Detection and Segmentation. This algorithm was implemented in MATLAB initially, and I organized a MATLAB version of the code: Depth2HHA-MATLAB. In this repo, I use python3 to get exactly the same result as what MATLAB code does.


All we need is:

  1. A depth image
  2. A raw-depth image (Option)
  3. Camera matrix

If you are confused about depth images or you don't have depth images, please refer to NYU Depth V2 dataset.


Usage

I already provide an interface in getHHA.py. The function is named getHHA(C, D, RD). To be detailed, it needs a camera matrix C, a depth image D and a raw depth image RD. RD is used to generate a mask to mark missing information, so it is ok to use getHHA(C, D, D) if you don't have a raw depth image or you just want to do so.

D = cv2.imread(os.path.join(root, '0.png'), cv2.COLOR_BGR2GRAY)/10000
RD = cv2.imread(os.path.join(root, '0_raw.png'), cv2.COLOR_BGR2GRAY)/10000
camera_matrix = getCameraParam('color')
hha = getHHA(camera_matrix, D, RD)

Tips

  1. I recommend you to use cv2.COLOR_BGR2GRAY instead of cv2.IMREAD_GRAYSCALE to read in the gray image D. If you use cv2.COLOR_BGR2GRAY, you will get exactly the same gray values as MATLAB's imread function does. If you use cv2.IMREAD_GRAYSCALE, you won't.
  2. The depth image array passed to function getHHA should in 'meter'. So in my demo code, I divide it with 10000 to modify the unit.
  3. Camera matrix C is a 3*3 matrix.

Results

Pictures below are visualizations of:

D:

RD:

HHA from MATLAB:

HHA using D and RD:

HHA using D and D:


Citation

If you find this project useful in your research, please consider cite:

@misc{Depth2HHA-python,
    title={{Depth2HHA-python}: Converting depth maps to HHA encodings},
    author={Xiaokang Chen},
    howpublished = {\url{https://github.com/charlesCXK/Depth2HHA-python}},
    year={2018}
}

TODO

  • Parallel processing

More Repositories

1

TorchSemiSeg

[CVPR 2021] Semi-Supervised Semantic Segmentation with Cross Pseudo Supervision
Python
440
star
2

RGBD_Semantic_Segmentation_PyTorch

[ECCV 2020] PyTorch Implementation of some RGBD Semantic Segmentation models.
Python
226
star
3

PyTorch_Semantic_Segmentation

Implement some models of RGB/RGBD semantic segmentation in PyTorch, easy to run. Such as FCN, RefineNet, PSPNet, RDFNet, 3DGNN, PointNet, DeepLab V3, DeepLab V3 plus, DenseASPP, FastFCN
Python
226
star
4

TorchSSC

Implement some state-of-the-art methods of Semantic Scene Completion (SSC) task in PyTorch. [1] 3D Sketch-aware Semantic Scene Completion via Semi-supervised Structure Prior (CVPR 2020)
Python
48
star
5

Depth2HHA

Use MATLAB to convert depth image into HHA image. In this repo, I will use NYU Depth V2 dataset as an example.
MATLAB
41
star
6

DIP_Final-Railway_ticket_detection

Final project of PKU DIP 2018 (火车票检测与识别)
Python
12
star
7

Chinese-QA-system

Final project of 2018 WebDatamining in PKU, Automatic QA system based on Chinese WIKI. (基于中文wiki的自动问答系统)
Python
8
star
8

PageRank-Algorithm

Implement the PageRank algorithm by python 3
Python
2
star
9

LeetCode-record

My solutions for LeetCode problems
Python
1
star
10

RankClus-Algorithm-By-Python3

My Project of 2018 PKU Data Warehouse
Jupyter Notebook
1
star
11

CAM-pytorch

CAM algorithm implemented by python3 and pytorch 0.4.0
Python
1
star
12

PKU-score-script

北大学生使用的通过爬取dean实现的自动查分脚本,Python3
Python
1
star
13

PKU-Flower-Encyclopedia

2018 PKU JAVA程序设计 Project, 花卉识别 Android APP
Java
1
star