下载原始的数据集后,通过终端来运行:
unzip 2011_10_03_calib.zip
和
unzip 2011_10_03_drive_0047_sync.zip
这样这个文件夹才算准备好:
然后去下载kitti2bag工具:
pip install kitti2bag
然后去2011_10_03文件夹下执行:
kitti2bag -t 2011_10_03 -r 0047 raw_synced .
转换完毕.
方法二,直接通过python来发布数据:
解析数据:input_ros_kitti.py
import rospy
from sensor_msgs.msg import Image,PointCloud2
from cv_bridge import CvBridge
import numpy as np
import os
import cv2
from pub_publish import *
# 保存解压后数据的地方DATA_PATH='/home/t/t/Row_Data/2011_09_26/2011_09_26_drive_0005_sync/'
if __name__=='__main__':rospy.init_node('kitti_node',anonymous=True)cam_pub=rospy.Publisher('kitti_cam',Image,queue_size=10)pcl_pub=rospy.Publisher('kitti_pcl',PointCloud2,queue_size=10)bridge=CvBridge()rate=rospy.Rate(10)frame=0# 循环播放,通过frame控制帧数while not rospy.is_shutdown():img=cv2.imread(os.path.join(DATA_PATH,'image_02/data/%010d.png'%frame))pcl=np.fromfile(os.path.join(DATA_PATH,'velodyne_points/data/%010d.bin'%frame),dtype=np.float32).reshape(-1,4)publish_camera(cam_pub,bridge,img)publish_pcl(pcl_pub,pcl)rospy.loginfo('published')rate.sleep()frame+=1frame%=154
发布数据的函数pub_publish.py
from std_msgs.msg import Header
import rospy
import sensor_msgs.point_cloud2 as pcl2
FRAME_ID='map'
def publish_camera(cam_pub,bridge,image):cam_pub.publish(bridge.cv2_to_imgmsg(image,'bgr8'))def publish_pcl(pcl_pub,point_cloud):header=Header()header.stamp=rospy.Time.now()header.frame_id=FRAME_IDpcl_pub.publish(pcl2.create_cloud_xyz32(header,point_cloud[:,:3]))
文件依然和方法一同样解压,放在同样的位置下。
最后来看一下如何将bag文件进行包围框的可视化。
参考
还是有点意思的。