PCL 打印当前 FPS
PCL print current FPS
我正在使用 PCL 库来可视化单个 .ply 模型。如何打印显示在 window?
左下角的每秒帧数 (FPS)
这是我的简单代码。我们只需要添加类似 cout<<print(current_fps);
的内容
#include <iostream>
//#include <unistd.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/console/parse.h>
#include <pcl/common/transforms.h>
#include <pcl/visualization/pcl_visualizer.h>
// Main function
int main(int argc, char **argv)
{
// Fetch point cloud filename in arguments | Works with PLY files
std::vector<int> filenames;
filenames = pcl::console::parse_file_extension_argument(argc, argv, ".ply");
// Load file | Works with PLY files
pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_cloud (new pcl::PointCloud<pcl::PointXYZRGB>());
pcl::io::loadPLYFile(argv[filenames[0]], *source_cloud);
// Visualization
printf("\n Point cloud colors :\n"
" \t white \t = \t original point cloud \n");
pcl::visualization::PCLVisualizer viewer(" Point Cloud Datsets Visualizer");
viewer.setBackgroundColor(0.05, 0.05, 0.05, 0); // Set background to a dark grey
// Define R,G,B colors for the point cloud
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(source_cloud);
// We add the point cloud to the viewer and pass the color handler
viewer.addPointCloud(source_cloud, rgb, "original_cloud");
viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "original_cloud");
//******************************
std::vector<Point, Eigen::aligned_allocator<Point>> points = source_cloud->points;
//******************************
while (!viewer.wasStopped()) { // Display the visualizer until the 'q' key is pressed
viewer.spinOnce();
}
return 0;
} // End main()
您可以使用 getFPS()。该问题已修复
https://github.com/PointCloudLibrary/pcl/pull/1974
然后你可以这样做
std::cout<<viewer.getFPS();
这将为您提供当前渲染帧率的浮点值。
我正在使用 PCL 库来可视化单个 .ply 模型。如何打印显示在 window?
左下角的每秒帧数 (FPS)这是我的简单代码。我们只需要添加类似 cout<<print(current_fps);
#include <iostream>
//#include <unistd.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/console/parse.h>
#include <pcl/common/transforms.h>
#include <pcl/visualization/pcl_visualizer.h>
// Main function
int main(int argc, char **argv)
{
// Fetch point cloud filename in arguments | Works with PLY files
std::vector<int> filenames;
filenames = pcl::console::parse_file_extension_argument(argc, argv, ".ply");
// Load file | Works with PLY files
pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_cloud (new pcl::PointCloud<pcl::PointXYZRGB>());
pcl::io::loadPLYFile(argv[filenames[0]], *source_cloud);
// Visualization
printf("\n Point cloud colors :\n"
" \t white \t = \t original point cloud \n");
pcl::visualization::PCLVisualizer viewer(" Point Cloud Datsets Visualizer");
viewer.setBackgroundColor(0.05, 0.05, 0.05, 0); // Set background to a dark grey
// Define R,G,B colors for the point cloud
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(source_cloud);
// We add the point cloud to the viewer and pass the color handler
viewer.addPointCloud(source_cloud, rgb, "original_cloud");
viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "original_cloud");
//******************************
std::vector<Point, Eigen::aligned_allocator<Point>> points = source_cloud->points;
//******************************
while (!viewer.wasStopped()) { // Display the visualizer until the 'q' key is pressed
viewer.spinOnce();
}
return 0;
} // End main()
您可以使用 getFPS()。该问题已修复 https://github.com/PointCloudLibrary/pcl/pull/1974
然后你可以这样做
std::cout<<viewer.getFPS();
这将为您提供当前渲染帧率的浮点值。