Code Monkey home page Code Monkey logo

instant-dexnerf's Introduction

Instant DexNerf

Depth/3D Shape estimation of transparent objects using multiview posed RGB images. The project was inspired by Dex-NeRF: Using a Neural Radiance field to Grasp Transparent Objects and Instant Neural Graphics Primitives. Combination of two methods provides both fast training/rendering speed and accurate depth map estimation.

How to install

For installation steps please refer to Instant NGP.

How to run

There is an example of a scene with transparent object. Run from the command line

./build/testbed --scene data/nerf/canister/transforms.json

In the GUI you can adjust sigma parameter and switch between normal and Dex depth rendering. By default, sigma = 15.

How to create depth maps of captured scenes

In /scripts folder there is a main.py script for depth map generation.

  1. First, fill the scene_dirs list with paths to your folders with rgb images. These folders must have the following structure. In /data/nerf/canister you can find examples of groundtruth_handeye.txt and intrinsics.txt
├── scene_folder
│   ├── img_dir (folder with rgb images. default "rgb", but you can change the name in main.py) 
│   ├── groundtruth_handeye.txt (contains c2w extrinsics as quaternions for each image. x,y,z,w format)
|   ├── intrinsics.txt (w h fx 0 cx 0 fy cy 0 0 1 [360 or 180]). 180 for forward-facing scene, 360 for 360° scene.
  1. Set parameters for training and rendering: depth_dir, sigma_thrsh, aabb_scale, train_steps
  2. Run main.py Rendered depth maps are found in scene_folder/depth_dir folder.

Note: if you use world coordinate system different from ours, please adapt transform_matrix in ours2nerf.py. c2w matrices are multiplied by transform_matrix before they written to the transforms.json file. Otherwise, poses are expected to be in OPENCV format.

Depending on your scene geometry, you may need to tune scale, offset parameters !!!

Results

Example 1

000039 rendered_depth1

Example 2

000050 rendered_depth2

Depth error

Example 1

error_depth1 cbar

Example 2

error_depth2 cbar

Citation

Kudos to the authors for their great work

@inproceedings{IchnowskiAvigal2021DexNeRF,
  title={{Dex-NeRF}: Using a Neural Radiance field to Grasp Transparent Objects},
  author={Ichnowski*, Jeffrey and Avigal*, Yahav and Kerr, Justin and Goldberg, Ken},
  booktitle={Conference on Robot Learning (CoRL)},
  year={2020}
}
@article{mueller2022instant,
    author = {Thomas M\"uller and Alex Evans and Christoph Schied and Alexander Keller},
    title = {Instant Neural Graphics Primitives with a Multiresolution Hash Encoding},
    journal = {ACM Trans. Graph.},
    issue_date = {July 2022},
    volume = {41},
    number = {4},
    month = jul,
    year = {2022},
    pages = {102:1--102:15},
    articleno = {102},
    numpages = {15},
    url = {https://doi.org/10.1145/3528223.3530127},
    doi = {10.1145/3528223.3530127},
    publisher = {ACM},
    address = {New York, NY, USA},
}

instant-dexnerf's People

Contributors

salykova 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

instant-dexnerf's Issues

Question about camera pose in groundtruth_handeye.txt

Hi,

I have a question about the convention used in groundtruth_handeye.txt. How to generate it given the pose in COLMAP format?

I tried the following code to generate groundtruth_handeye.txt and then use it with instrinsics.txt to generated the json file using ours2nerf.py but the generated camera poses are incorrect, as shown below (they should be 360)

image

This code reads images.txt file in COLMAP format

	for line in f:
		line = line.strip()
		if line[0] == "#":
			continue
		i = i + 1
		if i < SKIP_EARLY*2:
			continue
		if  i % 2 == 1:
			elems=line.split(" ") # 1-4 is quat, 5-7 is trans, 9ff is filename (9, if filename contains no spaces)
			image_rel = os.path.relpath(IMAGE_FOLDER)
			name = str(f"./{image_rel}/{'_'.join(elems[9:])}")	
			image_id = int(elems[0])
			qvec = np.array(tuple(map(float, elems[1:5])))
			tvec = np.array(tuple(map(float, elems[5:8])))
			R = qvec2rotmat(qvec)
			t = tvec.reshape([3,1])
			m = np.concatenate([np.concatenate([R, t], 1), bottom], 0)
			c2w = np.linalg.inv(m)
			R = c2w[:3,:3]
			t = c2w[:3,3]
			q = rotm2quat(R)
			f_c2w_pose_file.write(f"{counter} {q[0]} {q[1]} {q[2]} {q[3]} {t[0]} {t[1]} {t[2]}\n")
			counter = counter + 1

Reading wrong rotation

Hi and Thanks for your work!

I am trying to get the repo running with my own data. However, the extrinsics get messed up when loaded (they should point inward, not outward the circle):

image

I want to mention that the poses were generated with COLMAP in a transforms.json file. They are displayed correctly by instant-ngp and produce good results.

Also, I am getting this error when I try to start the training, which is probably because of it not being able to build the rays from the positions.

WARNING  Nerf training generated 0 samples. Aborting training.

run error

The error is "colmap fail for some images". How to resolve it?

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.