Qt PCL 点云点坐标拾取

主要问题:
1. 回调函数作为类的成员函数
*2. registerPointPickingCallback函数的参数,传this指针的值(this)作为一个实例对象。

//类成员函数 Smoothing::showAll()
//显示点云vector中的所有点云。
//调用宿主函数registerPointPickingCallback来监视点的拾取。
//并指定回调函数为Smoothing::pp_callback
void Smoothing::showAll() {
	viewer->removeAllPointClouds();
	//ui.CheckComboBox->setCurrentIndex(0);
	for(int pc=0;pc<turnPc.size();pc++){
		pcl::visualization::PointCloudColorHandlerGenericField<pcl::PointXYZ> fildColor(turnPc[pc], "z");
		
			viewer->addPointCloud(turnPc[pc], fildColor, "cloud " +to_string(pc));
			PointXYZ current_point= PointXYZ();
			viewer->registerPointPickingCallback(&Smoothing::pp_callback,  *this, &current_point);
			//std::cout << current_point.x << " " << current_point.y << " " << current_point.z << std::endl;
	}
	viewer->resetCamera(); 
	ui.qvtkWidget->update();
}
//类成员函数Smoothing::pp_callback()作为回调函数
void Smoothing::pp_callback(const pcl::visualization::PointPickingEvent& event, void *args)
{
	if (event.getPointIndex() == -1)
		return;
	PointXYZ *current_point = (PointXYZ*)(args);
	event.getPoint(current_point->x, current_point->y, current_point->z);
	//std::cout << current_point->x << " " << current_point->y << " " << current_point->z << std::endl;
	string x = "X: " + to_string(current_point->x);
	string y = "Y: " + to_string(current_point->y);
	string z = "Z: " + to_string(current_point->z);
	//ui中的三个标签
	ui.label_24->setText(QString::fromStdString(x));
	ui.label_25->setText(QString::fromStdString(y));
	ui.label_26->setText(QString::fromStdString(z));
	return ;
}
  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值