Skip to content

Instantly share code, notes, and snippets.

@edz-o
Last active June 13, 2020 11:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save edz-o/84d63fec2fc2d70721e775337c07e9c9 to your computer and use it in GitHub Desktop.
Save edz-o/84d63fec2fc2d70721e775337c07e9c9 to your computer and use it in GitHub Desktop.
def DepthConversion(PointDepth, f):
H = PointDepth.shape[0]
W = PointDepth.shape[1]
i_c = np.float(H) / 2 - 1
j_c = np.float(W) / 2 - 1
columns, rows = np.meshgrid(np.linspace(0, W-1, num=W), np.linspace(0, H-1, num=H))
DistanceFromCenter = ((rows - i_c)**2 + (columns - j_c)**2)**(0.5)
PlaneDepth = PointDepth / (1 + (DistanceFromCenter / f)**2)**(0.5)
return PlaneDepth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment