Upload 3 files
Browse files- README.md +107 -0
- header_flow.jpg +3 -0
- kitti-flow2012.py +117 -0
README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-sa-3.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# Dataset Card for KITTI Flow 2012
|
| 6 |
+
|
| 7 |
+
## Dataset Description
|
| 8 |
+
|
| 9 |
+
The **KITTI Flow 2012** dataset is a real-world benchmark dataset designed to evaluate optical flow estimation algorithms in the context of autonomous driving. Introduced in the seminal paper ["Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite"](http://www.cvlibs.net/publications/Geiger2012CVPR.pdf) by Geiger et al., it provides challenging sequences recorded from a moving platform in urban, residential, and highway scenes.
|
| 10 |
+
|
| 11 |
+
**Optical flow** refers to the apparent motion of brightness patterns in image sequences, used to estimate the motion of objects and the camera in the scene. It is a fundamental problem in computer vision with applications in visual odometry, object tracking, motion segmentation, and autonomous navigation.
|
| 12 |
+
|
| 13 |
+
KITTI Flow 2012 contributes to optical flow research by providing:
|
| 14 |
+
- Real-world stereo image pairs captured at two consecutive timepoints (t0 and t1).
|
| 15 |
+
- Sparse ground-truth optical flow maps at t0, annotated using 3D laser scans.
|
| 16 |
+
- Calibration files to relate image pixels to 3D geometry.
|
| 17 |
+
- Disparity ground truth and stereo imagery for related benchmarking.
|
| 18 |
+
|
| 19 |
+
The dataset enables fair and standardized comparison of optical flow algorithms and is widely adopted for benchmarking performance under real driving conditions.
|
| 20 |
+
|
| 21 |
+

|
| 22 |
+
|
| 23 |
+
## Dataset Source
|
| 24 |
+
- **Homepage**: [http://www.cvlibs.net/datasets/kitti/eval_stereo_flow.php?benchmark=flow](http://www.cvlibs.net/datasets/kitti/eval_stereo_flow.php?benchmark=flow)
|
| 25 |
+
- **License**: [Creative Commons Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 3.0)](https://creativecommons.org/licenses/by-nc-sa/3.0/)
|
| 26 |
+
- **Paper**: Andreas Geiger, Philip Lenz, and Raquel Urtasun. _Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite_. CVPR 2012.
|
| 27 |
+
|
| 28 |
+
## Dataset Structure
|
| 29 |
+
|
| 30 |
+
The dataset is organized into the following folders, each representing a specific modality or annotation:
|
| 31 |
+
|
| 32 |
+
| Folder | Description |
|
| 33 |
+
|--------|-------------|
|
| 34 |
+
| `image_0/` | Grayscale images from the **left camera** at two timepoints. `<id>_10.png` is the reference frame (t0), `<id>_11.png` is the subsequent frame (t1). |
|
| 35 |
+
| `image_1/` | Grayscale images from the **right camera**, same timestamps as `image_0/`. |
|
| 36 |
+
| `colored_0/` | Color images from the **left camera** at t0 and t1. |
|
| 37 |
+
| `colored_1/` | Color images from the **right camera**. |
|
| 38 |
+
| `disp_noc/` | Disparity maps at t0 for **non-occluded** pixels. |
|
| 39 |
+
| `disp_occ/` | Disparity maps at t0 for **all pixels**, including occlusions. |
|
| 40 |
+
| `disp_refl_noc/` | Disparity maps for **reflective surfaces**, non-occluded only. |
|
| 41 |
+
| `disp_refl_occ/` | Disparity maps for **reflective surfaces**, including occluded regions. |
|
| 42 |
+
| `flow_noc/` | Sparse ground-truth optical flow maps for **non-occluded** pixels between t0 and t1. |
|
| 43 |
+
| `flow_occ/` | Sparse ground-truth optical flow maps including **occluded** regions. |
|
| 44 |
+
| `calib/` | Calibration files for each sample. Contains projection matrices: `P0` (left grayscale), `P1` (right grayscale), `P2` (left color), `P3` (right color). |
|
| 45 |
+
|
| 46 |
+
### Notes on Filenames:
|
| 47 |
+
- `<id>_10.png` = timepoint **t0** (reference frame)
|
| 48 |
+
- `<id>_11.png` = timepoint **t1** (subsequent frame)
|
| 49 |
+
- `<id>.txt` in `calib/` contains the camera projection matrices (3×4) used for reconstruction.
|
| 50 |
+
- Testing split does not include ground truth.
|
| 51 |
+
|
| 52 |
+
## Example Usage
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from datasets import load_dataset
|
| 56 |
+
|
| 57 |
+
# Load the dataset (replace 'your-namespace' with your Hugging Face namespace)
|
| 58 |
+
dataset = load_dataset("randall-lab/kitti-flow2012", split="train", trust_remote_code=True)
|
| 59 |
+
|
| 60 |
+
example = dataset[0]
|
| 61 |
+
|
| 62 |
+
# Grayscale Images (left and right)
|
| 63 |
+
left_gray_t0 = example["ImageGray_left"][0] # Image at t0 from left gray camera
|
| 64 |
+
left_gray_t1 = example["ImageGray_left"][1] # Image at t1 from left gray camera
|
| 65 |
+
right_gray_t0 = example["ImageGray_right"][0]
|
| 66 |
+
right_gray_t1 = example["ImageGray_right"][1]
|
| 67 |
+
|
| 68 |
+
# Color Images
|
| 69 |
+
left_color_t0 = example["ImageColor_left"][0]
|
| 70 |
+
left_color_t1 = example["ImageColor_left"][1]
|
| 71 |
+
right_color_t0 = example["ImageColor_right"][0]
|
| 72 |
+
right_color_t1 = example["ImageColor_right"][1]
|
| 73 |
+
|
| 74 |
+
# Ground Truth (only for training split)
|
| 75 |
+
flow_noc = example["flow_noc"] # non-occluded flow map
|
| 76 |
+
flow_occ = example["flow_occ"] # all-pixels flow map
|
| 77 |
+
|
| 78 |
+
# GT for disparity map Uncomment it if needed
|
| 79 |
+
# disp_noc = example["disp_noc"] # disparity map
|
| 80 |
+
# disp_occ = example["disp_occ"]
|
| 81 |
+
# disp_refl_noc = example["disp_refl_noc"]
|
| 82 |
+
# disp_refl_occ = example["disp_refl_occ"]
|
| 83 |
+
|
| 84 |
+
# Calibration
|
| 85 |
+
P0 = example["calib"]["P0"] # Left grayscale camera
|
| 86 |
+
P1 = example["calib"]["P1"] # Right grayscale camera
|
| 87 |
+
P2 = example["calib"]["P2"] # Left color camera
|
| 88 |
+
P3 = example["calib"]["P3"] # Right color camera
|
| 89 |
+
|
| 90 |
+
# Show example
|
| 91 |
+
left_gray_t0.show()
|
| 92 |
+
flow_noc.show()
|
| 93 |
+
print(f"Calibration matrix P0 (left gray camera): {P0}")
|
| 94 |
+
```
|
| 95 |
+
If you are using colab, you should update datasets to avoid errors
|
| 96 |
+
```
|
| 97 |
+
pip install -U datasets
|
| 98 |
+
```
|
| 99 |
+
### Citation
|
| 100 |
+
```
|
| 101 |
+
@inproceedings{Geiger2012CVPR,
|
| 102 |
+
author = {Andreas Geiger and Philip Lenz and Raquel Urtasun},
|
| 103 |
+
title = {Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite},
|
| 104 |
+
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
|
| 105 |
+
year = {2012}
|
| 106 |
+
}
|
| 107 |
+
```
|
header_flow.jpg
ADDED
|
Git LFS Details
|
kitti-flow2012.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
import os
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
_KITTI2012_URL = "https://s3.eu-central-1.amazonaws.com/avg-kitti/data_stereo_flow.zip"
|
| 6 |
+
|
| 7 |
+
class KITTIFLow2012(datasets.GeneratorBasedBuilder):
|
| 8 |
+
"""KITTI Flow 2012 dataset with grayscale/color image sequences, optical flow ground truth, and calibration."""
|
| 9 |
+
|
| 10 |
+
VERSION = datasets.Version("1.0.0")
|
| 11 |
+
|
| 12 |
+
def _info(self):
|
| 13 |
+
return datasets.DatasetInfo(
|
| 14 |
+
description=(
|
| 15 |
+
"KITTI Flow 2012 dataset: contains grayscale and color stereo image sequences "
|
| 16 |
+
"captured at two consecutive timepoints, along with sparse optical flow ground truth and calibration files. "
|
| 17 |
+
"This dataset is widely used for benchmarking optical flow estimation methods in realistic driving scenarios."
|
| 18 |
+
),
|
| 19 |
+
features=datasets.Features(
|
| 20 |
+
{
|
| 21 |
+
"ImageGray_left": datasets.Sequence(datasets.Image()),
|
| 22 |
+
"ImageGray_right": datasets.Sequence(datasets.Image()),
|
| 23 |
+
"ImageColor_left": datasets.Sequence(datasets.Image()),
|
| 24 |
+
"ImageColor_right": datasets.Sequence(datasets.Image()),
|
| 25 |
+
"calib": {
|
| 26 |
+
"P0": datasets.Sequence(datasets.Value("float32")),
|
| 27 |
+
"P1": datasets.Sequence(datasets.Value("float32")),
|
| 28 |
+
"P2": datasets.Sequence(datasets.Value("float32")),
|
| 29 |
+
"P3": datasets.Sequence(datasets.Value("float32")),
|
| 30 |
+
},
|
| 31 |
+
"disp_noc": datasets.Image(),
|
| 32 |
+
"disp_occ": datasets.Image(),
|
| 33 |
+
"disp_refl_noc": datasets.Image(),
|
| 34 |
+
"disp_refl_occ": datasets.Image(),
|
| 35 |
+
"flow_noc": datasets.Image(),
|
| 36 |
+
"flow_occ": datasets.Image(),
|
| 37 |
+
}
|
| 38 |
+
),
|
| 39 |
+
homepage="http://www.cvlibs.net/datasets/kitti/eval_stereo_flow.php?benchmark=flow",
|
| 40 |
+
license="CC BY-NC-SA 3.0",
|
| 41 |
+
citation="""@inproceedings{Geiger2012CVPR,
|
| 42 |
+
author = {Andreas Geiger and Philip Lenz and Raquel Urtasun},
|
| 43 |
+
title = {Are we ready for Autonomous Driving? The KITTI Vision Benchmark Suite},
|
| 44 |
+
booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)},
|
| 45 |
+
year = {2012}
|
| 46 |
+
}""",
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
def _split_generators(self, dl_manager):
|
| 50 |
+
archive_path = dl_manager.download_and_extract(_KITTI2012_URL)
|
| 51 |
+
train_path = os.path.join(archive_path, "training")
|
| 52 |
+
test_path = os.path.join(archive_path, "testing")
|
| 53 |
+
return [
|
| 54 |
+
datasets.SplitGenerator(
|
| 55 |
+
name=datasets.Split.TRAIN,
|
| 56 |
+
gen_kwargs={"base_path": train_path, "split": "training"},
|
| 57 |
+
),
|
| 58 |
+
datasets.SplitGenerator(
|
| 59 |
+
name=datasets.Split.TEST,
|
| 60 |
+
gen_kwargs={"base_path": test_path, "split": "testing"},
|
| 61 |
+
),
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
def _generate_examples(self, base_path, split):
|
| 65 |
+
image_0_path = os.path.join(base_path, "image_0")
|
| 66 |
+
image_1_path = os.path.join(base_path, "image_1")
|
| 67 |
+
color_0_path = os.path.join(base_path, "colored_0")
|
| 68 |
+
color_1_path = os.path.join(base_path, "colored_1")
|
| 69 |
+
calib_path = os.path.join(base_path, "calib")
|
| 70 |
+
|
| 71 |
+
if split == "training":
|
| 72 |
+
disp_path = os.path.join(base_path, "disp_noc")
|
| 73 |
+
disp_path_occ = os.path.join(base_path, "disp_occ")
|
| 74 |
+
disp_path_refl_noc = os.path.join(base_path, "disp_refl_noc")
|
| 75 |
+
disp_path_refl_occ = os.path.join(base_path, "disp_refl_occ")
|
| 76 |
+
flow_noc_path = os.path.join(base_path, "flow_noc")
|
| 77 |
+
flow_occ_path = os.path.join(base_path, "flow_occ")
|
| 78 |
+
|
| 79 |
+
files = sorted(os.listdir(image_0_path))
|
| 80 |
+
ids = sorted(set(f.split("_")[0] for f in files))
|
| 81 |
+
|
| 82 |
+
for id_ in ids:
|
| 83 |
+
example = {
|
| 84 |
+
"ImageGray_left": [
|
| 85 |
+
Image.open(os.path.join(image_0_path, f"{id_}_10.png")),
|
| 86 |
+
Image.open(os.path.join(image_0_path, f"{id_}_11.png")),
|
| 87 |
+
],
|
| 88 |
+
"ImageGray_right": [
|
| 89 |
+
Image.open(os.path.join(image_1_path, f"{id_}_10.png")),
|
| 90 |
+
Image.open(os.path.join(image_1_path, f"{id_}_11.png")),
|
| 91 |
+
],
|
| 92 |
+
"ImageColor_left": [
|
| 93 |
+
Image.open(os.path.join(color_0_path, f"{id_}_10.png")),
|
| 94 |
+
Image.open(os.path.join(color_0_path, f"{id_}_11.png")),
|
| 95 |
+
],
|
| 96 |
+
"ImageColor_right": [
|
| 97 |
+
Image.open(os.path.join(color_1_path, f"{id_}_10.png")),
|
| 98 |
+
Image.open(os.path.join(color_1_path, f"{id_}_11.png")),
|
| 99 |
+
],
|
| 100 |
+
"calib": {"P0": [], "P1": [], "P2": [], "P3": []},
|
| 101 |
+
"disp_noc": Image.open(os.path.join(disp_path, f"{id_}_10.png")) if split == "training" else None,
|
| 102 |
+
"disp_occ": Image.open(os.path.join(disp_path_occ, f"{id_}_10.png")) if split == "training" else None,
|
| 103 |
+
"disp_refl_noc": Image.open(os.path.join(disp_path_refl_noc, f"{id_}_10.png")) if split == "training" else None,
|
| 104 |
+
"disp_refl_occ": Image.open(os.path.join(disp_path_refl_occ, f"{id_}_10.png")) if split == "training" else None,
|
| 105 |
+
"flow_noc": Image.open(os.path.join(flow_noc_path, f"{id_}_10.png")) if split == "training" else None,
|
| 106 |
+
"flow_occ": Image.open(os.path.join(flow_occ_path, f"{id_}_10.png")) if split == "training" else None,
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
calib_file = os.path.join(calib_path, f"{id_}.txt")
|
| 110 |
+
with open(calib_file, "r") as f:
|
| 111 |
+
lines = f.readlines()
|
| 112 |
+
for line in lines:
|
| 113 |
+
key, value = line.strip().split(":", 1)
|
| 114 |
+
if key in ["P0", "P1", "P2", "P3"]:
|
| 115 |
+
example["calib"][key] = [float(x) for x in value.strip().split()]
|
| 116 |
+
|
| 117 |
+
yield id_, example
|