mrcal
mrcal copied to clipboard
point cloud reconstruction from time of flight camera depth image
I have a time of flight camera, that is I get a depth image as raw data from my camera, after calibration, is mrcal.unprocject the supposed way to compute the corresponding point cloud, e.g. like this?:
import numpy as np
import mrcal
model = mrcal.cameramodel(filename)
depth_image = ... # load depth image
width, height = depth_image.shape
x, y = np.mgrid[0:width, 0:height]
points = np.stack((x, y), axis=-1).reshape(-1, 2)
upts = mrcal.unproject(points, *model.intrinsics(), normalize=True)
points_3d = (upts.T * depth_image.flatten()).T
From a high-level, that's right: you mrcal.unproject() to get directions, and scale them up with the ranges. If it doesn't work, tell me.