Code Monkey home page Code Monkey logo

densemap's Introduction

Get a dense Depth map from sparse LiDAR point clouds

This repository contains a short python script to get a dense depth map from a LiDAR point cloud for a known camera. The original code is written in matlab and is from balcilar(https://github.com/balcilar/DenseDepthMap).

In dense_map.py is the function to generate the dense depth map (depth_map) and in main.py the code is used on the KITTI dataset.

depth_map gets the projected LiDAR point cloud, the size of the camera image and the grid size. A grid size of 4 means a 9x9 neighbourhood is used and weighted depth information is calculated according to the distance of the neighbourhood.

densemap's People

Contributors

berensrwu 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

Watchers

 avatar

densemap's Issues

Adjustment to depth_map.py file.

The essence of creating dense depth map is to calculate weighted depth information according to the distance of neighborhood. The original repo is based on inverse distance weighted. When it comes to the distance calculation, I have mads some adjustments, replacing the np.round() with np.int32(). Also, in the double loop statements, I have deleted - grid - 1.
`

  def dense_map(Pts, n, m, grid):
      ng = 2 * grid + 1
      mX = np.zeros((m,n)) + np.float("inf")
      mY = np.zeros((m,n)) + np.float("inf")
      mD = np.zeros((m,n))
      mX[np.int32(Pts[1]),np.int32(Pts[0])] = Pts[0] - np.int32(Pts[0])#np.round(Pts[0])  # NOTICE
      mY[np.int32(Pts[1]),np.int32(Pts[0])] = Pts[1] - np.int32(Pts[1])#np.round(Pts[1])  # NOTICE
      mD[np.int32(Pts[1]),np.int32(Pts[0])] = Pts[2]
      
      KmX = np.zeros((ng, ng, m - ng, n - ng))
      KmY = np.zeros((ng, ng, m - ng, n - ng))
      KmD = np.zeros((ng, ng, m - ng, n - ng))
      
      for i in range(ng):
          for j in range(ng):
              KmX[i,j] = mX[i : (m - ng + i), j : (n - ng + j)] + i #- grid - 1  # NOTICE
              KmY[i,j] = mY[i : (m - ng + i), j : (n - ng + j)] + j #- grid - 1  # NOTICE
              KmD[i,j] = mD[i : (m - ng + i), j : (n - ng + j)]
      S = np.zeros_like(KmD[0,0])
      Y = np.zeros_like(KmD[0,0])

      # Inverse distance weighted
      for i in range(ng):
          for j in range(ng):
              s = 1/np.sqrt(KmX[i,j] * KmX[i,j] + KmY[i,j] * KmY[i,j])
              Y = Y + s * KmD[i,j]
              S = S + s
      
      S[S == 0] = 1
      out = np.zeros((m,n))
      out[grid + 1 : -grid, grid + 1 : -grid] = Y/S
      return out

`

To convert dense depth map to point cloud

Hi, I saw your impressive work and am curious, is it possible to project back the estimated dense depth map to point cloud coordinates? if so, can you please provide a code for that? Thanks in advance.

How to use this code ?

There is not input file path, where should I run this code? please help me out to do this, since this is my first time. Thanks a lot !

SyntaxError: invalid syntax

Screenshot from 2021-02-17 10-55-54
It showing some syntax error, can you please help me to solve this error ? and how can i visualize the output ?

Some questions about the code

Hi, thanks for sharing the code.
I have some problems with the code in depth_map.py.
To deal with images in sequence 04 where the size is 370 * 1226,
the error is located in line 10:
mX[np.int32(Pts[1]),np.int32(Pts[0])] = Pts[0] - np.round(Pts[0])
IndexError: index 370 is out of bounds for axis 0 with size 370

I found that the value of Pts[1] is larger than 370 and the value of Pts[0] is larger than 1226, so there is an index error.
The calib.txt is correct because sequences 00,01,02,03 can be done well.
Can you give some suggestions? Thanks very much.

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.