Coder Social home page Coder Social logo

tof_rgbd_processing's Introduction

Deep End-to-End Alignment and Refinement for Time-of-Flight RGB-D modules

This repository contains the TensorFlow (1.2) implementation of the paper "Deep End-to-End Alignment and Refinement for Time-of-Flight RGB-D modules". This implementation has been tested on Ubuntu 14.04. with CUDA 8.0.

To use it, first create your python virtual environment, and install the requirements by

pip install -r requirements.txt

Then compile the cuda operations: in /utils and /utils/ops/warp_by_flow, type in the Terminal

make

Now you should be ready to go. To test the model, use the fullmodel.py in the /fullmodel directory, where you can set the data directory and output directory.

Our trained model is provided here.

ToF FlyingThings3D dataset

You can download the RGB-Depth dataset (~20GB) here. The loader.py file is responsible for loading this dataset.

Update 17 March, 2020: Since the original transient rendering is too large to host on Drive, we provide the original blender&pbrt files in the same Drive folder with code on generating the data.

Note that our data generation follows the protocol from Su et al. Deep End-to-End Time-of-Flight Imaging, CVPR 2018.

Synthetic ToF Dataset Generation Using Blender and PBRT

Introduction

This repo contains the source and data files for generating synthetic ToF data.

There are two major parts in the data generation pipeline:

  • Produce ground truth depth using Blender with a .blend file.
  • Produce transient renderings using pbrt-v3-tof with a (or multiple) .pbrt file(s), and use MatLab to process the renderings as ToF raw correlation measurements or ToF depth images (no plane correction).

Optionally, you may render corresponding color images using Blender or the official version of pbrt.

The major files in repo is organized as follows:


|- blender_utils
    |-- export_path.py # export camera locations in Blender's Timeline, should be run inside of Blender #
    |-- output_zpass.py # python script for writing ground truth depth #
    |-- lighting_multiple_output # further applications for use of python in blender #

|- pbrt-v3-tof
    |-- example 
        |-- batch_run_pbrt.sh # pbrt rendering example #

|- transient_processing
    |-- example
        |-- transient_to_depth.m # MatLab script for converting transient rendering into ToF correlation measurements and ToF depth images #

|- pbrt_material_augmentation
    |-- exanple
        |-- output_materail.m # MatLab script for writing material library .pbrt files #

|- scenes # 3D models and camera paths # 
 

Installation pre-requisite

Tested under Ubuntu 14.04

Workflow

  1. Render ground truth depth images (no plane correction) using the Depth Pass in the Blender's Cycles renderer. In Blender's GUI, it is visible in the Node editor's Renderlayers viewport. Make sure the "Use Nodes" is ticked. Set your camera position and hit the camera-shot button to render the image and save it into the path.

The python script for producing this procedure without using the GUI is given in blender_utils/output_zpass.py. The termnial command is

$blender_path/blender -b $.blendfile --python output_zpass.py --$python_args 

Rendering the depth pass is very fast in Blender. You can do more interesting things with blender's python library bpy, as illustrated in the lighting_multiple_output.py.

  1. Render transient images. This is a one-line command
$pbrt_path/pbrt $pbrt_file

which will produce by default 256 transient images in $pwd. Typically it taks 3~5 minutes to render on a multicore CPU. A batch processing file is given in /pbrt-v3-tof/example/batch_run_pbrt.sh.

  1. Process the transient images. Here we use MatLab for this purpose. The code is provided in /transient_processing/example/transient_to_depth.m.

It is important that the .blend file and .pbrt file correspond to the same scene at the same camera viewpoint. There are differences between the coodinate system used by pbrt-v3-tof and Blender. For example, if you want to produce a .pbrt file from a .blend file, first use Blender's "Export as .obj" function and choose the option "-Z forward & Y up", and then further transform it into .pbrt using obj2pbrt provided in the pbrt-v3-tof package. You often have to make sure the rendering result are consistent. If they are still not consistent, you may also want to check other parameters such as fov, image resolution, etc. in both Blender's setting and the setting in the .pbrt file. As far as I know, blender refer to the horizontal dimension for FOV while pbrt uses the vertical dimension.

Material augmentation in .pbrt file

In /pbrt_material_augmentation we have some utility functions on augmenting material properties in .pbrt file using MatLab. What it does is to replace the material parameters with some prescribed or random numbers. You should refer to the format of .pbrt files in https://www.pbrt.org/fileformat-v3.html. Note in particular that a .pbrt file can refer to other .pbrt files. This will come handy if we have a material library .pbrt file as we do assume here.

Additional Resources


calib.bin files

In the Drive folder there is a calib.bin file, which should be used if mvg_aug is set to be true when training. There is another calib.bin file in the test_real folder, which contains a sample real test image. The calib.bin file there is for real calibration.


For the most updated details about this work, please refer to the arxiv paper. If you find this work useful, please cite

@inproceedings{qiu2019rgbd,
  title={Deep End-to-End Alignment and Refinement for Time-of-Flight RGB-D modules},
  author={Di Qiu, Jiahao Pang, Wenxiu Sun, Chengxi Yang},
  booktitle={International Conference in Computer Vision (ICCV)},
  year={2019}
}

Future Work

  • Can we possibly find the "correct material"? In this pipeline, given fixed scene geometry, multi-path interference error is determined by the material properties. Determining what meterial specification should coincide with the sensor's capture is not done here.
  • Sensor error simulation In Guo's FLAT dataset, they implemented Kinect's camera function and modelled its noise distribution. Here we do not have sensor specific data pipeline.
  • GPU acceleration PBRT currently only parallelizes on CPU.
  • PBRT-Blender materal correspondence This is specifically important if one wants to use RGB images from Blender.

Disclaimer: This software and related data are published for academic and non-commercial use only.

tof_rgbd_processing's People

Contributors

sylqiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tof_rgbd_processing's Issues

Could you please share your real dataset (400 scenes)?

Hi Sylqiu
Sorry for bothering you.
It mentions 400 scenes 640x480 real data by Panasonic ToF and RGB sensor in Chapter 4.2-Real Data Collection in your paper(Deep End-to-End Alignment and Refinement for Time-of-Flight RGB-D Module).
Could you please share your real dataset ?
Thanks.

Where are major files for Synthetic ToF Dataset Generation Using Blender and PBRT?

In your repo, you mention that the major files in repo is organized as follows:

|- blender_utils
|-- export_path.py # export camera locations in Blender's Timeline, should be run inside of Blender #
|-- output_zpass.py # python script for writing ground truth depth #
|-- lighting_multiple_output # further applications for use of python in blender #

|- pbrt-v3-tof
|-- example
|-- batch_run_pbrt.sh # pbrt rendering example #

|- transient_processing
|-- example
|-- transient_to_depth.m # MatLab script for converting transient rendering into ToF correlation measurements and ToF depth images #

|- pbrt_material_augmentation
|-- exanple
|-- output_materail.m # MatLab script for writing material library .pbrt files #

|- scenes # 3D models and camera paths #

But I can't find where are them.

TypeError: Expected list for 'values' argument to 'Pack' Op, not range(0, 512).

Hi, sylqiu,
recently, I am learning your repository, when I try to running your code, I received the error:TypeError: Expected list for 'values' argument to 'Pack' Op, not range(0, 512).
I set the main parameter input as: --dataset_name nogt --is_training 0
and I think this means I use test mode, So I changed the TestingConfig:
self.wlast = './full_model_checkpoint/checkpoint/ckpt'
self.path = '/home/tof_rgbd_processing-master/fullmodel/gt_depth_rgb',
I am really confused what's wrong in my code, may you give me some suggestions?

Missing value for placeholder i_D

Thank you for uploading a sample test image. I'm trying to get it to run, but am running into another issue.

Traceback (most recent call last): File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1139, in _do_call return fn(*args) File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1121, in _run_fn status, run_metadata) File "/home/ubuntu/anaconda3/lib/python3.6/contextlib.py", line 88, in __exit__ next(self.gen) File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'i_D_1' with dtype float and shape [1,384,512,1] [[Node: i_D_1 = Placeholder[dtype=DT_FLOAT, shape=[1,384,512,1], _device="/job:localhost/replica:0/task:0/gpu:0"]()]] [[Node: Reshape_11/_333 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_1171_Reshape_11", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

For reference, I'm running fullmodel.py, with dataset_name nogt and is_training 0.

I had to make a few small code changes to get it running, so it's possible I broke something in the process. Here are the changes I made:

In fullmodel.py, line 173, change "if self.use_fifo = True" to "if self.use_fifo == True" (add double equals)
In fullmodel.py, line 102, change "self.testing_config = TestingConfig()" to "self.testing_config = TestingConfig(dataset_name)", because TestingConfig's init method requires a dataset_name.
In fullmodel.py, line 490, change to "R, L, fD = self.sess.run([self.R, self.L, self.filtered_D])" because self.refineflow_EPE and self.roughflow_EPE are only created if ground truth is available.
In loaders.py, lines 26 and 27, remove dictionary entries for flatd and flat, because FLATD and FLAT seem to be undefined.

Thanks again for your help with this!

error when compile warp_by_flow

when i compile warp_by_flow int tf1.15 with cuda10.0, it remind me the error
#include "tensorflow/core/util/cuda_kernel_helper.h" not exist
it seems that tf1.15 had remove it, did you test it in any other tf version

Missing calib.bin

camera_util.py seems to expect a calib.bin file, but there doesn't seem to be one in the repo or in the dataset available for download. Can you provide a copy of this file?

Thanks!

mismatch of my data and your ToFFlythins3D

Hi,Di Qiu:
I am using the code which can generate the transient images and ground truth data. how ever when I repeate it in my machine, some problems occurs.
i am using the command line 'pbrt -**.pbrt' to generate the transient images of a special camera position. and using the command line'blender -b **.blend --python run_zpass_camera1_more.py' to generate the grund truth data. however when i am compared with your ToFFlytings3D dataset, some questions is here:
1:compare the transient images results with your GT data: I generarte the 20M depth using single frequency ,however my 20M depth is much larger than your data(in your .mat GT data, GT42/4095 to real depth), and the ration between your data and my 20M data is 1.4, it means that my 20M depth = 1.4 * your GT data, i don't known why this happened.
2: compare my GT data with your GT data: when compare my GT data with your GT data,some questions here, firstly i found the ration between my GT data and your GT data is about 12.5,secondly when i subtract 12.5*your GT data from my GT data ,a shift occured. you can see in this picture.
6dc1134dd8183711acc04f35a286fd6

best regards

Questions about only train ToF-KPN

Hi, sylqiu:
I have read your paper, in your paper compapred with DeepToF is given ,however the input of the ToF-KPN is RGB image ใ€ wraped ToF amplitude and wraped ToF depth image, when you train a ToF-KPN without RGB image , how to get wraped ToF amplitude and wraped ToF depth image ?

rendering with pbrt

I have followed your instruction, but I was not able to get 256 transient images (i rather got single *.exr file)

  • I downloaded ToF-pbrt-generation and installed pbrt-v3-tof
  • when I run pbrt, I used following command

/DirToPbrt/pbrt /DirToToF/ToF-pbrt-generation/scenes/ToFFlyingThings3D/breakfast/more.pbrt

and I got single "breakfast.exr" file in /DirToPbrt/

Also I tried to use "batch_run_pbrt.sh" but I was not able to run it as I have no clue about some variables to set like
CAMFILE (I used ToF-pbrt-generation/scenes/ToFFlyingThings3D/breakfast/campath1000.txt (or campath1000_z.txt)) , MAT_PATH (I have no idea),
SCENE_LIST (also have no idea) etc

can I get more detailed instruction of way to get 256 transient images?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.