将Unit8传递到PCL :: PassTrough
我有一个自定义的pointxyzb
带有字段x
,y
,z
和beam
在pcl
中。 x
,y
,z
是float,beam
是unit8,其值等于0或1。注册了我自定义的pointxyzb
到PCL,我正在尝试使用setFilterFieldName
用字段beam
来过滤我的点云。以下是我的代码。代码成功编译,但无法根据beam
过滤出正确的结果。我知道我们可以将setEnsngative
作为解决方法,但我想知道为什么我的代码失败。我想从c ++ API中的UINT8铸造到两倍时,有问题。
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
pcl::PointCloud<PointXYZB> filter (double lower, double upper)
{
pcl::PointCloud<PointXYZB>::Ptr cloud (new pcl::PointCloud<PointXYZB>);
pcl::PointCloud<PointXYZB>::Ptr cloud_filtered (new pcl::PointCloud<PointXYZB>);
// Create the filtering object
pcl::PassThrough<PointXYZB> pass;
pass.setInputCloud (cloud);
pass.setFilterFieldName ("beam");
pass.setFilterLimits (lower, double);
pass.filter (*cloud_filtered);
return *cloud_filtered;
}
int main() {
pcl::PointCloud<PointXYZB> f = filter(0.0, 0.0);
pcl::PointCloud<PointXYZB> b = filter(1.0, 1.0);
}
I have a customized PointXYZB
with fields x
, y
, z
, and beam
in pcl
. x
, y
, z
are float and beam
is unit8 with either value equals to 0 or 1. I have registered my customized PointXYZB
to pcl, and I'm trying to use setFilterFieldName
to filter my point cloud in terms of field beam
. The following is my code. The code compiles successfully but fails to filter out the correct result based on beam
. I know we can use setNegative
as a workaround but I want to know why my code fails. I guess there is something wrong when casting from uint8 to double in c++ API.
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
pcl::PointCloud<PointXYZB> filter (double lower, double upper)
{
pcl::PointCloud<PointXYZB>::Ptr cloud (new pcl::PointCloud<PointXYZB>);
pcl::PointCloud<PointXYZB>::Ptr cloud_filtered (new pcl::PointCloud<PointXYZB>);
// Create the filtering object
pcl::PassThrough<PointXYZB> pass;
pass.setInputCloud (cloud);
pass.setFilterFieldName ("beam");
pass.setFilterLimits (lower, double);
pass.filter (*cloud_filtered);
return *cloud_filtered;
}
int main() {
pcl::PointCloud<PointXYZB> f = filter(0.0, 0.0);
pcl::PointCloud<PointXYZB> b = filter(1.0, 1.0);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚检查过,
PassThrough
仅适用于类型float的字段: https://github.com/pointcloudlibrary/pcl/blob/master/master/filters/include/pcl/pcl/filters/impl/passthrough.hpphrough.hppthrough.hpp#l101您可以尝试 conditayAlremoval 或,如果您的PCL版本足够近, functorfilter/functionfilter/functionfilter
I just checked,
PassThrough
only works for fields of type float: https://github.com/PointCloudLibrary/pcl/blob/master/filters/include/pcl/filters/impl/passthrough.hpp#L101You can try ConditionalRemoval or, if your PCL version is sufficiently recent, FunctorFilter/FunctionFilter