mrcal icon indicating copy to clipboard operation
mrcal copied to clipboard

point cloud reconstruction from time of flight camera depth image

Open Baehn opened this issue 1 year ago • 1 comments

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

Baehn avatar Aug 11 '24 07:08 Baehn

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.

dkogan avatar Aug 13 '24 05:08 dkogan