统计一下kitti 07 序列里面某一帧点云大概有多少个点,然后加载一帧点云花费多少时间

简单测试kitti里程计07序列的10帧点云(已经从bin转换为pcd),vs2017运行输出结果

now count the pcd filename is 000000.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000000.pcd
read this frame pcd costtime is 645ms
read this frame pcd points is 122627 points
now time_average is 645ms
now count the pcd filename is 000001.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000001.pcd
read this frame pcd costtime is 658ms
read this frame pcd points is 122620 points
now time_average is 651.5ms
now count the pcd filename is 000002.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000002.pcd
read this frame pcd costtime is 652ms
read this frame pcd points is 122663 points
now time_average is 651.667ms
now count the pcd filename is 000003.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000003.pcd
read this frame pcd costtime is 643ms
read this frame pcd points is 122582 points
now time_average is 649.5ms
now count the pcd filename is 000004.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000004.pcd
read this frame pcd costtime is 649ms
read this frame pcd points is 122505 points
now time_average is 649.4ms
now count the pcd filename is 000005.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000005.pcd
read this frame pcd costtime is 643ms
read this frame pcd points is 122527 points
now time_average is 648.333ms
now count the pcd filename is 000006.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000006.pcd
read this frame pcd costtime is 655ms
read this frame pcd points is 122371 points
now time_average is 649.286ms
now count the pcd filename is 000007.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000007.pcd
read this frame pcd costtime is 651ms
read this frame pcd points is 122301 points
now time_average is 649.5ms
now count the pcd filename is 000008.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000008.pcd
read this frame pcd costtime is 652ms
read this frame pcd points is 122298 points
now time_average is 649.778ms
now count the pcd filename is 000009.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000009.pcd
read this frame pcd costtime is 652ms
read this frame pcd points is 122336 points
now time_average is 650ms
now count the pcd filename is 000010.pcd
now count the pcd filepath is C:/PCLproject/bin2pcd2/velodyne/pcd/000010.pcd
read this frame pcd costtime is 646ms
read this frame pcd points is 122475 points
now time_average is 649.636ms

程序代码 test_timecost.cpp

#include 
#include
#include //rand()头文件
#include
#include 
#include 
#include    //随机参数估计方法
#include     //模型定义
#include    //RANSAC分割
#include 
#include 
#include 

#include 

//自己写一个小代码,统计一下kitti 07 序列里面某一帧点云大概有多少个点,
//然后加载一帧点云花费多少时间

using namespace std;

int
   main()
{
	// ----------------------------加载点云-----------------------------
	// 定义一个对象,用来加载点云,然后输出点的个数
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);

	double time_cost_sum = 0;
	double time_average = 0;

	for (int i = 0; i <= 10; i++) {
		stringstream ss;
		ss << setw(6) << setfill('0') << i;
		//在循环内临时存放文件名
		string str;
		ss >> str;

		str = str + ".pcd";

		cout << "now count the pcd filename is " << str << endl;

		string filepath = "C:/PCLproject/bin2pcd2/velodyne/pcd/" + str;

		cout << "now count the pcd filepath is " << filepath << endl;

		// 计算加载点云消耗的时间, 为了尽量客观,不使用if 进行是否读取成功的检验
		pcl::console::TicToc time1;
		time1.tic();

		pcl::io::loadPCDFile<pcl::PointXYZ>(filepath, *cloud);

		double temp = time1.toc();

		cout << "read this frame pcd costtime is " << temp << "ms" << endl;

		cout << "read this frame pcd points is " << cloud->size() << " points" << endl;

		time_cost_sum += temp;
		// 因为帧是从 00000 开始,i也从0开始,计算平均时候需要注意
		time_average = time_cost_sum / (i + 1);

		cout << "now time_average is " << time_average << "ms" << endl;



		
	
	}

	//pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
	//if (pcl::io::loadPCDFile("C:/PCLproject/bin2pcd2/velodyne/pcd/000020.pcd", *cloud) == -1)
 //	//if (pcl::io::loadPCDFile("C:/datapcl/pcd/table_scene_lms400.pcd", *cloud) == -1)

	//{
	//	PCL_ERROR("读取源标点云失败 \n");
	//	return (-1);
	//}
	//cout << "从点云中读取 " << cloud->size() << " 个点" << endl;


	return (0);
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(test_timecost)

find_package(PCL 1.5 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable (test_timecost test_timecost.cpp)
target_link_libraries (test_timecost ${PCL_LIBRARIES})

你可能感兴趣的:(个人知识梳理,c++,算法,数据结构)