当前位置:   article > 正文

【辅助驾驶】KITTI激光数据与图像数据的融合MATLAB实现[3]——官方数据融合例程_run_demovelodyne.m

run_demovelodyne.m

一、实现效果

二、代码

官方代码:run_demoVelodyne.m

  1. function run_demoVelodyne (base_dir,calib_dir)
  2. % KITTI RAW DATA DEVELOPMENT KIT
  3. %
  4. % Demonstrates projection of the velodyne points into the image plane
  5. %
  6. % Input arguments:
  7. % base_dir .... absolute path to sequence base directory (ends with _sync)
  8. % calib_dir ... absolute path to directory that contains calibration files
  9. % clear and close everything
  10. close all; dbstop error; clc;
  11. disp('======= KITTI DevKit Demo =======');
  12. % options (modify this to select your sequence)
  13. if nargin<1
  14. base_dir = '/mn/karlsruhe_dataset/2011_09_26/2011_09_26_drive_0009_sync';
  15. end
  16. if nargin<2
  17. calib_dir = '/mnt/karlsruhe_dataset/2011_09_26';
  18. end
  19. cam = 2; % 0-based index
  20. frame = 0; % 0-based index
  21. % load calibration
  22. calib = loadCalibrationCamToCam(fullfile(calib_dir,'calib_cam_to_cam.txt'));
  23. Tr_velo_to_cam = loadCalibrationRigid(fullfile(calib_dir,'calib_velo_to_cam.txt'));
  24. % compute projection matrix velodyne->image plane
  25. R_cam_to_rect = eye(4);
  26. R_cam_to_rect(1:3,1:3) = calib.R_rect{1};
  27. P_velo_to_img = calib.P_rect{cam+1}*R_cam_to_rect*Tr_velo_to_cam;
  28. % load and display image
  29. img = imread(sprintf('%s/image_%02d/data/%010d.png',base_dir,cam,frame));
  30. fig = figure('Position',[20 100 size(img,2) size(img,1)]); axes('Position',[0 0 1 1]);
  31. imshow(img); hold on;
  32. % load velodyne points
  33. fid = fopen(sprintf('%s/velodyne_points/data/%010d.bin',base_dir,frame),'rb');
  34. velo = fread(fid,[4 inf],'single')';
  35. velo = velo(1:5:end,:); % remove every 5th point for display speed
  36. fclose(fid);
  37. % remove all points behind image plane (approximation
  38. idx = velo(:,1)<5;
  39. velo(idx,:) = [];
  40. % project to image plane (exclude luminance)
  41. velo_img = project(velo(:,1:3),P_velo_to_img);
  42. % plot points
  43. cols = jet;
  44. for i=1:size(velo_img,1)
  45. col_idx = round(64*5/velo(i,1));
  46. plot(velo_img(i,1),velo_img(i,2),'o','LineWidth',4,'MarkerSize',1,'Color',cols(col_idx,:));
  47. end

三、代码下载

官方代码下载:Download the raw data development kit (1 MB)

参考:

[机器学习]KITTI的雷达+摄像头数据融合》——对KITTI数据集和实现有说明

激光相机数据融合(4)--KITTI数据集中matlab接口说明及扩展》——对MATLAB程序有较为详细的说明

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/116599
推荐阅读
相关标签
  

闽ICP备14008679号