40#ifndef OPEN3D_SKIP_POINTCLOUD_MAIN
42#if defined(__CUDACC__)
44#elif defined(SYCL_LANGUAGE_VERSION)
50 std::optional<std::reference_wrapper<const core::Tensor>> image_colors,
52 std::optional<std::reference_wrapper<core::Tensor>> colors,
59 const bool have_colors = image_colors.has_value();
75 const auto& imcol = image_colors.value().get();
77 colors.value().get() =
core::Tensor({rows_strided * cols_strided, 3},
83#if defined(__CUDACC__) || defined(SYCL_LANGUAGE_VERSION)
85 int* count_ptr =
count.GetDataPtr<
int>();
87 std::atomic<int> count_atomic(0);
88 std::atomic<int>* count_ptr = &count_atomic;
91 int64_t n = rows_strided * cols_strided;
95 depth.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t workload_idx) {
96 int64_t y = (workload_idx / cols_strided) * stride;
97 int64_t x = (workload_idx % cols_strided) * stride;
99 float d = *depth_indexer.GetDataPtr<scalar_t>(x, y) /
101 if (d > 0 && d < depth_max) {
107 int idx = OPEN3D_ATOMIC_ADD(count_ptr, 1);
109 float x_c = 0, y_c = 0, z_c = 0;
110 ti.Unproject(static_cast<float>(x),
111 static_cast<float>(y), d, &x_c, &y_c,
114 float* vertex = point_indexer.GetDataPtr<float>(idx);
115 ti.RigidTransform(x_c, y_c, z_c, vertex + 0, vertex + 1,
119 colors_indexer.GetDataPtr<float>(idx);
121 image_colors_indexer.GetDataPtr<float>(x,
123 *pcd_pixel = *image_pixel;
124 *(pcd_pixel + 1) = *(image_pixel + 1);
125 *(pcd_pixel + 2) = *(image_pixel + 2);
130#if defined(__CUDACC__) || defined(SYCL_LANGUAGE_VERSION)
131 int total_pts_count =
count.Item<
int>();
133 int total_pts_count = (*count_ptr).load();
141 colors.value().get() =
142 colors.value().get().Slice(0, 0, total_pts_count);
146#if defined(__CUDACC__)
147void GetPointMaskWithinAABBCUDA
148#elif defined(SYCL_LANGUAGE_VERSION)
149void GetPointMaskWithinAABBSYCL
159 const scalar_t* points_ptr = points.GetDataPtr<scalar_t>();
160 const int64_t n = points.GetLength();
161 const scalar_t* min_bound_ptr = min_bound.GetDataPtr<scalar_t>();
162 const scalar_t* max_bound_ptr = max_bound.GetDataPtr<scalar_t>();
163 bool* mask_ptr = mask.GetDataPtr<bool>();
166 points.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t workload_idx) {
167 const scalar_t x = points_ptr[3 * workload_idx + 0];
168 const scalar_t y = points_ptr[3 * workload_idx + 1];
169 const scalar_t z = points_ptr[3 * workload_idx + 2];
171 if (x >= min_bound_ptr[0] && x <= max_bound_ptr[0] &&
172 y >= min_bound_ptr[1] && y <= max_bound_ptr[1] &&
173 z >= min_bound_ptr[2] && z <= max_bound_ptr[2]) {
174 mask_ptr[workload_idx] = true;
176 mask_ptr[workload_idx] = false;
182#if defined(__CUDACC__)
183void GetPointMaskWithinOBBCUDA
184#elif defined(SYCL_LANGUAGE_VERSION)
185void GetPointMaskWithinOBBSYCL
202 const scalar_t* pd_ptr = pd.GetDataPtr<scalar_t>();
204 const scalar_t* rotation_ptr = rotation_t.GetDataPtr<scalar_t>();
205 const scalar_t* half_extent_ptr = half_extent.GetDataPtr<scalar_t>();
206 bool* mask_ptr = mask.GetDataPtr<bool>();
208 core::ParallelFor(points.GetDevice(), n,
209 [=] OPEN3D_DEVICE(int64_t workload_idx) {
210 int64_t idx = 3 * workload_idx;
211 if (abs(core::linalg::kernel::dot_3x1(
212 pd_ptr + idx, rotation_ptr)) <=
213 half_extent_ptr[0] &&
214 abs(core::linalg::kernel::dot_3x1(
215 pd_ptr + idx, rotation_ptr + 3)) <=
216 half_extent_ptr[1] &&
217 abs(core::linalg::kernel::dot_3x1(
218 pd_ptr + idx, rotation_ptr + 6)) <=
219 half_extent_ptr[2]) {
220 mask_ptr[workload_idx] = true;
222 mask_ptr[workload_idx] = false;
228#if defined(__CUDACC__)
229void NormalizeNormalsCUDA
230#elif defined(SYCL_LANGUAGE_VERSION)
231void NormalizeNormalsSYCL
237 const int64_t n =
normals.GetLength();
240 scalar_t* ptr =
normals.GetDataPtr<scalar_t>();
244 int64_t idx = 3 * workload_idx;
245 scalar_t
x = ptr[idx];
246 scalar_t
y = ptr[idx + 1];
247 scalar_t
z = ptr[idx + 2];
248 scalar_t norm = sqrt(
x *
x +
y *
y +
z *
z);
261#if defined(__CUDACC__)
262void OrientNormalsToAlignWithDirectionCUDA
263#elif defined(SYCL_LANGUAGE_VERSION)
264void OrientNormalsToAlignWithDirectionSYCL
270 const int64_t n =
normals.GetLength();
273 scalar_t* ptr =
normals.GetDataPtr<scalar_t>();
274 const scalar_t* direction_ptr = direction.GetDataPtr<scalar_t>();
278 int64_t idx = 3 * workload_idx;
279 scalar_t* normal = ptr + idx;
280 const scalar_t norm = sqrt(normal[0] * normal[0] +
281 normal[1] * normal[1] +
282 normal[2] * normal[2]);
284 normal[0] = direction_ptr[0];
285 normal[1] = direction_ptr[1];
286 normal[2] = direction_ptr[2];
288 normal, direction_ptr) < 0) {
297#if defined(__CUDACC__)
298void OrientNormalsTowardsCameraLocationCUDA
299#elif defined(SYCL_LANGUAGE_VERSION)
300void OrientNormalsTowardsCameraLocationSYCL
308 const int64_t n =
normals.GetLength();
311 scalar_t* normals_ptr =
normals.GetDataPtr<scalar_t>();
312 const scalar_t* camera_ptr = camera.GetDataPtr<scalar_t>();
313 const scalar_t* points_ptr =
points.GetDataPtr<scalar_t>();
318 int64_t idx = 3 * workload_idx;
319 scalar_t* normal = normals_ptr + idx;
320 const scalar_t*
point = points_ptr + idx;
321 const scalar_t reference[3] = {camera_ptr[0] -
point[0],
322 camera_ptr[1] -
point[1],
323 camera_ptr[2] -
point[2]};
324 const scalar_t norm =
325 sqrt(normal[0] * normal[0] + normal[1] * normal[1] +
326 normal[2] * normal[2]);
328 normal[0] = reference[0];
329 normal[1] = reference[1];
330 normal[2] = reference[2];
331 const scalar_t norm_new = sqrt(normal[0] * normal[0] +
332 normal[1] * normal[1] +
333 normal[2] * normal[2]);
334 if (norm_new == 0.0) {
339 normal[0] /= norm_new;
340 normal[1] /= norm_new;
341 normal[2] /= norm_new;
355template <
typename scalar_t>
364 if (!(abs(query[0] - query[2]) < 1e-6) ||
365 !(abs(query[1] - query[2]) < 1e-6)) {
366 const scalar_t norm2_inv =
367 1.0 / sqrt(query[0] * query[0] + query[1] * query[1]);
368 v[0] = -1 * query[1] * norm2_inv;
369 v[1] = query[0] * norm2_inv;
372 const scalar_t norm2_inv =
373 1.0 / sqrt(query[1] * query[1] + query[2] * query[2]);
375 v[1] = -1 * query[2] * norm2_inv;
376 v[2] = query[1] * norm2_inv;
382template <
typename scalar_t>
389template <
typename scalar_t>
393 int l = 2 * largest + 1;
394 int r = 2 * largest + 2;
395 int next_largest = largest;
397 if (l < n && arr[l] > arr[next_largest]) {
400 if (r < n && arr[r] > arr[next_largest]) {
403 if (next_largest != largest) {
404 Swap<scalar_t>(&arr[largest], &arr[next_largest]);
405 largest = next_largest;
412template <
typename scalar_t>
414 for (
int i = n / 2 - 1; i >= 0; i--)
Heapify(arr, n, i);
416 for (
int i = n - 1; i > 0; i--) {
417 Swap<scalar_t>(&arr[0], &arr[i]);
418 Heapify<scalar_t>(arr, i, 0);
422template <
typename scalar_t>
425 double angle_threshold) {
427 scalar_t max_diff = 0;
429 for (
int i = 0; i <
counts - 1; i++) {
430 diff = angles[i + 1] - angles[i];
431 max_diff = max(max_diff, diff);
435 diff = 2 *
M_PI - angles[
counts - 1] + angles[0];
436 max_diff = max(max_diff, diff);
438 return max_diff > angle_threshold *
M_PI / 180.0 ? true :
false;
441#ifndef OPEN3D_SKIP_POINTCLOUD_MAIN
443#if defined(__CUDACC__)
444void ComputeBoundaryPointsCUDA
445#elif defined(SYCL_LANGUAGE_VERSION)
446void ComputeBoundaryPointsSYCL
455 double angle_threshold) {
456 const int nn_size =
indices.GetShape()[1];
459 const scalar_t* points_ptr = points.GetDataPtr<scalar_t>();
460 const scalar_t* normals_ptr = normals.GetDataPtr<scalar_t>();
461 const int64_t n = points.GetLength();
462 const int32_t* indices_ptr = indices.GetDataPtr<int32_t>();
463 const int32_t* counts_ptr = counts.GetDataPtr<int32_t>();
464 bool* mask_ptr = mask.GetDataPtr<bool>();
466 core::Tensor angles = core::Tensor::Full(
467 indices.GetShape(), -10, points.GetDtype(), points.GetDevice());
468 scalar_t* angles_ptr = angles.GetDataPtr<scalar_t>();
471 points.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t workload_idx) {
473 GetCoordinateSystemOnPlane(normals_ptr + 3 * workload_idx,
477 int indices_size = counts_ptr[workload_idx] - 1;
478 if (indices_size > 0) {
479 const scalar_t* query = points_ptr + 3 * workload_idx;
480 for (int i = 1; i < indices_size + 1; i++) {
481 const int idx = workload_idx * nn_size + i;
483 const scalar_t* point_ref =
484 points_ptr + 3 * indices_ptr[idx];
485 const scalar_t delta[3] = {point_ref[0] - query[0],
486 point_ref[1] - query[1],
487 point_ref[2] - query[2]};
488 const scalar_t angle = atan2(
489 core::linalg::kernel::dot_3x1(v, delta),
490 core::linalg::kernel::dot_3x1(u, delta));
492 angles_ptr[idx] = angle;
497 angles_ptr + workload_idx * nn_size + 1,
500 mask_ptr[workload_idx] = IsBoundaryPoints<scalar_t>(
501 angles_ptr + workload_idx * nn_size + 1,
502 indices_size, angle_threshold);
512template <
typename scalar_t>
514 const scalar_t* points_ptr,
515 const int32_t* indices_ptr,
516 const int32_t& indices_count,
517 scalar_t* covariance_ptr) {
518 if (indices_count < 3) {
519 covariance_ptr[0] = 1.0;
520 covariance_ptr[1] = 0.0;
521 covariance_ptr[2] = 0.0;
522 covariance_ptr[3] = 0.0;
523 covariance_ptr[4] = 1.0;
524 covariance_ptr[5] = 0.0;
525 covariance_ptr[6] = 0.0;
526 covariance_ptr[7] = 0.0;
527 covariance_ptr[8] = 1.0;
531 double centroid[3] = {0};
532 for (int32_t i = 0; i < indices_count; ++i) {
533 int32_t idx = 3 * indices_ptr[i];
534 centroid[0] += points_ptr[idx];
535 centroid[1] += points_ptr[idx + 1];
536 centroid[2] += points_ptr[idx + 2];
539 centroid[0] /= indices_count;
540 centroid[1] /= indices_count;
541 centroid[2] /= indices_count;
544 double cumulants[6] = {0};
545 for (int32_t i = 0; i < indices_count; ++i) {
546 int32_t idx = 3 * indices_ptr[i];
547 const double x =
static_cast<double>(points_ptr[idx]) - centroid[0];
548 const double y =
static_cast<double>(points_ptr[idx + 1]) - centroid[1];
549 const double z =
static_cast<double>(points_ptr[idx + 2]) - centroid[2];
551 cumulants[0] +=
x *
x;
552 cumulants[1] +=
y *
y;
553 cumulants[2] +=
z *
z;
555 cumulants[3] +=
x *
y;
556 cumulants[4] +=
x *
z;
557 cumulants[5] +=
y *
z;
563 const double normalization_factor =
static_cast<double>(indices_count - 1);
564 for (
int i = 0; i < 6; ++i) {
565 cumulants[i] /= normalization_factor;
569 covariance_ptr[0] =
static_cast<scalar_t
>(cumulants[0]);
571 covariance_ptr[4] =
static_cast<scalar_t
>(cumulants[1]);
573 covariance_ptr[8] =
static_cast<scalar_t
>(cumulants[2]);
576 covariance_ptr[1] =
static_cast<scalar_t
>(cumulants[3]);
577 covariance_ptr[3] = covariance_ptr[1];
580 covariance_ptr[2] =
static_cast<scalar_t
>(cumulants[4]);
581 covariance_ptr[6] = covariance_ptr[2];
584 covariance_ptr[5] =
static_cast<scalar_t
>(cumulants[5]);
585 covariance_ptr[7] = covariance_ptr[5];
588#if defined(__CUDACC__)
589void EstimateCovariancesUsingHybridSearchCUDA
590#elif defined(SYCL_LANGUAGE_VERSION)
591void EstimateCovariancesUsingHybridSearchSYCL
597 const double& radius,
598 const int64_t& max_nn) {
600 int64_t n =
points.GetLength();
603 bool check =
tree.HybridIndex(radius);
605 utility::LogError(
"Building FixedRadiusIndex failed.");
613 const scalar_t* points_ptr =
points.GetDataPtr<scalar_t>();
614 int32_t* neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
615 int32_t* neighbour_counts_ptr =
counts.GetDataPtr<int32_t>();
616 scalar_t* covariances_ptr = covariances.GetDataPtr<scalar_t>();
621 const int32_t neighbour_offset = max_nn * workload_idx;
623 const int32_t neighbour_count =
624 neighbour_counts_ptr[workload_idx];
627 const int32_t covariances_offset = 9 * workload_idx;
631 neighbour_indices_ptr + neighbour_offset,
633 covariances_ptr + covariances_offset);
640#if defined(__CUDACC__)
641void EstimateCovariancesUsingRadiusSearchCUDA
642#elif defined(SYCL_LANGUAGE_VERSION)
643void EstimateCovariancesUsingRadiusSearchSYCL
649 const double& radius) {
651 int64_t n =
points.GetLength();
654 bool check =
tree.FixedRadiusIndex(radius);
656 utility::LogError(
"Building Radius-Index failed.");
664 const scalar_t* points_ptr =
points.GetDataPtr<scalar_t>();
665 const int32_t* neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
666 const int32_t* neighbour_counts_ptr =
counts.GetDataPtr<int32_t>();
667 scalar_t* covariances_ptr = covariances.GetDataPtr<scalar_t>();
671 const int32_t neighbour_offset =
672 neighbour_counts_ptr[workload_idx];
673 const int32_t neighbour_count =
674 (neighbour_counts_ptr[workload_idx + 1] -
675 neighbour_counts_ptr[workload_idx]);
678 const int32_t covariances_offset = 9 * workload_idx;
682 neighbour_indices_ptr + neighbour_offset,
684 covariances_ptr + covariances_offset);
691#if defined(__CUDACC__)
692void EstimateCovariancesUsingKNNSearchCUDA
693#elif defined(SYCL_LANGUAGE_VERSION)
694void EstimateCovariancesUsingKNNSearchSYCL
700 const int64_t& max_nn) {
702 int64_t n =
points.GetLength();
705 bool check =
tree.KnnIndex();
707 utility::LogError(
"Building KNN-Index failed.");
714 int32_t nn_count =
static_cast<int32_t
>(
indices.GetShape()[1]);
718 "Not enough neighbors to compute Covariances / Normals. "
720 "increasing the max_nn parameter.");
724 auto points_ptr =
points.GetDataPtr<scalar_t>();
725 auto neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
726 auto covariances_ptr = covariances.GetDataPtr<scalar_t>();
731 const int32_t neighbour_offset = nn_count * workload_idx;
734 const int32_t covariances_offset = 9 * workload_idx;
738 neighbour_indices_ptr + neighbour_offset, nn_count,
739 covariances_ptr + covariances_offset);
746template <
typename scalar_t>
748 const scalar_t eval0,
749 scalar_t* eigen_vector0) {
750 scalar_t row0[3] = {A[0] - eval0, A[1], A[2]};
751 scalar_t row1[3] = {A[1], A[4] - eval0, A[5]};
752 scalar_t row2[3] = {A[2], A[5], A[8] - eval0};
754 scalar_t r0xr1[3], r0xr2[3], r1xr2[3];
775 scalar_t sqrt_d = sqrt(d0);
776 eigen_vector0[0] = r0xr1[0] / sqrt_d;
777 eigen_vector0[1] = r0xr1[1] / sqrt_d;
778 eigen_vector0[2] = r0xr1[2] / sqrt_d;
780 }
else if (imax == 1) {
781 scalar_t sqrt_d = sqrt(d1);
782 eigen_vector0[0] = r0xr2[0] / sqrt_d;
783 eigen_vector0[1] = r0xr2[1] / sqrt_d;
784 eigen_vector0[2] = r0xr2[2] / sqrt_d;
787 scalar_t sqrt_d = sqrt(d2);
788 eigen_vector0[0] = r1xr2[0] / sqrt_d;
789 eigen_vector0[1] = r1xr2[1] / sqrt_d;
790 eigen_vector0[2] = r1xr2[2] / sqrt_d;
795template <
typename scalar_t>
797 const scalar_t* evec0,
798 const scalar_t eval1,
799 scalar_t* eigen_vector1) {
801 if (abs(evec0[0]) > abs(evec0[1])) {
802 scalar_t inv_length =
803 1.0 / sqrt(evec0[0] * evec0[0] + evec0[2] * evec0[2]);
804 U[0] = -evec0[2] * inv_length;
806 U[2] = evec0[0] * inv_length;
808 scalar_t inv_length =
809 1.0 / sqrt(evec0[1] * evec0[1] + evec0[2] * evec0[2]);
811 U[1] = evec0[2] * inv_length;
812 U[2] = -evec0[1] * inv_length;
814 scalar_t V[3], AU[3], AV[3];
816 core::linalg::kernel::matmul3x3_3x1(A, U, AU);
817 core::linalg::kernel::matmul3x3_3x1(A, V, AV);
823 scalar_t absM00 = abs(m00);
824 scalar_t absM01 = abs(m01);
825 scalar_t absM11 = abs(m11);
826 scalar_t max_abs_comp;
828 if (absM00 >= absM11) {
829 max_abs_comp = max(absM00, absM01);
830 if (max_abs_comp > 0) {
831 if (absM00 >= absM01) {
833 m00 = 1 / sqrt(1 + m01 * m01);
837 m01 = 1 / sqrt(1 + m00 * m00);
840 eigen_vector1[0] = m01 * U[0] - m00 * V[0];
841 eigen_vector1[1] = m01 * U[1] - m00 * V[1];
842 eigen_vector1[2] = m01 * U[2] - m00 * V[2];
845 eigen_vector1[0] = U[0];
846 eigen_vector1[1] = U[1];
847 eigen_vector1[2] = U[2];
851 max_abs_comp = max(absM11, absM01);
852 if (max_abs_comp > 0) {
853 if (absM11 >= absM01) {
855 m11 = 1 / sqrt(1 + m01 * m01);
859 m01 = 1 / sqrt(1 + m11 * m11);
862 eigen_vector1[0] = m11 * U[0] - m01 * V[0];
863 eigen_vector1[1] = m11 * U[1] - m01 * V[1];
864 eigen_vector1[2] = m11 * U[2] - m01 * V[2];
867 eigen_vector1[0] = U[0];
868 eigen_vector1[1] = U[1];
869 eigen_vector1[2] = U[2];
875template <
typename scalar_t>
877 const scalar_t* covariance_ptr, scalar_t* normals_ptr) {
881 scalar_t max_coeff = covariance_ptr[0];
883 for (
int i = 1; i < 9; ++i) {
884 if (max_coeff < covariance_ptr[i]) {
885 max_coeff = covariance_ptr[i];
889 if (max_coeff == 0) {
890 normals_ptr[0] = 0.0;
891 normals_ptr[1] = 0.0;
892 normals_ptr[2] = 0.0;
898 for (
int i = 0; i < 9; ++i) {
899 A[i] = covariance_ptr[i] / max_coeff;
902 scalar_t norm = A[1] * A[1] + A[2] * A[2] + A[5] * A[5];
910 scalar_t q = (A[0] + A[4] + A[8]) / 3.0;
912 scalar_t b00 = A[0] - q;
913 scalar_t b11 = A[4] - q;
914 scalar_t b22 = A[8] - q;
917 sqrt((b00 * b00 + b11 * b11 + b22 * b22 + norm * 2.0) / 6.0);
919 scalar_t c00 = b11 * b22 - A[5] * A[5];
920 scalar_t c01 = A[1] * b22 - A[5] * A[2];
921 scalar_t c02 = A[1] * A[5] - b11 * A[2];
922 scalar_t det = (b00 * c00 - A[1] * c01 + A[2] * c02) / (p * p * p);
924 scalar_t half_det = det * 0.5;
925 half_det = min(max(half_det,
static_cast<scalar_t
>(-1.0)),
926 static_cast<scalar_t
>(1.0));
928 scalar_t angle = acos(half_det) / 3.0;
929 const scalar_t two_thrids_pi = 2.09439510239319549;
931 scalar_t beta2 = cos(angle) * 2.0;
932 scalar_t beta0 = cos(angle + two_thrids_pi) * 2.0;
933 scalar_t beta1 = -(beta0 + beta2);
935 eval[0] = q + p * beta0;
936 eval[1] = q + p * beta1;
937 eval[2] = q + p * beta2;
940 ComputeEigenvector0<scalar_t>(A, eval[2], evec2);
942 if (eval[2] < eval[0] && eval[2] < eval[1]) {
943 normals_ptr[0] = evec2[0];
944 normals_ptr[1] = evec2[1];
945 normals_ptr[2] = evec2[2];
950 ComputeEigenvector1<scalar_t>(A, evec2, eval[1], evec1);
952 if (eval[1] < eval[0] && eval[1] < eval[2]) {
953 normals_ptr[0] = evec1[0];
954 normals_ptr[1] = evec1[1];
955 normals_ptr[2] = evec1[2];
960 normals_ptr[0] = evec1[1] * evec2[2] - evec1[2] * evec2[1];
961 normals_ptr[1] = evec1[2] * evec2[0] - evec1[0] * evec2[2];
962 normals_ptr[2] = evec1[0] * evec2[1] - evec1[1] * evec2[0];
966 ComputeEigenvector0<scalar_t>(A, eval[0], evec0);
968 if (eval[0] < eval[1] && eval[0] < eval[2]) {
969 normals_ptr[0] = evec0[0];
970 normals_ptr[1] = evec0[1];
971 normals_ptr[2] = evec0[2];
975 ComputeEigenvector1<scalar_t>(A, evec0, eval[1], evec1);
977 if (eval[1] < eval[0] && eval[1] < eval[2]) {
978 normals_ptr[0] = evec1[0];
979 normals_ptr[1] = evec1[1];
980 normals_ptr[2] = evec1[2];
984 normals_ptr[0] = evec0[1] * evec1[2] - evec0[2] * evec1[1];
985 normals_ptr[1] = evec0[2] * evec1[0] - evec0[0] * evec1[2];
986 normals_ptr[2] = evec0[0] * evec1[1] - evec0[1] * evec1[0];
990 if (covariance_ptr[0] < covariance_ptr[4] &&
991 covariance_ptr[0] < covariance_ptr[8]) {
992 normals_ptr[0] = 1.0;
993 normals_ptr[1] = 0.0;
994 normals_ptr[2] = 0.0;
996 }
else if (covariance_ptr[4] < covariance_ptr[0] &&
997 covariance_ptr[4] < covariance_ptr[8]) {
998 normals_ptr[0] = 0.0;
999 normals_ptr[1] = 1.0;
1000 normals_ptr[2] = 0.0;
1003 normals_ptr[0] = 0.0;
1004 normals_ptr[1] = 0.0;
1005 normals_ptr[2] = 1.0;
1011#if defined(__CUDACC__)
1012void EstimateNormalsFromCovariancesCUDA
1013#elif defined(SYCL_LANGUAGE_VERSION)
1014void EstimateNormalsFromCovariancesSYCL
1022 int64_t n = covariances.GetLength();
1025 const scalar_t* covariances_ptr = covariances.GetDataPtr<scalar_t>();
1029 covariances.GetDevice(), n,
1031 int32_t covariances_offset = 9 * workload_idx;
1032 int32_t normals_offset = 3 * workload_idx;
1033 scalar_t normals_output[3] = {0};
1034 EstimatePointWiseNormalsWithFastEigen3x3<scalar_t>(
1035 covariances_ptr + covariances_offset,
1038 if ((normals_output[0] * normals_output[0] +
1039 normals_output[1] * normals_output[1] +
1040 normals_output[2] * normals_output[2]) == 0.0 &&
1042 normals_output[0] = 0.0;
1043 normals_output[1] = 0.0;
1044 normals_output[2] = 1.0;
1047 if ((normals_ptr[normals_offset] * normals_output[0] +
1048 normals_ptr[normals_offset + 1] *
1050 normals_ptr[normals_offset + 2] *
1051 normals_output[2]) < 0.0) {
1052 normals_output[0] *= -1;
1053 normals_output[1] *= -1;
1054 normals_output[2] *= -1;
1058 normals_ptr[normals_offset] = normals_output[0];
1059 normals_ptr[normals_offset + 1] = normals_output[1];
1060 normals_ptr[normals_offset + 2] = normals_output[2];
1067template <
typename scalar_t>
1069 const scalar_t* points_ptr,
1070 const scalar_t* normals_ptr,
1071 const scalar_t* colors_ptr,
1072 const int32_t& idx_offset,
1073 const int32_t* indices_ptr,
1074 const int32_t& indices_count,
1075 scalar_t* color_gradients_ptr) {
1076 if (indices_count < 4) {
1077 color_gradients_ptr[idx_offset] = 0;
1078 color_gradients_ptr[idx_offset + 1] = 0;
1079 color_gradients_ptr[idx_offset + 2] = 0;
1081 scalar_t vt[3] = {points_ptr[idx_offset], points_ptr[idx_offset + 1],
1082 points_ptr[idx_offset + 2]};
1084 scalar_t nt[3] = {normals_ptr[idx_offset], normals_ptr[idx_offset + 1],
1085 normals_ptr[idx_offset + 2]};
1087 scalar_t it = (colors_ptr[idx_offset] + colors_ptr[idx_offset + 1] +
1088 colors_ptr[idx_offset + 2]) /
1091 scalar_t AtA[9] = {0};
1092 scalar_t Atb[3] = {0};
1102 scalar_t s = vt[0] * nt[0] + vt[1] * nt[1] + vt[2] * nt[2];
1105 for (; i < indices_count; i++) {
1106 int64_t neighbour_idx_offset = 3 * indices_ptr[i];
1108 if (neighbour_idx_offset == -1) {
1112 scalar_t vt_adj[3] = {points_ptr[neighbour_idx_offset],
1113 points_ptr[neighbour_idx_offset + 1],
1114 points_ptr[neighbour_idx_offset + 2]};
1118 scalar_t d = vt_adj[0] * nt[0] + vt_adj[1] * nt[1] +
1119 vt_adj[2] * nt[2] - s;
1122 scalar_t vt_proj[3] = {vt_adj[0] - d * nt[0], vt_adj[1] - d * nt[1],
1123 vt_adj[2] - d * nt[2]};
1125 scalar_t it_adj = (colors_ptr[neighbour_idx_offset + 0] +
1126 colors_ptr[neighbour_idx_offset + 1] +
1127 colors_ptr[neighbour_idx_offset + 2]) /
1130 scalar_t A[3] = {vt_proj[0] - vt[0], vt_proj[1] - vt[1],
1131 vt_proj[2] - vt[2]};
1133 AtA[0] += A[0] * A[0];
1134 AtA[1] += A[1] * A[0];
1135 AtA[2] += A[2] * A[0];
1136 AtA[4] += A[1] * A[1];
1137 AtA[5] += A[2] * A[1];
1138 AtA[8] += A[2] * A[2];
1140 scalar_t b = it_adj - it;
1148 scalar_t A[3] = {(i - 1) * nt[0], (i - 1) * nt[1], (i - 1) * nt[2]};
1150 AtA[0] += A[0] * A[0];
1151 AtA[1] += A[0] * A[1];
1152 AtA[2] += A[0] * A[2];
1153 AtA[4] += A[1] * A[1];
1154 AtA[5] += A[1] * A[2];
1155 AtA[8] += A[2] * A[2];
1163 color_gradients_ptr + idx_offset);
1167#ifndef OPEN3D_SKIP_POINTCLOUD_MAIN
1169#if defined(__CUDACC__)
1170void EstimateColorGradientsUsingHybridSearchCUDA
1171#elif defined(SYCL_LANGUAGE_VERSION)
1172void EstimateColorGradientsUsingHybridSearchSYCL
1180 const double& radius,
1181 const int64_t& max_nn) {
1183 int64_t n =
points.GetLength();
1187 bool check =
tree.HybridIndex(radius);
1189 utility::LogError(
"NearestNeighborSearch::HybridIndex is not set.");
1197 auto points_ptr =
points.GetDataPtr<scalar_t>();
1199 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1200 auto neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
1201 auto neighbour_counts_ptr =
counts.GetDataPtr<int32_t>();
1202 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1207 int32_t neighbour_offset = max_nn * workload_idx;
1209 int32_t neighbour_count =
1210 neighbour_counts_ptr[workload_idx];
1211 int32_t idx_offset = 3 * workload_idx;
1214 points_ptr, normals_ptr, colors_ptr, idx_offset,
1215 neighbour_indices_ptr + neighbour_offset,
1216 neighbour_count, color_gradients_ptr);
1223#if defined(__CUDACC__)
1224void EstimateColorGradientsUsingKNNSearchCUDA
1225#elif defined(SYCL_LANGUAGE_VERSION)
1226void EstimateColorGradientsUsingKNNSearchSYCL
1234 const int64_t& max_nn) {
1236 int64_t n =
points.GetLength();
1240 bool check =
tree.KnnIndex();
1242 utility::LogError(
"KnnIndex is not set.");
1253 "Not enough neighbors to compute Covariances / Normals. "
1255 "changing the search parameter.");
1259 auto points_ptr =
points.GetDataPtr<scalar_t>();
1261 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1262 auto neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
1263 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1267 int32_t neighbour_offset = max_nn * workload_idx;
1268 int32_t idx_offset = 3 * workload_idx;
1271 points_ptr, normals_ptr, colors_ptr, idx_offset,
1272 neighbour_indices_ptr + neighbour_offset, nn_count,
1273 color_gradients_ptr);
1280#if defined(__CUDACC__)
1281void EstimateColorGradientsUsingRadiusSearchCUDA
1282#elif defined(SYCL_LANGUAGE_VERSION)
1283void EstimateColorGradientsUsingRadiusSearchSYCL
1291 const double& radius) {
1293 int64_t n =
points.GetLength();
1297 bool check =
tree.FixedRadiusIndex(radius);
1299 utility::LogError(
"RadiusIndex is not set.");
1310 auto points_ptr =
points.GetDataPtr<scalar_t>();
1312 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1313 auto neighbour_indices_ptr =
indices.GetDataPtr<int32_t>();
1314 auto neighbour_counts_ptr =
counts.GetDataPtr<int32_t>();
1315 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1319 int32_t neighbour_offset =
1320 neighbour_counts_ptr[workload_idx];
1322 const int32_t neighbour_count =
1323 (neighbour_counts_ptr[workload_idx + 1] -
1324 neighbour_counts_ptr[workload_idx]);
1325 int32_t idx_offset = 3 * workload_idx;
1328 points_ptr, normals_ptr, colors_ptr, idx_offset,
1329 neighbour_indices_ptr + neighbour_offset,
1330 neighbour_count, color_gradients_ptr);
1346 const int64_t neighbor_count =
1347 std::min<int64_t>(
points.GetLength(), int64_t(max_nn) + 1);
1349 if (!nns.KnnIndex()) {
1350 utility::LogError(
"Building KNN index failed.");
1353 std::tie(
indices, distances) = nns.KnnSearch(
points, neighbor_count);
1362 const int64_t neighbor_count =
indices.GetShape()[1];
1365 const scalar_t* points_ptr = points.GetDataPtr<scalar_t>();
1366 const int32_t* indices_ptr = indices.GetDataPtr<int32_t>();
1367 scalar_t* output_ptr = smoothed_points.GetDataPtr<scalar_t>();
1369 points.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t point_idx) {
1370 scalar_t mean[3] = {0, 0, 0};
1372 for (int64_t neighbor = 0; neighbor < neighbor_count;
1374 const int32_t neighbor_idx =
1375 indices_ptr[point_idx * neighbor_count +
1377 if (neighbor_idx < 0 || neighbor_idx == point_idx) {
1380 mean[0] += points_ptr[3 * neighbor_idx + 0];
1381 mean[1] += points_ptr[3 * neighbor_idx + 1];
1382 mean[2] += points_ptr[3 * neighbor_idx + 2];
1385 const int64_t offset = 3 * point_idx;
1387 output_ptr[offset + 0] = points_ptr[offset + 0];
1388 output_ptr[offset + 1] = points_ptr[offset + 1];
1389 output_ptr[offset + 2] = points_ptr[offset + 2];
1392 const scalar_t inv_count =
1393 static_cast<scalar_t>(1.0 / count);
1394 const scalar_t alpha = static_cast<scalar_t>(factor);
1395 output_ptr[offset + 0] = points_ptr[offset + 0] +
1396 alpha * (mean[0] * inv_count -
1397 points_ptr[offset + 0]);
1398 output_ptr[offset + 1] = points_ptr[offset + 1] +
1399 alpha * (mean[1] * inv_count -
1400 points_ptr[offset + 1]);
1401 output_ptr[offset + 2] = points_ptr[offset + 2] +
1402 alpha * (mean[2] * inv_count -
1403 points_ptr[offset + 2]);
1410#if defined(__CUDACC__)
1411void SmoothLaplacianCUDA
1412#elif defined(SYCL_LANGUAGE_VERSION)
1413void SmoothLaplacianSYCL
1422 bool use_fixed_neighborhoods) {
1423 if (
points.GetLength() == 0 || iterations == 0 || max_nn <= 0) {
1424 smoothed_points =
points.Clone();
1430 if (use_fixed_neighborhoods) {
1431 BuildKnnNeighborhoods(current, max_nn, fixed_indices);
1433 for (
size_t iteration = 0; iteration < iterations; ++iteration) {
1435 if (use_fixed_neighborhoods) {
1438 BuildKnnNeighborhoods(current, max_nn,
indices);
1442 ApplyLaplacianPass(current,
next,
indices, lambda);
1445 smoothed_points = current;
1448#if defined(__CUDACC__)
1449void SmoothTaubinCUDA
1450#elif defined(SYCL_LANGUAGE_VERSION)
1451void SmoothTaubinSYCL
1461 bool use_fixed_neighborhoods) {
1462 if (
points.GetLength() == 0 || iterations == 0 || max_nn <= 0) {
1463 smoothed_points =
points.Clone();
1469 if (use_fixed_neighborhoods) {
1470 BuildKnnNeighborhoods(current, max_nn, fixed_indices);
1472 for (
size_t iteration = 0; iteration < iterations; ++iteration) {
1474 if (use_fixed_neighborhoods) {
1475 lambda_indices = fixed_indices;
1477 BuildKnnNeighborhoods(current, max_nn, lambda_indices);
1481 ApplyLaplacianPass(current, after_lambda, lambda_indices, lambda);
1484 if (use_fixed_neighborhoods) {
1485 mu_indices = fixed_indices;
1487 BuildKnnNeighborhoods(after_lambda, max_nn, mu_indices);
1491 ApplyLaplacianPass(after_lambda, after_mu, mu_indices, mu);
1494 smoothed_points = current;
1497#if defined(__CUDACC__)
1499#elif defined(SYCL_LANGUAGE_VERSION)
1507 bool update_normals,
1510 smoothed_points =
points.Clone();
1511 if (
points.GetLength() == 0 || (radius <= 0.0 && max_nn <= 0)) {
1517 bool radius_search =
false;
1518 int64_t fixed_count = 0;
1519 if (radius > 0.0 && max_nn > 0) {
1521 utility::LogError(
"Building hybrid index failed.");
1525 fixed_count = max_nn;
1526 }
else if (max_nn > 0) {
1528 fixed_count =
indices.GetShape()[1];
1529 distances = core::Tensor::Zeros(
indices.GetShape(),
points.GetDtype(),
1533 utility::LogError(
"Building radius index failed.");
1537 radius_search =
true;
1541 if (
counts.NumElements() > 0) {
1547 const scalar_t* points_ptr = points.GetDataPtr<scalar_t>();
1548 const int32_t* indices_ptr = indices.GetDataPtr<int32_t>();
1549 const scalar_t* distances_ptr = distances.GetDataPtr<scalar_t>();
1550 const int32_t* counts_ptr = counts.NumElements() > 0
1551 ? counts.GetDataPtr<int32_t>()
1553 scalar_t* output_ptr = smoothed_points.GetDataPtr<scalar_t>();
1554 scalar_t* normals_ptr =
1555 update_normals ? normals.GetDataPtr<scalar_t>() : nullptr;
1556 const scalar_t inv_radius2 =
1557 radius > 0.0 ? static_cast<scalar_t>(1.0 / (radius * radius))
1558 : static_cast<scalar_t>(0.0);
1560 points.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t point_idx) {
1561 const int32_t offset = radius_search
1562 ? counts_ptr[point_idx]
1563 : point_idx * fixed_count;
1564 const int32_t count =
1565 radius_search ? counts_ptr[point_idx + 1] -
1566 counts_ptr[point_idx]
1567 : (counts_ptr ? counts_ptr[point_idx]
1569 const int64_t point_offset = 3 * point_idx;
1571 if (update_normals) {
1572 scalar_t* normal = normals_ptr + point_offset;
1573 const scalar_t norm = sqrt(normal[0] * normal[0] +
1574 normal[1] * normal[1] +
1575 normal[2] * normal[2]);
1585 scalar_t centroid[3] = {0, 0, 0};
1586 scalar_t weight_sum = 0;
1587 for (int32_t neighbor = 0; neighbor < count; ++neighbor) {
1588 const int32_t neighbor_idx =
1589 indices_ptr[offset + neighbor];
1590 if (neighbor_idx < 0) continue;
1591 const scalar_t weight =
1592 exp(-distances_ptr[offset + neighbor] *
1595 weight * points_ptr[3 * neighbor_idx + 0];
1597 weight * points_ptr[3 * neighbor_idx + 1];
1599 weight * points_ptr[3 * neighbor_idx + 2];
1600 weight_sum += weight;
1602 if (weight_sum <= 0) return;
1603 centroid[0] /= weight_sum;
1604 centroid[1] /= weight_sum;
1605 centroid[2] /= weight_sum;
1607 scalar_t covariance[9] = {0};
1608 for (int32_t neighbor = 0; neighbor < count; ++neighbor) {
1609 const int32_t neighbor_idx =
1610 indices_ptr[offset + neighbor];
1611 if (neighbor_idx < 0) continue;
1612 const scalar_t weight =
1613 exp(-distances_ptr[offset + neighbor] *
1616 points_ptr[3 * neighbor_idx + 0] - centroid[0];
1618 points_ptr[3 * neighbor_idx + 1] - centroid[1];
1620 points_ptr[3 * neighbor_idx + 2] - centroid[2];
1621 covariance[0] += weight * x * x;
1622 covariance[1] += weight * x * y;
1623 covariance[2] += weight * x * z;
1624 covariance[4] += weight * y * y;
1625 covariance[5] += weight * y * z;
1626 covariance[8] += weight * z * z;
1628 covariance[3] = covariance[1];
1629 covariance[6] = covariance[2];
1630 covariance[7] = covariance[5];
1632 EstimatePointWiseNormalsWithFastEigen3x3(covariance,
1634 const scalar_t projection =
1635 (points_ptr[point_offset + 0] - centroid[0]) *
1637 (points_ptr[point_offset + 1] - centroid[1]) *
1639 (points_ptr[point_offset + 2] - centroid[2]) *
1641 output_ptr[point_offset + 0] =
1642 points_ptr[point_offset + 0] -
1643 projection * normal[0];
1644 output_ptr[point_offset + 1] =
1645 points_ptr[point_offset + 1] -
1646 projection * normal[1];
1647 output_ptr[point_offset + 2] =
1648 points_ptr[point_offset + 2] -
1649 projection * normal[2];
1650 if (update_normals) {
1651 normals_ptr[point_offset + 0] = normal[0];
1652 normals_ptr[point_offset + 1] = normal[1];
1653 normals_ptr[point_offset + 2] = normal[2];
1659#if defined(__CUDACC__)
1660void SmoothBilateralCUDA
1661#elif defined(SYCL_LANGUAGE_VERSION)
1662void SmoothBilateralSYCL
1673 smoothed_points =
points.Clone();
1674 if (
points.GetLength() == 0)
return;
1678 utility::LogError(
"Building hybrid index failed.");
1689 const scalar_t* points_ptr = points.GetDataPtr<scalar_t>();
1690 const scalar_t* normals_ptr = normals.GetDataPtr<scalar_t>();
1691 const int32_t* indices_ptr = indices.GetDataPtr<int32_t>();
1692 const scalar_t* distances_ptr = distances.GetDataPtr<scalar_t>();
1693 const int32_t* counts_ptr = counts.GetDataPtr<int32_t>();
1694 scalar_t* output_ptr = smoothed_points.GetDataPtr<scalar_t>();
1695 const scalar_t inv_sigma_s2 =
1696 static_cast<scalar_t>(1.0 / (2.0 * sigma_s * sigma_s));
1697 const scalar_t inv_sigma_r2 =
1698 static_cast<scalar_t>(1.0 / (2.0 * sigma_r * sigma_r));
1700 points.GetDevice(), n, [=] OPEN3D_DEVICE(int64_t point_idx) {
1701 const int32_t count = counts_ptr[point_idx];
1702 if (count <= 1) return;
1703 const int64_t point_offset = 3 * point_idx;
1704 scalar_t nx = normals_ptr[point_offset + 0];
1705 scalar_t ny = normals_ptr[point_offset + 1];
1706 scalar_t nz = normals_ptr[point_offset + 2];
1707 const scalar_t normal_norm =
1708 sqrt(nx * nx + ny * ny + nz * nz);
1709 if (normal_norm <= 0) return;
1713 scalar_t weighted_sum[3] = {0, 0, 0};
1714 scalar_t weight_sum = 0;
1715 const int64_t offset = point_idx * max_nn;
1716 for (int32_t neighbor = 0; neighbor < count; ++neighbor) {
1717 const int32_t neighbor_idx =
1718 indices_ptr[offset + neighbor];
1719 if (neighbor_idx < 0) continue;
1720 const int64_t neighbor_offset = 3 * neighbor_idx;
1721 const scalar_t range_distance =
1722 (points_ptr[point_offset + 0] -
1723 points_ptr[neighbor_offset + 0]) *
1725 (points_ptr[point_offset + 1] -
1726 points_ptr[neighbor_offset + 1]) *
1728 (points_ptr[point_offset + 2] -
1729 points_ptr[neighbor_offset + 2]) *
1731 const scalar_t weight = exp(
1732 -distances_ptr[offset + neighbor] *
1734 range_distance * range_distance * inv_sigma_r2);
1736 weight * points_ptr[neighbor_offset + 0];
1738 weight * points_ptr[neighbor_offset + 1];
1740 weight * points_ptr[neighbor_offset + 2];
1741 weight_sum += weight;
1743 if (weight_sum > 0) {
1744 output_ptr[point_offset + 0] =
1745 weighted_sum[0] / weight_sum;
1746 output_ptr[point_offset + 1] =
1747 weighted_sum[1] / weight_sum;
1748 output_ptr[point_offset + 2] =
1749 weighted_sum[2] / weight_sum;
#define OPEN3D_HOST_DEVICE
Definition CUDAUtils.h:43
#define OPEN3D_DEVICE
Definition CUDAUtils.h:44
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition Dispatch.h:30
#define DISPATCH_FLOAT_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition Dispatch.h:77
math::float4 next
Definition LineSetBuffers.cpp:44
std::vector< int > indices
Definition PointCloudSmoothing.cpp:133
std::vector< int > counts
Definition PointCloudSmoothing.cpp:132
double t
Definition SurfaceReconstructionPoisson.cpp:175
Point< Real, 3 > point
Definition SurfaceReconstructionPoisson.cpp:166
FEMTree< Dim, Real > & tree
Definition SurfaceReconstructionPoisson.cpp:174
size_t stride
Definition TriangleMeshBuffers.cpp:163
SizeVector GetShape() const
Definition Tensor.h:1186
int64_t GetLength() const
Definition Tensor.h:1184
T * GetDataPtr()
Definition Tensor.h:1203
Tensor Div(const Tensor &value) const
Divides a tensor and returns the resulting tensor.
Definition Tensor.cpp:1301
Tensor Contiguous() const
Definition Tensor.cpp:817
Tensor Transpose(int64_t dim0, int64_t dim1) const
Transpose a Tensor by swapping dimension dim0 and dim1.
Definition Tensor.cpp:1141
Device GetDevice() const override
Definition Tensor.cpp:1556
Dtype GetDtype() const
Definition Tensor.h:1223
Tensor To(Dtype dtype, bool copy=false) const
Definition Tensor.cpp:784
Facade for batched KNN, fixed-radius, hybrid, and multi-radius search.
Definition NearestNeighborSearch.h:29
bool HybridIndex(std::optional< double > radius={})
Definition NearestNeighborSearch.cpp:66
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, const double radius, const int max_knn) const
Definition NearestNeighborSearch.cpp:144
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
Definition NearestNeighborSearch.cpp:112
bool FixedRadiusIndex(std::optional< double > radius={})
Definition NearestNeighborSearch.cpp:37
Definition GeometryIndexer.h:160
OPEN3D_HOST_DEVICE index_t GetShape(int i) const
Definition GeometryIndexer.h:310
void Synchronize()
Definition CUDAUtils.cpp:58
OPEN3D_HOST_DEVICE OPEN3D_FORCE_INLINE void cross_3x1(const scalar_t *A_3x1_input, const scalar_t *B_3x1_input, scalar_t *C_3x1_output)
Definition Matrix.h:63
OPEN3D_DEVICE OPEN3D_FORCE_INLINE void solve_svd3x3(const scalar_t *A_3x3, const scalar_t *B_3x1, scalar_t *X_3x1)
Definition SVD3x3.h:2171
OPEN3D_HOST_DEVICE OPEN3D_FORCE_INLINE scalar_t dot_3x1(const scalar_t *A_3x1_input, const scalar_t *B_3x1_input)
Definition Matrix.h:89
const Dtype Int32
Definition Dtype.cpp:46
void ParallelFor(const Device &device, int64_t n, const func_t &func)
Definition ParallelFor.h:190
const Dtype Float32
Definition Dtype.cpp:42
void EstimateCovariancesUsingHybridSearchCPU(const core::Tensor &points, core::Tensor &covariances, const double &radius, const int64_t &max_nn)
Definition PointCloudImpl.h:595
void SmoothMLSCPU(const core::Tensor &points, core::Tensor &smoothed_points, core::Tensor &normals, bool update_normals, double radius, int max_nn)
Definition PointCloudImpl.h:1504
void EstimateCovariancesUsingRadiusSearchCPU(const core::Tensor &points, core::Tensor &covariances, const double &radius)
Definition PointCloudImpl.h:647
OPEN3D_HOST_DEVICE void GetCoordinateSystemOnPlane(const scalar_t *query, scalar_t *u, scalar_t *v)
Definition PointCloudImpl.h:356
void SmoothTaubinCPU(const core::Tensor &points, core::Tensor &smoothed_points, size_t iterations, double lambda, double mu, int max_nn, bool use_fixed_neighborhoods)
Definition PointCloudImpl.h:1455
void EstimateNormalsFromCovariancesCPU(const core::Tensor &covariances, core::Tensor &normals, const bool has_normals)
Definition PointCloudImpl.h:1018
OPEN3D_HOST_DEVICE void ComputeEigenvector0(const scalar_t *A, const scalar_t eval0, scalar_t *eigen_vector0)
Definition PointCloudImpl.h:747
void OrientNormalsTowardsCameraLocationCPU(const core::Tensor &points, core::Tensor &normals, const core::Tensor &camera)
Definition PointCloudImpl.h:304
OPEN3D_HOST_DEVICE void EstimatePointWiseRobustNormalizedCovarianceKernel(const scalar_t *points_ptr, const int32_t *indices_ptr, const int32_t &indices_count, scalar_t *covariance_ptr)
Definition PointCloudImpl.h:513
void GetPointMaskWithinAABBCPU(const core::Tensor &points, const core::Tensor &min_bound, const core::Tensor &max_bound, core::Tensor &mask)
Definition PointCloudImpl.h:153
OPEN3D_HOST_DEVICE void Swap(scalar_t *x, scalar_t *y)
Definition PointCloudImpl.h:383
OPEN3D_HOST_DEVICE bool IsBoundaryPoints(const scalar_t *angles, int counts, double angle_threshold)
Definition PointCloudImpl.h:423
void ComputeBoundaryPointsCPU(const core::Tensor &points, const core::Tensor &normals, const core::Tensor &indices, const core::Tensor &counts, core::Tensor &mask, double angle_threshold)
Definition PointCloudImpl.h:450
void SmoothLaplacianCPU(const core::Tensor &points, core::Tensor &smoothed_points, size_t iterations, double lambda, int max_nn, bool use_fixed_neighborhoods)
Definition PointCloudImpl.h:1417
void SmoothBilateralCPU(const core::Tensor &points, const core::Tensor &normals, core::Tensor &smoothed_points, double radius, int max_nn, double sigma_s, double sigma_r)
Definition PointCloudImpl.h:1666
void EstimateColorGradientsUsingKNNSearchCPU(const core::Tensor &points, const core::Tensor &normals, const core::Tensor &colors, core::Tensor &color_gradient, const int64_t &max_nn)
Definition PointCloudImpl.h:1230
void UnprojectCPU(const core::Tensor &depth, std::optional< std::reference_wrapper< const core::Tensor > > image_colors, core::Tensor &points, std::optional< std::reference_wrapper< core::Tensor > > colors, const core::Tensor &intrinsics, const core::Tensor &extrinsics, float depth_scale, float depth_max, int64_t stride)
Definition PointCloudImpl.h:49
void NormalizeNormalsCPU(core::Tensor &normals)
Definition PointCloudImpl.h:235
OPEN3D_HOST_DEVICE void ComputeEigenvector1(const scalar_t *A, const scalar_t *evec0, const scalar_t eval1, scalar_t *eigen_vector1)
Definition PointCloudImpl.h:796
OPEN3D_HOST_DEVICE void EstimatePointWiseColorGradientKernel(const scalar_t *points_ptr, const scalar_t *normals_ptr, const scalar_t *colors_ptr, const int32_t &idx_offset, const int32_t *indices_ptr, const int32_t &indices_count, scalar_t *color_gradients_ptr)
Definition PointCloudImpl.h:1068
void EstimateColorGradientsUsingRadiusSearchCPU(const core::Tensor &points, const core::Tensor &normals, const core::Tensor &colors, core::Tensor &color_gradient, const double &radius)
Definition PointCloudImpl.h:1287
void GetPointMaskWithinOBBCPU(const core::Tensor &points, const core::Tensor ¢er, const core::Tensor &rotation, const core::Tensor &extent, core::Tensor &mask)
Definition PointCloudImpl.h:189
void EstimateColorGradientsUsingHybridSearchCPU(const core::Tensor &points, const core::Tensor &normals, const core::Tensor &colors, core::Tensor &color_gradient, const double &radius, const int64_t &max_nn)
Definition PointCloudImpl.h:1176
OPEN3D_HOST_DEVICE void EstimatePointWiseNormalsWithFastEigen3x3(const scalar_t *covariance_ptr, scalar_t *normals_ptr)
Definition PointCloudImpl.h:876
OPEN3D_HOST_DEVICE void Heapify(scalar_t *arr, int n, int root)
Definition PointCloudImpl.h:390
void OrientNormalsToAlignWithDirectionCPU(core::Tensor &normals, const core::Tensor &direction)
Definition PointCloudImpl.h:268
void EstimateCovariancesUsingKNNSearchCPU(const core::Tensor &points, core::Tensor &covariances, const int64_t &max_nn)
Definition PointCloudImpl.h:698
TArrayIndexer< int64_t > NDArrayIndexer
Definition GeometryIndexer.h:359
core::Tensor InverseTransformation(const core::Tensor &T)
TODO(wei): find a proper place for such functionalities.
Definition Utility.h:77
Definition PinholeCameraIntrinsic.cpp:16
const core::Tensor * normals
Definition TriangleMesh.cpp:2126