14 namespace pointcloud {
27 const bool has_colors = image_colors.has_value();
29 int64_t n =
points.GetLength();
31 const float* points_ptr =
points.GetDataPtr<
float>();
32 const float* point_colors_ptr =
44 float x = points_ptr[3 * workload_idx + 0];
45 float y = points_ptr[3 * workload_idx + 1];
46 float z = points_ptr[3 * workload_idx + 2];
49 float xc, yc, zc, u, v;
50 transform_indexer.RigidTransform(x, y, z, &xc, &yc, &zc);
53 transform_indexer.Project(xc, yc, zc, &u, &v);
56 if (!depth_indexer.
InBoundary(u, v) || zc <= 0 || zc > depth_max) {
60 float* depth_ptr = depth_indexer.
GetDataPtr<
float>(
61 static_cast<int64_t
>(u),
static_cast<int64_t
>(v));
62 float d = zc * depth_scale;
65 #pragma omp critical(ProjectCPU)
67 if (*depth_ptr == 0 || *depth_ptr >= d) {
71 float* color_ptr = color_indexer.
GetDataPtr<
float>(
72 static_cast<int64_t
>(u),
static_cast<int64_t
>(v));
74 color_ptr[0] = point_colors_ptr[3 * workload_idx + 0];
75 color_ptr[1] = point_colors_ptr[3 * workload_idx + 1];
76 color_ptr[2] = point_colors_ptr[3 * workload_idx + 2];
CLOUDVIEWER_HOST_DEVICE void * GetDataPtr() const
CLOUDVIEWER_HOST_DEVICE bool InBoundary(float x, float y) const
void ParallelFor(const Device &device, int64_t n, const func_t &func)
void ProjectCPU(core::Tensor &depth, utility::optional< std::reference_wrapper< core::Tensor >> image_colors, const core::Tensor &points, utility::optional< std::reference_wrapper< const core::Tensor >> colors, const core::Tensor &intrinsics, const core::Tensor &extrinsics, float depth_scale, float depth_max)
TArrayIndexer< int64_t > NDArrayIndexer
Generic file read and write utility for python interface.