pcl
pcl copied to clipboard
[common] pcl::getMinMax3d() support for pcl::PointXY
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
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.
@sibi-venti there already is a getMinMax3D or getMinMax3D in common that is templated on the pointtype.
That should suffice?
Oops, they might not work on PointXY - misread it the first time.
@sibi-venti There is some information missing in your problem description. Which class are you trying to use with pcl::PointXY? You mention pcl::segmentation, but which class exactly? Please show your code so we can reproduce the error, and ideally also post the compiler output (the complete error message).
@mvieth pcl::segmentation
MODEL : SAC_MODEL_LINE METHOD: SAC_MLESAC
@mvieth pcl::segmentation
MODEL : SAC_MODEL_LINE METHOD: SAC_MLESAC
@the-code-samurai-97 Do you mean like this or what?
#define PCL_NO_PRECOMPILE
#include <pcl/segmentation/sac_segmentation.h>
...
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
auto cloud_xy = pcl::make_shared<pcl::PointCloud<pcl::PointXY>>();
cloud_xy->emplace_back(1.0, 2.0);
cloud_xy->emplace_back(2.0, 4.0);
cloud_xy->emplace_back(3.0, 6.0);
pcl::SACSegmentation<pcl::PointXY> seg();
seg.setModelType (pcl::SACMODEL_LINE);
seg.setMethodType (pcl::SAC_MLESAC);
seg.setInputCloud (cloud_xy);
seg.segment (*inliers, *coefficients);
It is really unclear what you are trying to do, please show your code! And please describe what you want to do in general! Do you have a 2D point cloud and want to apply the MLESAC algorithm to find a line in the point cloud? Or something else?