点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 3369|回复: 1

条件滤波调试出现显示vector subscript out of range错误

[复制链接]
发表于 2016-7-25 18:14:57 | 显示全部楼层 |阅读模式
在进行点云滤波的代码调试的时候,显示vector subscript out of range错误,尝试了很多解决方法都没弄好,不知道是不是跟点云的有序和无序是否有关?
#include "stdafx.h"
#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/cloud_viewer.h>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
  // 填入点云数据
        pcl::io::loadPCDFile ("cloud_tBF01_inliers.pcd", *cloud);
        pcl::visualization::CloudViewer viewer1("Cloud before filtering");
        viewer1.showCloud(cloud);
        //添加比较算子
        pcl::ConditionAnd<pcl::PointXYZ>::Ptr range_cond (new pcl::ConditionAnd<pcl::PointXYZ> ());
    range_cond->addComparison (pcl::FieldComparison<pcl::PointXYZ>::ConstPtr (new pcl::FieldComparison<pcl::PointXYZ> ("z", pcl::ComparisonOps::GT, 0.0)));
    range_cond->addComparison (pcl::FieldComparison<pcl::PointXYZ>::ConstPtr (new pcl::FieldComparison<pcl::PointXYZ> ("z", pcl::ComparisonOps::LT, 0.8)));
    // 创建滤波器
    pcl::ConditionalRemoval<pcl::PointXYZ> condrem (range_cond);
    condrem.setInputCloud (cloud);
    condrem.setKeepOrganized(true);
    // 应用滤波器
    condrem.filter (*cloud_filtered);
        pcl::visualization::CloudViewer viewer2("Cloud after filtering");
        viewer2.showCloud(cloud_filtered);
        pcl::PCDWriter writer;
    writer.write<pcl::PointXYZ>("cloud_tBF01_gh.pcd",*cloud_filtered,false);
    system("pause");
        return 0;
}

回复

使用道具 举报

发表于 2016-10-5 16:46:08 | 显示全部楼层
请问 问题解决了吗
回复 支持 反对

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-4-26 00:05 , Processed in 1.740369 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表