【发布时间】:2019-07-18 12:51:10
【问题描述】:
我正在使用 Kinect2Grabber 并希望进行一些实时处理,但我获得的性能约为 1 fps。最终,我想估计一个在空中抛球的轨迹。处理速度这么慢,我做不到:(
我在 AMD Ryzen Threadripper 1900X 8 核处理器上使用 Windows 10 64 位、Visual Studio 2017、PCL 1.9.1 一体化安装程序 MSVC2017 x64。我的项目中启用了 OpenMP,优化也是如此。但是,当我运行我的程序时,它的 CPU 使用率约为 12-13%。我做错了什么?
int main(int argc, char* argv[])
{
boost::shared_ptr<visualization::PCLVisualizer> viewer(new visualization::PCLVisualizer("Point Cloud Viewer"));
viewer->setCameraPosition(0.0, 0.0, -1.0, 0.0, 0.0, 0.0);
PointCloud<PointType>::Ptr cloud(new PointCloud<PointType>);
// Retrieved Point Cloud Callback Function
boost::mutex mutex;
boost::function<void(const PointCloud<PointType>::ConstPtr&)> function = [&cloud, &mutex](const PointCloud<PointType>::ConstPtr& ptr) {
boost::mutex::scoped_lock lock(mutex);
//Point Cloud Processing
cloud = ptr->makeShared();
std::vector<int> indices;
removeNaNFromPointCloud<PointType>(*cloud, *cloud, indices);
pass_filter(0.5, 0.90, cloud);
outlier_removal(50, 1.0, cloud);
downsampling_vox_grid(0.005f, cloud);
normals(0.04, cloud, cloud_normals);
segmentation(cloud, cloud_normals);
};
boost::shared_ptr<Grabber> grabber = boost::make_shared<Kinect2Grabber>();
boost::signals2::connection connection = grabber->registerCallback(function);
grabber->start();
while (!viewer->wasStopped()) {
// Update Viewer
viewer->spinOnce();
boost::mutex::scoped_try_lock lock(mutex);
if (lock.owns_lock() && cloud) {
// Update Point Cloud
if (!viewer->updatePointCloud(cloud, "chmura")) {
viewer->addPointCloud(cloud, "chmura");
}
}
}
grabber->stop();
// Disconnect Callback Function
if (connection.connected()) {
connection.disconnect();
}
return 0;
}
pass_filter、outlier_removal 等的省略代码直接取自教程,它正在工作,但从 outlier_removal(包括)开始非常慢。 非常感谢您的帮助。
我不必使用 Kinect2Grabber。在 Windows 上抓取和处理来自 Kinec2 的帧都可以。
【问题讨论】:
标签: c++ visual-studio-2017 point-cloud-library