Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get labeled point cloud object #82

Closed
brunoeducsantos opened this issue Apr 4, 2022 · 2 comments
Closed

Get labeled point cloud object #82

brunoeducsantos opened this issue Apr 4, 2022 · 2 comments

Comments

@brunoeducsantos
Copy link

Hi @niosus ,
Thanks for the amazing project.
I wonder if you could give me a pointer how to get point cloud label indices.
Kind regards,
Bruno

@brunoeducsantos
Copy link
Author

For the ones who may care, I managed to get labeled point cloud as follows:

for (auto path : cloud_reader.GetAllFilePaths()) {
    time_utils::Timer timer;
    auto cloud = ReadKittiCloud(path);
    cloud->InitProjection(*proj_params_ptr);
    auto proj =cloud->projection_ptr();
    auto img= proj->depth_image();
       LinearImageLabeler<> image_labeler(cloud->projection_ptr()->depth_image(),
                           cloud->projection_ptr()->params(), angle_tollerance);
    image_labeler.ComputeLabels(DiffFactory::DiffType::ANGLES);
    const cv::Mat* labels_ptr = image_labeler.GetLabelImage();
     std::unordered_map<uint16_t, Cloud> clusters;
    for (int row = 0; row < labels_ptr->rows; ++row) {
      for (int col = 0; col < labels_ptr->cols; ++col) {
        const auto& point_container = cloud->projection_ptr()->at(row, col);
        if (point_container.IsEmpty()) {
          // this is ok, just continue, nothing interesting here, no points.
          continue;
        }
        uint16_t label = labels_ptr->at<uint16_t>(row, col);
        if (label < 1) {
          // this is a default label, skip
          continue;
        }
        for (const auto& point_idx : point_container.points()) {
          const auto& point = cloud->points()[point_idx];
          clusters[label].push_back(point);
        }
      }
    }

@brunoeducsantos
Copy link
Author

After all it didnt sort it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant