@@ -73,9 +73,10 @@ static inline void flush() { std::cout << std::endl; };
73
73
* @return the geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array.
74
74
*/
75
75
template <typename real_t = float , const size_t feature_count = 11 >
76
- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>> compute_geometric_features (
77
- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
78
- const size_t k_min, const bool verbose)
76
+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>
77
+ compute_geometric_features (
78
+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
79
+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const size_t k_min, const bool verbose)
79
80
{
80
81
if (k_min < 1 ) { throw std::invalid_argument (" k_min should be > 1" ); }
81
82
// Each point can be treated in parallel
@@ -111,7 +112,8 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
111
112
// Final print to start on a new line
112
113
if (verbose) log ::flush ();
113
114
const size_t shape[2 ] = {n_points, feature_count};
114
- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>>(features, 2 , shape, owner_features);
115
+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>(
116
+ features, 2 , shape, owner_features);
115
117
}
116
118
/* *
117
119
* Convenience function that check that scales are well ordered in increasing order.
@@ -155,9 +157,10 @@ static bool check_scales(const std::vector<uint32_t>& k_scales)
155
157
* nd::array
156
158
*/
157
159
template <typename real_t , const size_t feature_count = 11 >
158
- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any, feature_count>> compute_geometric_features_multiscale (
159
- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
160
- const std::vector<uint32_t >& k_scales, const bool verbose)
160
+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , -1 , static_cast <nb::ssize_t >(feature_count)>>
161
+ compute_geometric_features_multiscale (
162
+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
163
+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const std::vector<uint32_t >& k_scales, const bool verbose)
161
164
{
162
165
if (!check_scales (k_scales))
163
166
{
@@ -203,7 +206,7 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any, feature_count>
203
206
if (verbose) log ::flush ();
204
207
205
208
const size_t shape[3 ] = {n_points, n_scales, feature_count};
206
- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any, feature_count>>(
209
+ return nb::ndarray<nb::numpy, real_t , nb::shape<- 1 , - 1 , static_cast < nb::ssize_t >( feature_count) >>(
207
210
features, 3 , shape, owner_features);
208
211
}
209
212
@@ -238,9 +241,11 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any, feature_count>
238
241
* @return Geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array
239
242
*/
240
243
template <typename real_t , const size_t feature_count = 12 >
241
- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>> compute_geometric_features_optimal (
242
- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
243
- const uint32_t k_min, const uint32_t k_step, const uint32_t k_min_search, const bool verbose)
244
+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>
245
+ compute_geometric_features_optimal (
246
+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
247
+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const uint32_t k_min, const uint32_t k_step,
248
+ const uint32_t k_min_search, const bool verbose)
244
249
{
245
250
if (k_min < 1 && k_min_search < 1 ) { throw std::invalid_argument (" k_min and k_min_search should be > 1" ); }
246
251
// Each point can be treated in parallel
@@ -300,7 +305,8 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
300
305
if (verbose) log ::flush ();
301
306
302
307
const size_t shape[2 ] = {n_points, feature_count};
303
- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>>(features, 2 , shape, owner_features);
308
+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>(
309
+ features, 2 , shape, owner_features);
304
310
}
305
311
306
312
/* *
@@ -317,14 +323,14 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
317
323
* @return Geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array
318
324
*/
319
325
template <typename real_t >
320
- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any >> compute_geometric_features_selected (
326
+ static nb::ndarray<nb::numpy, real_t , nb::shape<- 1 , - 1 >> compute_geometric_features_selected (
321
327
RefCloud<real_t > xyz, const real_t search_radius, const uint32_t max_knn,
322
328
const std::vector<EFeatureID>& selected_features)
323
329
{
324
330
using kd_tree_t = nanoflann::KDTreeEigenMatrixAdaptor<RefCloud<real_t >, 3 , nanoflann::metric_L2_Simple>;
325
331
// TODO: where knn < num of points
326
332
327
- kd_tree_t kd_tree (3 , xyz, 10 );
333
+ kd_tree_t kd_tree (3 , xyz, 10 , 0 );
328
334
const size_t feature_count = selected_features.size ();
329
335
const Eigen::Index n_points = xyz.rows ();
330
336
real_t sq_search_radius = search_radius * search_radius;
@@ -364,6 +370,7 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any>> compute_geome
364
370
});
365
371
executor.run (taskflow).get ();
366
372
367
- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any>>(features, {static_cast <size_t >(n_points), feature_count}, owner_features);
373
+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , -1 >>(
374
+ features, {static_cast <size_t >(n_points), feature_count}, owner_features);
368
375
}
369
376
} // namespace pgeof
0 commit comments