统计一下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 <iostream>
#include<sstream>
#include<stdlib.h> //rand()头文件
#include<pcl/point_types.h>
#include <pcl/io/pcd_io.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/sample_consensus/method_types.h>   //随机参数估计方法
#include <pcl/sample_consensus/model_types.h>    //模型定义
#include <pcl/segmentation/sac_segmentation.h>   //RANSAC分割
#include <pcl/filters/extract_indices.h>
#include <boost/thread/thread.hpp>
#include <pcl/visualization/pcl_visualizer.h>

#include <pcl/console/time.h>

//自己写一个小代码,统计一下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<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
	//if (pcl::io::loadPCDFile<pcl::PointXYZ>("C:/PCLproject/bin2pcd2/velodyne/pcd/000020.pcd", *cloud) == -1)
 //	//if (pcl::io::loadPCDFile<pcl::PointXYZ>("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})
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
### 回答1: Kitti数据集是一个用于自动驾驶以及计算机视觉的数据集,包含了许多不同类型的数据,包括激光雷达和相机的数据。如果想要将激光雷达数据可视化到图像上,可以使用Python编写代码来实现。 首先需要加载点云数据,在Python中可以使用PCL库或Open3D库。在加载点云数据之后,需要将其转换成图像数据,这可以通过将点云数据投影到一个平面上来实现,这个平面是车辆朝向的平面。在投影点云数据时可以根据需求选择投影的范围和分辨率。然后使用opencv库将投影的数据从灰度图像转换为彩色图像,并将图像保存在本地或者在屏幕上播放。 当然,对于初学者来说,上述代码并不容易理解和实现。因此,建议学习和掌握以下内容: 1. Python基础知识,包括语法、控制流和函数等。 2. PCL和Open3D库的基本使用方法。 3. Opencv库的基本使用方法。 4. 点云数据转换成图像数据的方法和参数。 最后,建议查阅相关的代码示例和文档,因为这有助于更好地理解代码和算法。通过不断练习,您可以将点云数据可视化到图像上,并得到更深层次的理解。 ### 回答2: Kitti数据集是一个基于激光雷达的自动驾驶数据集,里面包括了多种不同场景下的点云数据、图像数据和各种传感器数据。其中,点云数据对于自动驾驶系统的实现具有重要意义。以下是使用Python将点云数据可视化到图像上的步骤: 1. 安装必要的Python库: ```python pip install numpy matplotlib open3d opencv-python ``` 2. 加载点云数据: 从Kitti数据集中选取某个场景下的点云数据,使用Python加载点云数据文件: ```python import numpy as np pcd = np.fromfile("path_to_point_cloud_file.bin", dtype=np.float32).reshape(-1, 4) ``` 3. 可视化点云数据: 使用Open3D库可视化点云数据,实现点云数据在三维空间内的展示: ```python import open3d as o3d pcd = o3d.geometry.PointCloud() pcd.points = o3d.utility.Vector3dVector(points) o3d.visualization.draw_geometries([pcd]) ``` 4. 投影点云数据到图像平面: 将点云数据投影到图像平面上,通过OpenCV库将点云数据可视化到图像上: ```python import cv2 from kitti_projection import KittiProjection range_image = KittiProjection().project_lidar_to_image(points, image_size=(1242, 375)) cv2.imshow("Range Image", range_image) cv2.waitKey(0) ``` 5. 结论: 通过上述步骤,我们可以将Kitti数据集中的点云数据可视化到图像上,实现自动驾驶系统中点云数据和图像数据的结合,为自动驾驶系统的实现提供支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值