49 namespace pointcloud {
58 #if defined(__CUDACC__) 74 const bool have_colors = image_colors.has_value();
90 const auto& imcol = image_colors.value().get();
92 colors.value().get() =
core::Tensor({rows_strided * cols_strided, 3},
98 #if defined(__CUDACC__) 100 int* count_ptr =
count.GetDataPtr<
int>();
102 std::atomic<int> count_atomic(0);
103 std::atomic<int>* count_ptr = &count_atomic;
106 int64_t n = rows_strided * cols_strided;
111 int64_t y = (workload_idx / cols_strided) *
stride;
112 int64_t x = (workload_idx % cols_strided) *
stride;
114 float d = *depth_indexer.
GetDataPtr<scalar_t>(x, y) /
116 if (d > 0 && d < depth_max) {
119 float x_c = 0, y_c = 0, z_c = 0;
121 static_cast<float>(y), d, &x_c, &y_c,
124 float* vertex = point_indexer.GetDataPtr<
float>(idx);
133 *pcd_pixel = *image_pixel;
134 *(pcd_pixel + 1) = *(image_pixel + 1);
135 *(pcd_pixel + 2) = *(image_pixel + 2);
140 #if defined(__CUDACC__) 141 int total_pts_count =
count.Item<
int>();
143 int total_pts_count = (*count_ptr).load();
149 points = points.Slice(0, 0, total_pts_count);
151 colors.value().get() =
152 colors.value().get().Slice(0, 0, total_pts_count);
156 #if defined(__CUDACC__) 157 void GetPointMaskWithinAABBCUDA
167 const scalar_t* points_ptr = points.
GetDataPtr<scalar_t>();
169 const scalar_t* min_bound_ptr = min_bound.GetDataPtr<scalar_t>();
170 const scalar_t* max_bound_ptr = max_bound.GetDataPtr<scalar_t>();
171 bool* mask_ptr = mask.GetDataPtr<
bool>();
175 const scalar_t x = points_ptr[3 * workload_idx + 0];
176 const scalar_t y = points_ptr[3 * workload_idx + 1];
177 const scalar_t z = points_ptr[3 * workload_idx + 2];
179 if (x >= min_bound_ptr[0] && x <= max_bound_ptr[0] &&
180 y >= min_bound_ptr[1] && y <= max_bound_ptr[1] &&
181 z >= min_bound_ptr[2] && z <= max_bound_ptr[2]) {
182 mask_ptr[workload_idx] =
true;
184 mask_ptr[workload_idx] =
false;
190 template <
typename scalar_t>
199 if (!(abs(query[0] - query[2]) < 1e-6) ||
200 !(abs(query[1] - query[2]) < 1e-6)) {
201 const scalar_t norm2_inv =
202 1.0 / sqrt(query[0] * query[0] + query[1] * query[1]);
203 v[0] = -1 * query[1] * norm2_inv;
204 v[1] = query[0] * norm2_inv;
207 const scalar_t norm2_inv =
208 1.0 / sqrt(query[1] * query[1] + query[2] * query[2]);
210 v[1] = -1 * query[2] * norm2_inv;
211 v[2] = query[1] * norm2_inv;
217 template <
typename scalar_t>
224 template <
typename scalar_t>
227 int l = 2 * root + 1;
228 int r = 2 * root + 2;
230 if (l < n && arr[l] > arr[largest]) {
233 if (r < n && arr[r] > arr[largest]) {
236 if (largest != root) {
237 Swap<scalar_t>(&arr[root], &arr[largest]);
238 Heapify<scalar_t>(arr, n, largest);
242 template <
typename scalar_t>
244 for (
int i = n / 2 - 1; i >= 0; i--)
Heapify(arr, n, i);
246 for (
int i = n - 1; i > 0; i--) {
247 Swap<scalar_t>(&arr[0], &arr[i]);
248 Heapify<scalar_t>(arr, i, 0);
252 template <
typename scalar_t>
255 double angle_threshold) {
257 scalar_t max_diff = 0;
259 for (
int i = 0; i < counts - 1; i++) {
260 diff = angles[i + 1] - angles[i];
261 max_diff = max(max_diff, diff);
265 diff = 2 * M_PI - angles[counts - 1] + angles[0];
266 max_diff = max(max_diff, diff);
268 return max_diff > angle_threshold * M_PI / 180.0 ? true :
false;
271 #if defined(__CUDACC__) 272 void ComputeBoundaryPointsCUDA
281 double angle_threshold) {
283 const int nn_size = indices.GetShape()[1];
286 const scalar_t* points_ptr = points.
GetDataPtr<scalar_t>();
287 const scalar_t* normals_ptr = normals.GetDataPtr<scalar_t>();
291 bool* mask_ptr = mask.GetDataPtr<
bool>();
295 scalar_t* angles_ptr = angles.
GetDataPtr<scalar_t>();
304 int indices_size = counts_ptr[workload_idx] - 1;
305 if (indices_size > 0) {
306 const scalar_t* query = points_ptr + 3 * workload_idx;
307 for (
int i = 1; i < indices_size + 1; i++) {
308 const int idx = workload_idx * nn_size + i;
310 const scalar_t* point_ref =
311 points_ptr + 3 * indices_ptr[idx];
312 const scalar_t delta[3] = {point_ref[0] - query[0],
313 point_ref[1] - query[1],
314 point_ref[2] - query[2]};
315 const scalar_t angle = atan2(
319 angles_ptr[idx] = angle;
324 angles_ptr + workload_idx * nn_size + 1,
327 mask_ptr[workload_idx] = IsBoundaryPoints<scalar_t>(
328 angles_ptr + workload_idx * nn_size + 1,
329 indices_size, angle_threshold);
337 template <
typename scalar_t>
339 const scalar_t* points_ptr,
342 scalar_t* covariance_ptr) {
343 if (indices_count < 3) {
344 covariance_ptr[0] = 1.0;
345 covariance_ptr[1] = 0.0;
346 covariance_ptr[2] = 0.0;
347 covariance_ptr[3] = 0.0;
348 covariance_ptr[4] = 1.0;
349 covariance_ptr[5] = 0.0;
350 covariance_ptr[6] = 0.0;
351 covariance_ptr[7] = 0.0;
352 covariance_ptr[8] = 1.0;
356 double centroid[3] = {0};
357 for (
int32_t i = 0; i < indices_count; ++i) {
358 int32_t idx = 3 * indices_ptr[i];
359 centroid[0] += points_ptr[idx];
360 centroid[1] += points_ptr[idx + 1];
361 centroid[2] += points_ptr[idx + 2];
364 centroid[0] /= indices_count;
365 centroid[1] /= indices_count;
366 centroid[2] /= indices_count;
369 double cumulants[6] = {0};
370 for (
int32_t i = 0; i < indices_count; ++i) {
371 int32_t idx = 3 * indices_ptr[i];
372 const double x =
static_cast<double>(points_ptr[idx]) - centroid[0];
373 const double y =
static_cast<double>(points_ptr[idx + 1]) - centroid[1];
374 const double z =
static_cast<double>(points_ptr[idx + 2]) - centroid[2];
376 cumulants[0] += x * x;
377 cumulants[1] += y * y;
378 cumulants[2] += z * z;
380 cumulants[3] += x * y;
381 cumulants[4] += x * z;
382 cumulants[5] += y * z;
388 const double normalization_factor =
static_cast<double>(indices_count - 1);
389 for (
int i = 0; i < 6; ++i) {
390 cumulants[i] /= normalization_factor;
394 covariance_ptr[0] =
static_cast<scalar_t
>(cumulants[0]);
396 covariance_ptr[4] =
static_cast<scalar_t
>(cumulants[1]);
398 covariance_ptr[8] =
static_cast<scalar_t
>(cumulants[2]);
401 covariance_ptr[1] =
static_cast<scalar_t
>(cumulants[3]);
402 covariance_ptr[3] = covariance_ptr[1];
405 covariance_ptr[2] =
static_cast<scalar_t
>(cumulants[4]);
406 covariance_ptr[6] = covariance_ptr[2];
409 covariance_ptr[5] =
static_cast<scalar_t
>(cumulants[5]);
410 covariance_ptr[7] = covariance_ptr[5];
413 #if defined(__CUDACC__) 414 void EstimateCovariancesUsingHybridSearchCUDA
420 const double& radius,
421 const int64_t& max_nn) {
432 std::tie(indices, distance, counts) =
436 const scalar_t* points_ptr = points.
GetDataPtr<scalar_t>();
439 scalar_t* covariances_ptr = covariances.GetDataPtr<scalar_t>();
444 const int32_t neighbour_offset = max_nn * workload_idx;
446 const int32_t neighbour_count =
447 neighbour_counts_ptr[workload_idx];
450 const int32_t covariances_offset = 9 * workload_idx;
454 neighbour_indices_ptr + neighbour_offset,
456 covariances_ptr + covariances_offset);
463 #if defined(__CUDACC__) 464 void EstimateCovariancesUsingRadiusSearchCUDA
470 const double& radius) {
481 std::tie(indices, distance, counts) =
485 const scalar_t* points_ptr = points.
GetDataPtr<scalar_t>();
488 scalar_t* covariances_ptr = covariances.GetDataPtr<scalar_t>();
492 const int32_t neighbour_offset =
493 neighbour_counts_ptr[workload_idx];
494 const int32_t neighbour_count =
495 (neighbour_counts_ptr[workload_idx + 1] -
496 neighbour_counts_ptr[workload_idx]);
499 const int32_t covariances_offset = 9 * workload_idx;
503 neighbour_indices_ptr + neighbour_offset,
505 covariances_ptr + covariances_offset);
512 #if defined(__CUDACC__) 513 void EstimateCovariancesUsingKNNSearchCUDA
519 const int64_t& max_nn) {
530 std::tie(indices, distance) = tree.
KnnSearch(points, max_nn);
537 "Not enough neighbors to compute Covariances / Normals. " 539 "increasing the max_nn parameter.");
543 auto points_ptr = points.
GetDataPtr<scalar_t>();
545 auto covariances_ptr = covariances.GetDataPtr<scalar_t>();
550 const int32_t neighbour_offset = nn_count * workload_idx;
553 const int32_t covariances_offset = 9 * workload_idx;
557 neighbour_indices_ptr + neighbour_offset, nn_count,
558 covariances_ptr + covariances_offset);
565 template <
typename scalar_t>
567 const scalar_t eval0,
568 scalar_t* eigen_vector0) {
569 scalar_t row0[3] = {A[0] - eval0, A[1], A[2]};
570 scalar_t row1[3] = {A[1], A[4] - eval0, A[5]};
571 scalar_t row2[3] = {A[2], A[5], A[8] - eval0};
573 scalar_t r0xr1[3], r0xr2[3], r1xr2[3];
594 scalar_t sqrt_d = sqrt(d0);
595 eigen_vector0[0] = r0xr1[0] / sqrt_d;
596 eigen_vector0[1] = r0xr1[1] / sqrt_d;
597 eigen_vector0[2] = r0xr1[2] / sqrt_d;
599 }
else if (imax == 1) {
600 scalar_t sqrt_d = sqrt(d1);
601 eigen_vector0[0] = r0xr2[0] / sqrt_d;
602 eigen_vector0[1] = r0xr2[1] / sqrt_d;
603 eigen_vector0[2] = r0xr2[2] / sqrt_d;
606 scalar_t sqrt_d = sqrt(d2);
607 eigen_vector0[0] = r1xr2[0] / sqrt_d;
608 eigen_vector0[1] = r1xr2[1] / sqrt_d;
609 eigen_vector0[2] = r1xr2[2] / sqrt_d;
614 template <
typename scalar_t>
616 const scalar_t* evec0,
617 const scalar_t eval1,
618 scalar_t* eigen_vector1) {
620 if (abs(evec0[0]) > abs(evec0[1])) {
621 scalar_t inv_length =
622 1.0 / sqrt(evec0[0] * evec0[0] + evec0[2] * evec0[2]);
623 U[0] = -evec0[2] * inv_length;
625 U[2] = evec0[0] * inv_length;
627 scalar_t inv_length =
628 1.0 / sqrt(evec0[1] * evec0[1] + evec0[2] * evec0[2]);
630 U[1] = evec0[2] * inv_length;
631 U[2] = -evec0[1] * inv_length;
633 scalar_t V[3], AU[3], AV[3];
635 core::linalg::kernel::matmul3x3_3x1(A, U, AU);
636 core::linalg::kernel::matmul3x3_3x1(A, V, AV);
642 scalar_t absM00 = abs(m00);
643 scalar_t absM01 = abs(m01);
644 scalar_t absM11 = abs(m11);
645 scalar_t max_abs_comp;
647 if (absM00 >= absM11) {
648 max_abs_comp = max(absM00, absM01);
649 if (max_abs_comp > 0) {
650 if (absM00 >= absM01) {
652 m00 = 1 / sqrt(1 + m01 * m01);
656 m01 = 1 / sqrt(1 + m00 * m00);
659 eigen_vector1[0] = m01 * U[0] - m00 * V[0];
660 eigen_vector1[1] = m01 * U[1] - m00 * V[1];
661 eigen_vector1[2] = m01 * U[2] - m00 * V[2];
664 eigen_vector1[0] = U[0];
665 eigen_vector1[1] = U[1];
666 eigen_vector1[2] = U[2];
670 max_abs_comp = max(absM11, absM01);
671 if (max_abs_comp > 0) {
672 if (absM11 >= absM01) {
674 m11 = 1 / sqrt(1 + m01 * m01);
678 m01 = 1 / sqrt(1 + m11 * m11);
681 eigen_vector1[0] = m11 * U[0] - m01 * V[0];
682 eigen_vector1[1] = m11 * U[1] - m01 * V[1];
683 eigen_vector1[2] = m11 * U[2] - m01 * V[2];
686 eigen_vector1[0] = U[0];
687 eigen_vector1[1] = U[1];
688 eigen_vector1[2] = U[2];
694 template <
typename scalar_t>
696 const scalar_t* covariance_ptr, scalar_t* normals_ptr) {
700 scalar_t max_coeff = covariance_ptr[0];
702 for (
int i = 1; i < 9; ++i) {
703 if (max_coeff < covariance_ptr[i]) {
704 max_coeff = covariance_ptr[i];
708 if (max_coeff == 0) {
709 normals_ptr[0] = 0.0;
710 normals_ptr[1] = 0.0;
711 normals_ptr[2] = 0.0;
717 for (
int i = 0; i < 9; ++i) {
718 A[i] = covariance_ptr[i] / max_coeff;
721 scalar_t norm = A[1] * A[1] + A[2] * A[2] + A[5] * A[5];
729 scalar_t q = (A[0] + A[4] + A[8]) / 3.0;
731 scalar_t b00 = A[0] - q;
732 scalar_t b11 = A[4] - q;
733 scalar_t b22 = A[8] - q;
736 sqrt((b00 * b00 + b11 * b11 + b22 * b22 + norm * 2.0) / 6.0);
738 scalar_t c00 = b11 * b22 - A[5] * A[5];
739 scalar_t c01 = A[1] * b22 - A[5] * A[2];
740 scalar_t c02 = A[1] * A[5] - b11 * A[2];
741 scalar_t det = (b00 * c00 - A[1] * c01 + A[2] * c02) / (p * p * p);
743 scalar_t half_det = det * 0.5;
744 half_det = min(max(half_det, static_cast<scalar_t>(-1.0)),
745 static_cast<scalar_t>(1.0));
747 scalar_t angle = acos(half_det) / 3.0;
748 const scalar_t two_thrids_pi = 2.09439510239319549;
750 scalar_t beta2 = cos(angle) * 2.0;
751 scalar_t beta0 = cos(angle + two_thrids_pi) * 2.0;
752 scalar_t beta1 = -(beta0 + beta2);
754 eval[0] = q + p * beta0;
755 eval[1] = q + p * beta1;
756 eval[2] = q + p * beta2;
759 ComputeEigenvector0<scalar_t>(A, eval[2], evec2);
761 if (eval[2] < eval[0] && eval[2] < eval[1]) {
762 normals_ptr[0] = evec2[0];
763 normals_ptr[1] = evec2[1];
764 normals_ptr[2] = evec2[2];
769 ComputeEigenvector1<scalar_t>(A, evec2, eval[1], evec1);
771 if (eval[1] < eval[0] && eval[1] < eval[2]) {
772 normals_ptr[0] = evec1[0];
773 normals_ptr[1] = evec1[1];
774 normals_ptr[2] = evec1[2];
779 normals_ptr[0] = evec1[1] * evec2[2] - evec1[2] * evec2[1];
780 normals_ptr[1] = evec1[2] * evec2[0] - evec1[0] * evec2[2];
781 normals_ptr[2] = evec1[0] * evec2[1] - evec1[1] * evec2[0];
785 ComputeEigenvector0<scalar_t>(A, eval[0], evec0);
787 if (eval[0] < eval[1] && eval[0] < eval[2]) {
788 normals_ptr[0] = evec0[0];
789 normals_ptr[1] = evec0[1];
790 normals_ptr[2] = evec0[2];
794 ComputeEigenvector1<scalar_t>(A, evec0, eval[1], evec1);
796 if (eval[1] < eval[0] && eval[1] < eval[2]) {
797 normals_ptr[0] = evec1[0];
798 normals_ptr[1] = evec1[1];
799 normals_ptr[2] = evec1[2];
803 normals_ptr[0] = evec0[1] * evec1[2] - evec0[2] * evec1[1];
804 normals_ptr[1] = evec0[2] * evec1[0] - evec0[0] * evec1[2];
805 normals_ptr[2] = evec0[0] * evec1[1] - evec0[1] * evec1[0];
809 if (covariance_ptr[0] < covariance_ptr[4] &&
810 covariance_ptr[0] < covariance_ptr[8]) {
811 normals_ptr[0] = 1.0;
812 normals_ptr[1] = 0.0;
813 normals_ptr[2] = 0.0;
815 }
else if (covariance_ptr[0] < covariance_ptr[4] &&
816 covariance_ptr[0] < covariance_ptr[8]) {
817 normals_ptr[0] = 0.0;
818 normals_ptr[1] = 1.0;
819 normals_ptr[2] = 0.0;
822 normals_ptr[0] = 0.0;
823 normals_ptr[1] = 0.0;
824 normals_ptr[2] = 1.0;
830 #if defined(__CUDACC__) 831 void EstimateNormalsFromCovariancesCUDA
842 const scalar_t* covariances_ptr = covariances.
GetDataPtr<scalar_t>();
843 scalar_t* normals_ptr = normals.GetDataPtr<scalar_t>();
848 int32_t covariances_offset = 9 * workload_idx;
849 int32_t normals_offset = 3 * workload_idx;
850 scalar_t normals_output[3] = {0};
851 EstimatePointWiseNormalsWithFastEigen3x3<scalar_t>(
852 covariances_ptr + covariances_offset,
855 if ((normals_output[0] * normals_output[0] +
856 normals_output[1] * normals_output[1] +
857 normals_output[2] * normals_output[2]) == 0.0 &&
859 normals_output[0] = 0.0;
860 normals_output[1] = 0.0;
861 normals_output[2] = 1.0;
864 if ((normals_ptr[normals_offset] * normals_output[0] +
865 normals_ptr[normals_offset + 1] *
867 normals_ptr[normals_offset + 2] *
868 normals_output[2]) < 0.0) {
869 normals_output[0] *= -1;
870 normals_output[1] *= -1;
871 normals_output[2] *= -1;
875 normals_ptr[normals_offset] = normals_output[0];
876 normals_ptr[normals_offset + 1] = normals_output[1];
877 normals_ptr[normals_offset + 2] = normals_output[2];
884 template <
typename scalar_t>
886 const scalar_t* points_ptr,
887 const scalar_t* normals_ptr,
888 const scalar_t* colors_ptr,
892 scalar_t* color_gradients_ptr) {
893 if (indices_count < 4) {
894 color_gradients_ptr[idx_offset] = 0;
895 color_gradients_ptr[idx_offset + 1] = 0;
896 color_gradients_ptr[idx_offset + 2] = 0;
898 scalar_t vt[3] = {points_ptr[idx_offset], points_ptr[idx_offset + 1],
899 points_ptr[idx_offset + 2]};
901 scalar_t nt[3] = {normals_ptr[idx_offset], normals_ptr[idx_offset + 1],
902 normals_ptr[idx_offset + 2]};
904 scalar_t it = (colors_ptr[idx_offset] + colors_ptr[idx_offset + 1] +
905 colors_ptr[idx_offset + 2]) /
908 scalar_t AtA[9] = {0};
909 scalar_t Atb[3] = {0};
919 scalar_t s = vt[0] * nt[0] + vt[1] * nt[1] + vt[2] * nt[2];
922 for (; i < indices_count; i++) {
923 int64_t neighbour_idx_offset = 3 * indices_ptr[i];
925 if (neighbour_idx_offset == -1) {
929 scalar_t vt_adj[3] = {points_ptr[neighbour_idx_offset],
930 points_ptr[neighbour_idx_offset + 1],
931 points_ptr[neighbour_idx_offset + 2]};
935 scalar_t d = vt_adj[0] * nt[0] + vt_adj[1] * nt[1] +
936 vt_adj[2] * nt[2] - s;
939 scalar_t vt_proj[3] = {vt_adj[0] - d * nt[0], vt_adj[1] - d * nt[1],
940 vt_adj[2] - d * nt[2]};
942 scalar_t it_adj = (colors_ptr[neighbour_idx_offset + 0] +
943 colors_ptr[neighbour_idx_offset + 1] +
944 colors_ptr[neighbour_idx_offset + 2]) /
947 scalar_t A[3] = {vt_proj[0] - vt[0], vt_proj[1] - vt[1],
950 AtA[0] += A[0] * A[0];
951 AtA[1] += A[1] * A[0];
952 AtA[2] += A[2] * A[0];
953 AtA[4] += A[1] * A[1];
954 AtA[5] += A[2] * A[1];
955 AtA[8] += A[2] * A[2];
957 scalar_t b = it_adj - it;
965 scalar_t A[3] = {(i - 1) * nt[0], (i - 1) * nt[1], (i - 1) * nt[2]};
967 AtA[0] += A[0] * A[0];
968 AtA[1] += A[0] * A[1];
969 AtA[2] += A[0] * A[2];
970 AtA[4] += A[1] * A[1];
971 AtA[5] += A[1] * A[2];
972 AtA[8] += A[2] * A[2];
980 color_gradients_ptr + idx_offset);
984 #if defined(__CUDACC__) 985 void EstimateColorGradientsUsingHybridSearchCUDA
993 const double& radius,
994 const int64_t& max_nn) {
1006 std::tie(indices, distance, counts) =
1010 auto points_ptr = points.
GetDataPtr<scalar_t>();
1011 auto normals_ptr = normals.GetDataPtr<scalar_t>();
1012 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1015 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1020 int32_t neighbour_offset = max_nn * workload_idx;
1023 neighbour_counts_ptr[workload_idx];
1024 int32_t idx_offset = 3 * workload_idx;
1027 points_ptr, normals_ptr, colors_ptr, idx_offset,
1028 neighbour_indices_ptr + neighbour_offset,
1029 neighbour_count, color_gradients_ptr);
1036 #if defined(__CUDACC__) 1037 void EstimateColorGradientsUsingKNNSearchCUDA
1045 const int64_t& max_nn) {
1057 std::tie(indices, distance) = tree.
KnnSearch(points, max_nn);
1060 int64_t nn_count = indices.
GetShape()[1];
1064 "Not enough neighbors to compute Covariances / Normals. " 1066 "changing the search parameter.");
1070 auto points_ptr = points.
GetDataPtr<scalar_t>();
1071 auto normals_ptr = normals.GetDataPtr<scalar_t>();
1072 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1074 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1078 int32_t neighbour_offset = max_nn * workload_idx;
1079 int32_t idx_offset = 3 * workload_idx;
1082 points_ptr, normals_ptr, colors_ptr, idx_offset,
1083 neighbour_indices_ptr + neighbour_offset, nn_count,
1084 color_gradients_ptr);
1091 #if defined(__CUDACC__) 1092 void EstimateColorGradientsUsingRadiusSearchCUDA
1100 const double& radius) {
1112 std::tie(indices, distance, counts) =
1119 auto points_ptr = points.
GetDataPtr<scalar_t>();
1120 auto normals_ptr = normals.GetDataPtr<scalar_t>();
1121 auto colors_ptr = colors.GetDataPtr<scalar_t>();
1124 auto color_gradients_ptr = color_gradients.GetDataPtr<scalar_t>();
1129 neighbour_counts_ptr[workload_idx];
1131 const int32_t neighbour_count =
1132 (neighbour_counts_ptr[workload_idx + 1] -
1133 neighbour_counts_ptr[workload_idx]);
1134 int32_t idx_offset = 3 * workload_idx;
1137 points_ptr, normals_ptr, colors_ptr, idx_offset,
1138 neighbour_indices_ptr + neighbour_offset,
1139 neighbour_count, color_gradients_ptr);
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:2190
OPEN3D_HOST_DEVICE index_t GetShape(int i) const
Definition: GeometryIndexer.h:330
TArrayIndexer< int64_t > NDArrayIndexer
Definition: GeometryIndexer.h:379
Definition: GeometryIndexer.h:180
void EstimateCovariancesUsingRadiusSearchCPU(const core::Tensor &points, core::Tensor &covariances, const double &radius)
Definition: PointCloudImpl.h:468
OPEN3D_HOST_DEVICE void ComputeEigenvector0(const scalar_t *A, const scalar_t eval0, scalar_t *eigen_vector0)
Definition: PointCloudImpl.h:566
bool FixedRadiusIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:59
static Tensor Full(const SizeVector &shape, T fill_value, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with specified value.
Definition: Tensor.h:271
OPEN3D_HOST_DEVICE void GetCoordinateSystemOnPlane(const scalar_t *query, scalar_t *u, scalar_t *v)
Definition: PointCloudImpl.h:191
OPEN3D_HOST_DEVICE void * GetDataPtr() const
Definition: GeometryIndexer.h:334
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:82
bool HybridIndex(utility::optional< double > radius={})
Definition: NearestNeighborSearch.cpp:79
OPEN3D_HOST_DEVICE bool IsBoundaryPoints(const scalar_t *angles, int counts, double angle_threshold)
Definition: PointCloudImpl.h:253
void ParallelFor(const Device &device, int64_t n, const func_t &func)
Definition: ParallelFor.h:122
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t int32_t
Definition: K4aPlugin.cpp:408
std::tuple< Tensor, Tensor, Tensor > FixedRadiusSearch(const Tensor &query_points, double radius, bool sort=true)
Definition: NearestNeighborSearch.cpp:117
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:96
const Dtype Float32
Definition: Dtype.cpp:61
OPEN3D_HOST_DEVICE void EstimatePointWiseNormalsWithFastEigen3x3(const scalar_t *covariance_ptr, scalar_t *normals_ptr)
Definition: PointCloudImpl.h:695
std::tuple< Tensor, Tensor, Tensor > HybridSearch(const Tensor &query_points, const double radius, const int max_knn) const
Definition: NearestNeighborSearch.cpp:149
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:885
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:989
Dtype GetDtype() const
Definition: Tensor.h:1169
Device GetDevice() const override
Definition: Tensor.cpp:1384
#define OPEN3D_DEVICE
Definition: CUDAUtils.h:64
#define OPEN3D_ATOMIC_ADD(X, Y)
Definition: GeometryMacros.h:58
void Synchronize()
Definition: CUDAUtils.cpp:77
#define OPEN3D_HOST_DEVICE
Definition: CUDAUtils.h:63
core::Tensor InverseTransformation(const core::Tensor &T)
TODO(wei): find a proper place for such functionalities.
Definition: Utility.h:96
const Dtype Int32
Definition: Dtype.cpp:65
OPEN3D_HOST_DEVICE void Swap(scalar_t *x, scalar_t *y)
Definition: PointCloudImpl.h:218
void EstimateCovariancesUsingHybridSearchCPU(const core::Tensor &points, core::Tensor &covariances, const double &radius, const int64_t &max_nn)
Definition: PointCloudImpl.h:418
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:338
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:276
Tensor To(Dtype dtype, bool copy=false) const
Definition: Tensor.cpp:725
Tensor Contiguous() const
Definition: Tensor.cpp:758
OPEN3D_HOST_DEVICE void Heapify(scalar_t *arr, int n, int root)
Definition: PointCloudImpl.h:225
A Class for nearest neighbor search.
Definition: NearestNeighborSearch.h:44
size_t stride
Definition: TriangleMeshBuffers.cpp:184
Definition: Optional.h:79
SizeVector GetShape() const
Definition: Tensor.h:1132
std::pair< Tensor, Tensor > KnnSearch(const Tensor &query_points, int knn)
Definition: NearestNeighborSearch.cpp:98
void UnprojectCPU(const core::Tensor &depth, utility::optional< std::reference_wrapper< const core::Tensor >> image_colors, core::Tensor &points, utility::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:63
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:49
void EstimateColorGradientsUsingRadiusSearchCPU(const core::Tensor &points, const core::Tensor &normals, const core::Tensor &colors, core::Tensor &color_gradient, const double &radius)
Definition: PointCloudImpl.h:1096
void EstimateCovariancesUsingKNNSearchCPU(const core::Tensor &points, core::Tensor &covariances, const int64_t &max_nn)
Definition: PointCloudImpl.h:517
Definition: PinholeCameraIntrinsic.cpp:35
void EstimateNormalsFromCovariancesCPU(const core::Tensor &covariances, core::Tensor &normals, const bool has_normals)
Definition: PointCloudImpl.h:835
void GetPointMaskWithinAABBCPU(const core::Tensor &points, const core::Tensor &min_bound, const core::Tensor &max_bound, core::Tensor &mask)
Definition: PointCloudImpl.h:161
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:1041
OPEN3D_HOST_DEVICE void ComputeEigenvector1(const scalar_t *A, const scalar_t *evec0, const scalar_t eval1, scalar_t *eigen_vector1)
Definition: PointCloudImpl.h:615
#define DISPATCH_FLOAT_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:96
T * GetDataPtr()
Definition: Tensor.h:1149
OPEN3D_HOST_DEVICE void HeapSort(scalar_t *arr, int n)
Definition: PointCloudImpl.h:243
int64_t GetLength() const
Definition: Tensor.h:1130
bool KnnIndex()
Definition: NearestNeighborSearch.cpp:42
#define LogError(...)
Definition: Logging.h:67