nuscenes_data/
lib.rs

1//! nuScenes dataset loader.
2//!
3//! # Tutorial
4//!
5//! This section gives a brief overview of this crate. It assumes the
6//! dataset is located at "/path/to/dataset" directory. It contains a
7//! "v1.0-trainval" directory, which name is also the version number.
8//!
9//! ## Load nuScenes Dataset
10//!
11//! Import [Dataset] type and use it to load the data directory. The
12//! dataset version is "v1.0-trainval" in this example. You should
13//! able to find the "/path/to/dataset/v1.0-trainval" directory.
14//!
15//! ```ignore
16//! use nuscenes_data::Dataset;
17//!
18//! let dataset = Dataset::load("v1.0-trainval", "/path/to/dataset")?;
19//! ```
20//!
21//! ## Traverse Scenes and Samples in the Dataset
22//!
23//! The dataset contains many scenes. Use `dataset.scene_iter()` to
24//! iterate over scenes in the dataset. Scenes contain samples. Use
25//! `scene.sample_iter()` to iterate them.
26//!
27//! ```ignore
28//! for scene dataset.scene_iter() {
29//!     for sample in scene.sample_iter() {
30//!         for annotation in sample.annotatoin_iter() { /* omit */ }
31//!         for data in sample.sample_data_iter() { /* omit */ }
32//!     }
33//! }
34//! ```
35//!
36//! ## Look-up Samples using Tokens
37//!
38//! It supports data query using tokens. The usage is straightforward.
39//!
40//! ```ignore
41//! let sample_token = Token::from_str("24fa5b014824491f9bd2f9e4a1a1b5b8").unwrap();
42//! let sample = dataset.sample(sample_token).unwrap();
43//!
44//! let sensor_token = Token::from_str("1f69f87a4e175e5ba1d03e2e6d9bcd27").unwrap();
45//! let sensor = dataset.sensor(sensor_token).unwrap();
46//! ```
47//!
48//! ## Associated Data Query
49//!
50//! It's easy to search to associated data in the dataset.
51//!
52//! ```ignore
53//! let scene = dataset.scene_iter().first().unwrap();
54//! let sample = scene.sample_iter().first().unwrap();
55//! let data = sample.sample_data_iter().first().unwrap();
56//! let ego_pose = data.ego_pose();
57//! let calibrated_sensor = data.calibrated_sensor();
58//! ```
59//!
60//! ## Integration with [nalgebra](https://docs.rs/nalgebra)
61//!
62//! Add this extension crate to enable [nalgebra](https://docs.rs/nalgebra) support.
63//!
64//! ```sh
65//! cargo add nuscenes-data-nalgebra
66//! ```
67//!
68//! It add extra methods to existing types. This example obtains an
69//! nalgebra transformation from an ego\_pose object.
70//!
71//! ```ignore
72//! use nuscenes_data_nalgebra::prelude::*;
73//! use nalgebra as na;
74//!
75//! let ego_pose = dataset.ego_pose(token).unwrap();
76//! let transform: na::Isometry3<f64> = ego_pose.na_transform();
77//!
78//! let old_point = na::Point3::new(0.0, 0.0, 0.0);
79//! let new_point = &transform * &old_point;
80//! ```
81//!
82//! ## Load Data Files
83//!
84//! This crate supports integration with
85//! [opencv](https://docs.rs/opencv), [image](https://docs.rs/image)
86//! and [pcd-rs](https://docs.rs/pcd-rs) crates. Add these extension
87//! crates to enable this.
88//!
89//! ```sh
90//! cargo add nuscenes-data-opencv
91//! cargo add nuscenes-data-image
92//! cargo add nuscenes-data-pcd
93//! ```
94//!
95//! It adds data loading methods on sample data objects.
96//!
97//! ```ignore
98//! // image
99//! use nuscenes_data_image::prelude::*;
100//! let image_sample = dataset.sample_data(token).unwrap();
101//! let image: image::DynamicImage = image_sample.load_dynamic_image()?.unwrap();
102//!
103//! // opencv
104//! use nuscenes_data_opencv::prelude::*;
105//! let image_sample = dataset.sample_data(token).unwrap();
106//! let image: opencv::core::Mat = image_sample.load_opencv_mat()?.unwrap();
107//!
108//! // pcd-rs
109//! use nuscenes_data_pcd::{prelude::*, PointCloud};
110//! let pcd_sample = dataset.sample_data(token).unwrap();
111//! let pcd: PointCloud = pcd_sample.load_pcd()?.unwrap();
112//! match pcd {
113//!     PointCloud::Pcd(points) => { /* Loaded from a .pcd file */ }
114//!     PointCloud::Bin(points) => { /* Loaded from a .bin file */  }
115//!     PointCloud::NotSupported => {}
116//! }
117//! ```
118
119pub mod dataset;
120pub mod error;
121pub mod loader;
122pub mod serializable;
123pub mod utils;
124
125pub use crate::{dataset::Dataset, loader::DatasetLoader, serializable::Token};