kitti_dataset/
lib.rs

1//! Dataset loader, data parsers and writers for KITTI dataset.
2//!
3//! ## Dataset Loader
4//!
5//! The dataset loader allows you to iterate through all kinds of data
6//! samples. Currently, [ObjectDataset](dataset::ObjectDataset) and
7//! [TrackingDataset](dataset::TrackingDataset) are supported.
8//!
9//! The dataset layout for _Object Detection Evaluation 2012_ dataset
10//! is presented below for example. You can download appropriate zip
11//! files on the [official
12//! site](https://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=2d)
13//! and extract them together to get the layout.
14//!
15//! ```ignore
16//! object/training
17//! ├── calib
18//! ├── image_2
19//! ├── image_3
20//! ├── label_2
21//! └── velodyne
22//! ```
23//!
24//! The usage of dataset API is demonstrated in the code.
25//!
26//! ```no_run
27//! use kitti_dataset::dataset::{object::SampleData, ObjectDataset};
28//!
29//! # fn main() -> anyhow::Result<()> {
30//! let dataset = ObjectDataset::open("/path/to/kitti_dir/object/training")?;
31//!
32//! // To get a specific frame
33//! let frame = dataset.frame(0).unwrap();
34//!
35//! // Iterate through all frames
36//! for frame in dataset.frame_iter() {
37//!     // Obtain a specific sample
38//!     let sample = frame.key("image_2").unwrap();
39//!     let SampleData::Image(image) = sample.data()? else {
40//!         unreachable!();
41//!     };
42//!
43//!     // Iterate through all samples
44//!     for sample in frame.sample_iter() {
45//!         let data = sample.data()?;
46//!     }
47//! }
48//! # Ok(())
49//! # }
50//! ```
51//!
52//! ## Data Types
53//!
54//! The section is a comprehensive list of available data types used
55//! in the KITTI dataset. Each type has one or more associated data
56//! loaders. For example,
57//! [Label::vec_from_path()](object::Label::vec_from_path) reads a
58//! list of labels in one .txt file. Please click into the type pages
59//! to discover available methods.
60//!
61//! ### Common
62//!
63//! - [common::PointCloud] - 3D Object Detection Evaluation 2017 Velodyne point cloud type
64//! - [common::ProjectionMatrix] - A 3x4 matrix that describes a world to camera coordinate transform
65//! - [common::Transform2D] - A 3x3 matrix that describes a 2D coordinate transform
66//!
67//!
68//! ### Object Detection
69//!
70//! - [object::Label] - Object detection labels for Object Detection Evaluation
71//!
72//!     ```text
73//!     Car 0.00 0 -1.58 587.01 173.33 614.12 200.12 1.65 1.67 3.64 -0.65 1.71 46.70 -1.59
74//!     Cyclist 0.00 0 -2.46 665.45 160.00 717.93 217.99 1.72 0.47 1.65 2.45 1.35 22.10 -2.35
75//!     Pedestrian 0.00 2 0.21 423.17 173.67 433.17 224.03 1.60 0.38 0.30 -5.87 1.63 23.11 -0.03
76//!     ```
77//!
78//! - [object::Calibration] - 3D Object Detection Evaluation 2017 camera calibration matrices
79//!
80//!     ```text
81//!     P0: 7.070493000000e+02 0.000000000000e+00 6.040814000000e+02 0.000000000000e+00 0.000000000000e+00 7.070493000000e+02 1.805066000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
82//!     P1: 7.070493000000e+02 0.000000000000e+00 6.040814000000e+02 -3.797842000000e+02 0.000000000000e+00 7.070493000000e+02 1.805066000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
83//!     P2: 7.070493000000e+02 0.000000000000e+00 6.040814000000e+02 4.575831000000e+01 0.000000000000e+00 7.070493000000e+02 1.805066000000e+02 -3.454157000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 4.981016000000e-03
84//!     P3: 7.070493000000e+02 0.000000000000e+00 6.040814000000e+02 -3.341081000000e+02 0.000000000000e+00 7.070493000000e+02 1.805066000000e+02 2.330660000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 3.201153000000e-03
85//!     R0_rect: 9.999128000000e-01 1.009263000000e-02 -8.511932000000e-03 -1.012729000000e-02 9.999406000000e-01 -4.037671000000e-03 8.470675000000e-03 4.123522000000e-03 9.999556000000e-01
86//!     Tr_velo_to_cam: 6.927964000000e-03 -9.999722000000e-01 -2.757829000000e-03 -2.457729000000e-02 -1.162982000000e-03 2.749836000000e-03 -9.999955000000e-01 -6.127237000000e-02 9.999753000000e-01 6.931141000000e-03 -1.143899000000e-03 -3.321029000000e-01
87//!     Tr_imu_to_velo: 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01
88//!     ```
89//!
90//!
91//! ### Tracking
92//!
93//! - [tracking::Label] - Tracking labels for Object Tracking Evaluation
94//!
95//!     ```text
96//!     0 40 Car 0 1 -0.846079 1129.142258 162.748587 1241.000000 223.323419 1.500000 1.610071 4.069631 16.204139 1.250580 19.092509 -0.150167
97//!     1 0 Car 0 0 2.917216 0.000000 182.291562 220.536500 256.742509 1.491984 1.588650 4.106539 -11.652879 1.736447 16.864469 2.319742
98//!     1 1 Car 0 0 2.886886 398.707515 170.768137 553.526667 222.702626 1.492172 1.666927 4.500000 -4.227687 1.449374 22.678314 2.704154
99//!     1 2 Car 0 1 -1.134233 830.185677 160.148863 991.640373 251.980749 1.649293 1.669751 3.639134 6.203001 1.432202 14.799351 -0.745043
100//!     2 0 Car 0 0 2.952925 0.000000 181.644428 160.336384 258.017227 1.491984 1.588650 4.106539 -12.245073 1.702574 15.415174 2.289919
101//!     ```
102//!
103//! - [tracking::Oxts] - GPS/IMU data type for Object Tracking Evaluation
104//!
105//!     ```text
106//!     49.011212804408 8.4228850417969 112.83492279053 0.022447 1e-05 -1.2219096732051 -3.3256321640686 1.1384311814592 3.5147680214713 0.037625160413037 -0.03878884255623 -0.29437452763793 0.037166856911681 9.9957015129717 -0.30581030960531 -0.19635662515203 9.9942128010936 -0.017332142869546 0.024792163815438 0.14511808479348 -0.017498934149631 0.021393359392165 0.14563031426063 0.49229361157748 0.068883960397178 4 10 4 4 0
107//!     49.01120997371 8.4228865746799 112.84690093994 0.022857 0.004342 -1.2060766732051 -3.2881070007181 1.1667449071211 3.488638681917 0.054703935610776 0.011017553303551 -0.14011828216638 1.0142711526489 10.536284805105 -0.11933995891782 0.77095084470794 10.557191097922 -0.0044213078422351 0.047499861901847 0.13888384511551 -0.0041658784261557 0.044282418023417 0.13995351452114 0.49229361157748 0.068883960397178 4 10 4 4 0
108//!     49.011207340729 8.4228879062526 112.86553955078 0.023136 0.014862 -1.1936236732051 -3.2411567408588 1.2346955705869 3.468542331508 0.020905692383421 0.087430817119982 -0.37599422874402 0.92464351685799 10.21491279541 -0.28214813630003 0.68838604691212 10.237591960914 -0.0011286126703085 0.10138706616598 0.12365328181544 8.8704809942824e-06 0.098502901229822 0.12597678052672 0.51960850647386 0.072917761896537 4 10 4 4 0
109//!     ```
110//!
111//!
112//! ### Odometry
113//!
114//! - [odometry::Calibration] - Visual Odometry / SLAM Evaluation 2012 calibration files
115//!
116//!     ```text
117//!     P0: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 0.000000000000e+00 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
118//!     P1: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 -3.861448000000e+02 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
119//!     P2: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 4.538225000000e+01 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 -1.130887000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 3.779761000000e-03
120//!     P3: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 -3.372877000000e+02 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 2.369057000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 4.915215000000e-03
121//!     Tr: 4.276802385584e-04 -9.999672484946e-01 -8.084491683471e-03 -1.198459927713e-02 -7.210626507497e-03 8.081198471645e-03 -9.999413164504e-01 -5.403984729748e-02 9.999738645903e-01 4.859485810390e-04 -7.206933692422e-03 -2.921968648686e-01
122//!     ```
123//!
124//! - [odometry::Pose] - Visual Odometry / SLAM Evaluation 2012 pose
125//!
126//!     ```text
127//!     1.000000e+00 9.043680e-12 2.326809e-11 5.551115e-17 9.043683e-12 1.000000e+00 2.392370e-10 3.330669e-16 2.326810e-11 2.392370e-10 9.999999e-01 -4.440892e-16
128//!     9.999978e-01 5.272628e-04 -2.066935e-03 -4.690294e-02 -5.296506e-04 9.999992e-01 -1.154865e-03 -2.839928e-02 2.066324e-03 1.155958e-03 9.999971e-01 8.586941e-01
129//!     9.999910e-01 1.048972e-03 -4.131348e-03 -9.374345e-02 -1.058514e-03 9.999968e-01 -2.308104e-03 -5.676064e-02 4.128913e-03 2.312456e-03 9.999887e-01 1.716275e+00
130//!     ```
131
132pub(crate) mod calib_codegen;
133pub mod common;
134pub mod dataset;
135pub mod error;
136pub mod object;
137pub mod odometry;
138pub(crate) mod serde;
139pub mod tracking;
140
141pub use common::{Point, ProjectionMatrix, Transform2D};
142pub use error::Error;