【发布时间】:2014-10-08 10:23:38
【问题描述】:
在可视化点云时,有没有办法让 PCL 库等待一段时间?我有一系列点云,想在 PCLVisualizer 中“动画化”这些点云(通过更新单个点云或循环显示和删除新点云)。
我正在使用 C++ 并设置了 CloudViewer example。到目前为止,我只能通过与 OpenCV 交叉编译并使用它的 waitKey(milliseconds) 函数来达到一定程度的延迟。我在 Ubuntu 14.04 LTS 上。使用 OpenCV 制作示例:
#include <opencv2/opencv.hpp>
using namespace cv;
但是 waitKey 仅在 viewerPsycho 函数的最后一个简单用途中起作用,它确实延迟了该函数中的计数器:
void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape ("text", 0);
viewer.addText (ss.str(), 200, 300, "text", 0);
// this will delay counter but shows nothing
waitKey(1000);
viewer.addPointCloud(point_cloud_ptr, "first");
waitKey(1000);
viewer.removePointCloud("first");
}
我的代码比原始示例更丰富,并且 addPointCloud 方法在不尝试延迟时可以正常工作。方法 removePointCloud 可能也有效,因为没有显示任何内容(waitKey 被忽略?)。
当像这样与 addPointCloud 和 removePointCloud 一起使用时,在 viewerOneOff 函数中,waitKey 似乎也被忽略了(在函数末尾):
作品(仅展示):
viewer.addPointCloud(point_cloud_ptr, "first");
不起作用(什么都不显示):
viewer.addPointCloud(point_cloud_ptr, "first");
waitKey(5000);
viewer.removePointCloud("first");
我的 CMakeLists.txt:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(opencv_pcl)
find_package(PCL 1.2 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (opencv_pcl opencv_pcl.cpp)
target_link_libraries (opencv_pcl ${PCL_LIBRARIES} ${OpenCV_LIBS})
我将不胜感激。
【问题讨论】:
标签: c++ delay sleep wait point-cloud-library