C++中的点云库(PCL)等待/延迟/睡眠功能
Point Cloud Library (PCL) wait/delay/sleep function in C++
在可视化点云时,有没有办法让PCL库等待一段时间?我有一系列的点云,希望在PCLVisualizer中"动画化"这些点云(通过更新单个点云或在循环中显示+删除新的点云)。
我使用的是C++,并且已经设置了CloudViewer示例。到目前为止,我只能通过与OpenCV交叉编译并使用其waitKey(毫秒)函数来达到一定程度的延迟。我使用的是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已忽略?)。
在viewerOneOff函数中,当以与addPointCloud和removePointCloud相同的方式使用时,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})
我将感谢任何帮助。
您的代码中有spin()或spinOnce()方法吗?
viewer->spinOnce (100);
这将更新渲染器并处理所有交互(http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a896556f91ba6b45b12a9543a2b397193)。
相关文章:
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 如何仅为一个函数添加延迟
- 如何让LLDB在成功时退出,在失败时等待
- 以在Qt中的IF语句中设置时间延迟
- 模板化类中静态成员的延迟初始化
- 等待整个 omp 块完成,然后再调用第二个函数
- 在 Windows 8/10 技术中完全实时的屏幕捕获,没有延迟
- 将自定义函数传递到基抽象类中以延迟执行
- 提升 ASIO - io_service 不要等待连接到线程
- 如何在C++中实现带有packaged_task的异步等待循环?
- 我希望改进或要求我目前的延迟/睡眠方法。C++
- 虚假唤醒是否会解锁所有等待线程,甚至是不相关的线程?
- 如何等待窗口隐藏在Qt中?
- 如何在 c++ 中延迟?
- 如何在不等待检索的情况下获取C++中的内存位置?
- 等待被迷住了,没有回来
- 如何测量管道延迟?
- 获取毫秒延迟的错误值
- C++中的点云库(PCL)等待/延迟/睡眠功能
- C++11 延迟"thread"创建(即指定线程功能但不等待创建物理线程)