Eigen::Tensor<uint8_t, 3, Eigen::RowMajor> crop_pointcloud( const Eigen::Tensor<Scalar, 3, Eigen::RowMajor> data_crop, Scalar x_o, Scalar y_o, Scalar x_i, Scalar y_i, Scalar R_o, Scalar R_i, Scalar z_critical) { const int range_z = data_crop.dimension(2); const Scalar K_o = R_o * R_o / range_z; const Scalar K_i = R_i * R_i / range_z; Eigen::Tensor<uint8_t, 3, Eigen::RowMajor> cropped_data = data_crop.cast<uint8_t>(); for (int z = 0; z < range_z; z++) { const Scalar r_o = std::sqrt(z * K_o); auto data_layer = cropped_data.chip(z, 2); const Scalar d_o = std::sqrt(x_o * x_o + y_o * y_o); const Scalar d_i = std::sqrt(x_i * x_i + y_i * y_i); const Scalar r_i = (z < z_critical) ? 0 : std::sqrt(z * K_i); data_layer = data_layer * ((d_o <= r_o) && (d_i > r_i)).template cast<uint8_t>(); } return cropped_data; } 参数改为int
时间: 2024-03-19 15:41:25 浏览: 57
Eigen::Tensor<uint8_t, 3, Eigen::RowMajor> crop_pointcloud(
const Eigen::Tensor<int, 3, Eigen::RowMajor> data_crop,
int x_o, int y_o, int x_i, int y_i,
int R_o, int R_i, int z_critical) {
const int range_z = data_crop.dimension(2);
const int K_o = R_o * R_o / range_z;
const int K_i = R_i * R_i / range_z;
Eigen::Tensor<uint8_t, 3, Eigen::RowMajor> cropped_data = data_crop.cast<uint8_t>();
for (int z = 0; z < range_z; z++) {
const int r_o = std::sqrt(z * K_o);
auto data_layer = cropped_data.chip(z, 2);
const int d_o = std::sqrt(x_o * x_o + y_o * y_o);
const int d_i = std::sqrt(x_i * x_i + y_i * y_i);
const int r_i = (z < z_critical) ? 0 : std::sqrt(z * K_i);
data_layer = data_layer * ((d_o <= r_o) && (d_i > r_i)).template cast<uint8_t>();
}
return cropped_data;
}
阅读全文