PCL打印当前FPS

时间:2017-07-20 19:25:41

标签: api graphics 3d point-cloud-library point-clouds

我正在使用PCL库来显示单个.ply模型。如何打印窗口左下方显示的每秒帧数(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()

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用getFPS()。问题已解决 https://github.com/PointCloudLibrary/pcl/pull/1974

然后你可以做类似

的事情
std::cout<<viewer.getFPS();

这将为您提供当前渲染帧速率的浮点值。