Skip to content

[common] pcl::getMinMax3d() support for pcl::PointXY #6271

Open
@sibi-venti

Description

@sibi-venti

Describe the bug

i cannot create pcl::segmentation with pcl::PointXY , it have a default way to convert to Eigen vector 4 map
Context

What are you trying to accomplish? Providing context helps us come up with a solution that is most useful in the real world

Expected behavior

it should be able to give you min max of x y points and 0 for z and w

Current Behavior

What happens instead of the expected behavior?
compilation issue
To Reproduce

Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. A reproducible example helps to provide faster answers. If you load data e.g. from a PCD or PLY file, please provide the file.

Screenshots/Code snippets

In order to help explain your problem, please consider adding

  • screenshots of the GUI issues
  • code snippets: syntax for code with correct language highlights

Your Environment (please complete the following information):

  • OS: [e.g. Ubuntu 16.04]
  • Compiler: [:eg GCC 8.1]
  • PCL Version [e.g. 1.10, HEAD]

Possible Solution

//////////////////////////////////////////////////////////////////////////
template <typename PointT> void
pcl::MaximumLikelihoodSampleConsensus<PointT>::getMinMax (
    const PointCloudConstPtr &cloud, 
    const IndicesPtr &indices,
    Eigen::Vector4f &min_p, 
    Eigen::Vector4f &max_p) const
{
  min_p.setConstant (std::numeric_limits<float>::max());
  max_p.setConstant (std::numeric_limits<float>::lowest());
  min_p[3] = max_p[3] = 0;

  for (std::size_t i = 0; i < indices->size (); ++i)
  {
    if ((*cloud)[(*indices)[i]].x < min_p[0]) min_p[0] = (*cloud)[(*indices)[i]].x;
    if ((*cloud)[(*indices)[i]].y < min_p[1]) min_p[1] = (*cloud)[(*indices)[i]].y;
    if ((*cloud)[(*indices)[i]].z < min_p[2]) min_p[2] = (*cloud)[(*indices)[i]].z;

    if ((*cloud)[(*indices)[i]].x > max_p[0]) max_p[0] = (*cloud)[(*indices)[i]].x;
    if ((*cloud)[(*indices)[i]].y > max_p[1]) max_p[1] = (*cloud)[(*indices)[i]].y;
    if ((*cloud)[(*indices)[i]].z > max_p[2]) max_p[2] = (*cloud)[(*indices)[i]].z;
  }
}

you can make this global common i cannot use it outside this class

Image
all min max does not support the PointXY

Not obligatory, but suggest a fix/reason for the bug. Feel free to create a PR if you feel comfortable.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions