我正在研究kinect V2
及其抓取工具来运行它。我遇到了一些想要在pcd
上编写云信息的问题。看看这段代码:
int main(int argc, char* argv[])
{
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("Point Cloud Viewer"));
viewer->registerKeyboardCallback(&keyboard_callback, "keyboard");
viewer->registerMouseCallback(&mouse_callback, "mouse");
pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud;
boost::function<void(const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> function =
[&cloud](const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &ptr){
boost::mutex::scoped_lock lock(mutex);
cloud = ptr;
};
pcl::Grabber* grabber = new pcl::Kinect2Grabber();
boost::signals2::connection connection = grabber->registerCallback(function);
grabber->start();
while (!viewer->wasStopped()){
viewer->spinOnce();
if (cloud){
if (!viewer->updatePointCloud(cloud, "cloud")){
viewer->addPointCloud(cloud, "cloud");
viewer->resetCameraViewpoint("cloud");
}
}
if (GetKeyState(VK_ESCAPE) < 0){
break;
}
}
grabber->stop();
return 0;
}
boost函数的云指针必须是const
(我不确定)。因此,我无法与cloud.makeShared()
函数共享它,cloud->makeShared()
通过抛出一些例外而中止。我也尝试将其复制到常规云但不起作用。你能帮我解决一下如何在pcd
文件上写这个云吗?