-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Thank you for your excellent work!
I've downloaded the test set from the website and converted the depth image into point cloud using the following code:
import os
import numpy as np
from numpy.matlib import repmat
os.environ['OPENCV_IO_ENABLE_OPENEXR'] = '1'
import cv2
image = cv2.imread('0000.exr', cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)[..., 0]
pixel_size = image.shape[0] * image.shape[1]
depth_image = image.reshape(pixel_size)
u_coord = repmat(np.r_[0:image.shape[1]:1], image.shape[0], 1).reshape(pixel_size)
v_coord = repmat(np.c_[0:image.shape[0]:1], 1, image.shape[1]).reshape(pixel_size)
fx = 499.9999781443055
fy = 499.9999781443055
cx = image.shape[1] / 2
cy = image.shape[0] / 2
k = np.identity(3)
k[0, 2] = cx
k[1, 2] = cy
k[0, 0] = k[1, 1] = fx
p2d = np.array([u_coord, v_coord, np.ones_like(u_coord)])
p3d = np.transpose(np.dot(np.linalg.inv(k), p2d) * depth_image).reshape(-1, 3)
point_cloud = []
for x, y, z in p3d:
x, y, z = z, x, -y
point_cloud.append([x, y, z])
point_cloud = np.array(point_cloud)
from plyfile import PlyData, PlyElement
vertices = np.array([(x, y, z) for x, y, z in point_cloud.reshape(-1, 3)], dtype=[('x', 'f4'), ('y', 'f4'), ('z', 'f4')])
plydata = PlyData([PlyElement.describe(vertices, 'vertex')], text=False)
plydata.write('point_cloud.ply')
The shape of the point cloud seemed nice, however there seemed to be a noticeable amount of noise in the point cloud.
Is this normal or am I using a wrong way to convert the exr file?
I'm opening 0000.exr
from small_city_road_horizon_test_depth.tar
.
Metadata
Metadata
Assignees
Labels
No labels