【C++错误】:R6010 -abort() has been called

出现这个错误可能的原因是 点击打开链接

而我在处理云点时,问题出在指针,刚开始我只通过

pcl::PointIndices::Ptr inliers
定义了inliers, 而没有为它开辟空间,因此在seg.segment函数中进行传参时,指针出现问题。所以,要注意通过函数传参返回运算结果时,一定要先开辟好存储空间,在存储。
int Ransac::PlaneEstimation(pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud, 
	int count, pcl::ModelCoefficients::Ptr model_coefficients,
	const char* outputpath) {
	// Create the segmentation object
	pcl::SACSegmentation<pcl::PointXYZRGB> seg;
	pcl::PointIndices::Ptr inliers(new pcl::PointIndices);
	// Optional
	seg.setOptimizeCoefficients(true);
	// Mandatory
	seg.setModelType(pcl::SACMODEL_PLANE);
	seg.setMethodType(pcl::SAC_RANSAC);
	seg.setDistanceThreshold(0.5);
	seg.setMaxIterations(300);
	//seg.setProbability(p);

	seg.setInputCloud(cloud);
	seg.segment(*inliers, *model_coefficients);

	if (inliers->indices.size() == 0)
	{
		PCL_ERROR("Could not estimate a planar model for the given dataset.");
		return 0;
	}

	pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_plane(new pcl::PointCloud<pcl::PointXYZRGB>);
	// Extract the planar inliers from the input cloud  
	pcl::ExtractIndices<pcl::PointXYZRGB> extract;
	extract.setInputCloud(cloud);
	extract.setIndices(inliers);
	// Get the points associated with the planar surface  
	extract.filter(*cloud_plane);
	string fn = string(outputpath) + "\\plane" +to_string(count) + ".txt";
	write2txt(fn.c_str(), cloud_plane);

	extract.setNegative(true);
	cloud->clear();
	extract.filter(*cloud);

	return 1;
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值