jbehley / point_labeler

My awesome point cloud labeling tool
MIT License
647 stars 161 forks source link

How to run kitti_raw2odometry.py #24

Closed josy43 closed 3 years ago

josy43 commented 4 years ago

When I run the script it just displays the "print" command : Convert KITTI's raw format into odometry format consumable by point_labeler. ./kitti_raw2odometry.py []

I created folders with the name input_folder, which contains the .bin file and outpot_folder. But there is no file in the output folder after I run the conversion script.

jbehley commented 4 years ago

Let's assume your folder with the raw data is in the folder /home/josy43/data/kitti/2019-12-10 and you want to write the result into /home/josy43/data/converted/2019-12-10, then you have to call:

./kitti_raw2odometry.py /home/josy43/data/kitti/2019-12-10 /home/josy43/data/converted/2019-12-10

But you can also give no output folder, it is optional: therefore the brackets. These are only examples... so modify this as it fits.

The input folder must contain the veoldyne_points, oxts, image folder from the raw archive.

josy43 commented 4 years ago

Thanks it works. As far as I understood, i just need my Pointcloud to be in .bin format. So I just have this file. I dont have image files or oxts files. So how can I skip this. I just need my .bin file to be in kitti odometry format.

jbehley commented 4 years ago

You also need the poses. And it should be finally in the expected folder structure.

Images are optional, but you usually just download them with the raw synced rectified data.

josy43 commented 4 years ago

But how can I get them. I did the following: I had a Pointcloudstream in rosbag format and extracted the frames in pcd format. Then I converted the .pcd format in .bin format. I don´t see where I can find or extraxt poses or oxts data.

jbehley commented 4 years ago

The script kitti_raw2odometry is meant to convert the KITTI raw dataset into a "odometry" style dataset using the GPS poses as scan poses. If you want to use your custom data, you have to produce the following folder structure:

point cloud folder
├── velodyne/             -- directory containing ".bin" files with Velodyne point clouds.   
├── labels/   [optional]  -- label directory, will be generated if not present.  
├── image_2/  [optional]  -- directory containing ".png" files from the color   camera.  
├── calib.txt             -- calibration of velodyne vs. camera. needed for projection of point cloud into camera.  
└── poses.txt             -- file containing the poses of every scan.

The calib.txt can be very generic (as mentioned in https://github.com/jbehley/point_labeler/issues/23#issuecomment-640119577):

P0: 1 0 0 0 0 1 0 0 0 0 1 0 P1: 1 0 0 0 0 1 0 0 0 0 1 0 P2: 1 0 0 0 0 1 0 0 0 0 1 0 P3: 1 0 0 0 0 1 0 0 0 0 1 0 Tr: 1 0 0 0 0 1 0 0 0 0 1 0

If you want to fully exploit sequential point clouds, you have to provide poses. You can estimate poses with SuMa (https://github.com/jbehley/suma). You might have to adjust the params in "config/default.xml".

josy43 commented 4 years ago

How do I convert my custom .bin files ti KITTI.bin files ?. When I read both in .txt files there is a difference in dimensions. The values of the KITTI dimensions are something between -100;100 while the dimensions of my data is between 5e-41; 5e+31.

jbehley commented 4 years ago

I cannot comment on this, since I don't know what sensor you use or how you convert the data. And I furthermore cannot tell if your code is correct.

The KITTI format stores as binary file 4 floats for each point: x,y,z,remission. The x,y,z coordinates are give in meters. Some sensors return distances as cm, thus you might have to scale the value appropriately.

josy43 commented 4 years ago

I have my Pointclouds in PCD format. Opened in an editor ist looks like this:

VERSION 0.7 FIELDS x y z intensity ring time SIZE 4 4 4 4 2 4 TYPE F F F F U F COUNT 1 1 1 1 1 1 WIDTH 37067 HEIGHT 1 VIEWPOINT 0.0 0.0 0.0 1.0 0.0 0.0 0.0 POINTS 37067 DATA ascii -8.5294103622e+00 -5.3352613449e+00 -2.6422095299e+00 3.6000000000e+01 0 -9.9462985992e-02 -4.3950276375e+00 -1.2794736862e+01 -2.4698644876e-01 2.0000000000e+00 17 -9.9462985992e-02 ......

When I convert a kitti velodyne binary to pcd and open it in a txt file it shows just x,y,z and intensity. I also tried pcd to bin scripts but they don´t work. So I don´t know how to convert my ASCII file to KITTI binary format.

I know it´s out of topic but I appreciate your effort

jbehley commented 4 years ago

Sorry for the delay.

It seems like that your PCD file has points with 5 values. To convert the data into a KITTI compliant format, you have to perform the following steps:

  1. Read the point cloud with something like https://github.com/dimatura/pypcd. This will give you the point cloud data as a numpy array.
  2. Get from the array the x,y,z,remission/itensity values, and then write the array arr with arr.tofile(filename) to a file in a velodyne folder.
  3. You also need a calib.txt, with identity matrix. As mentioned above.

If you have a folder with velodyne as subfolder with 00000.bin, 00001.bin, 00002.bin, ... for each scan, you can either use SuMa or something else to estimate poses (best option) or generate a poses.txt, where you have the identity matrix for each pose. (12 values: 1 0 0 0 0 1 0 0 0 0 1 0)

If you used option 2, you can now view the individual points clouds also in the labeler, but have to select "show single scan", which just will render one scan.

But as I said, the real deal you get only with pose information.

You can also have a look on my script to convert the nuScenes data into a KITTI-like format: https://gist.github.com/jbehley/1f2a68cba1b1914bb8b23f2de08fc233#file-nuscenes2kitti-py

jbehley commented 3 years ago

Since there is no activity since some time, I close this issue now. If you have further comments on this issue, you can reopen it. Thanks.