Datasets:
Commit ·
d9596c0
0
Parent(s):
Straw6D: plant-disjoint split (train/validation/test), rgb+metadata.jsonl per split
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +61 -0
- README.md +149 -0
- scripts/visualization.py +146 -0
- test/metadata.jsonl +0 -0
- test/plant_000/000.png +3 -0
- test/plant_000/001.png +3 -0
- test/plant_000/002.png +3 -0
- test/plant_000/003.png +3 -0
- test/plant_000/004.png +3 -0
- test/plant_000/005.png +3 -0
- test/plant_000/006.png +3 -0
- test/plant_000/007.png +3 -0
- test/plant_000/008.png +3 -0
- test/plant_000/009.png +3 -0
- test/plant_000/010.png +3 -0
- test/plant_000/011.png +3 -0
- test/plant_000/012.png +3 -0
- test/plant_000/013.png +3 -0
- test/plant_000/014.png +3 -0
- test/plant_000/015.png +3 -0
- test/plant_000/016.png +3 -0
- test/plant_000/017.png +3 -0
- test/plant_000/018.png +3 -0
- test/plant_000/019.png +3 -0
- test/plant_000/020.png +3 -0
- test/plant_000/021.png +3 -0
- test/plant_000/022.png +3 -0
- test/plant_000/023.png +3 -0
- test/plant_000/024.png +3 -0
- test/plant_000/025.png +3 -0
- test/plant_000/026.png +3 -0
- test/plant_000/027.png +3 -0
- test/plant_000/028.png +3 -0
- test/plant_000/029.png +3 -0
- test/plant_000/030.png +3 -0
- test/plant_000/031.png +3 -0
- test/plant_000/032.png +3 -0
- test/plant_000/033.png +3 -0
- test/plant_000/034.png +3 -0
- test/plant_000/035.png +3 -0
- test/plant_000/036.png +3 -0
- test/plant_000/037.png +3 -0
- test/plant_000/038.png +3 -0
- test/plant_000/039.png +3 -0
- test/plant_000/040.png +3 -0
- test/plant_000/041.png +3 -0
- test/plant_000/042.png +3 -0
- test/plant_000/043.png +3 -0
- test/plant_000/044.png +3 -0
- test/plant_000/045.png +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.avro filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
# Audio files - uncompressed
|
| 40 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
# Audio files - compressed
|
| 44 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
# Image files - uncompressed
|
| 50 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
# Image files - compressed
|
| 55 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
# Video files - compressed
|
| 59 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
train/metadata.jsonl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
configs:
|
| 4 |
+
- config_name: default
|
| 5 |
+
data_files:
|
| 6 |
+
- split: train
|
| 7 |
+
path: data/train-*
|
| 8 |
+
dataset_info:
|
| 9 |
+
features:
|
| 10 |
+
- name: image_id
|
| 11 |
+
dtype: string
|
| 12 |
+
- name: image
|
| 13 |
+
dtype: image
|
| 14 |
+
- name: resolution
|
| 15 |
+
list: int32
|
| 16 |
+
- name: fx
|
| 17 |
+
dtype: float64
|
| 18 |
+
- name: fy
|
| 19 |
+
dtype: float64
|
| 20 |
+
- name: cx
|
| 21 |
+
dtype: float64
|
| 22 |
+
- name: cy
|
| 23 |
+
dtype: float64
|
| 24 |
+
- name: camera_view_matrix
|
| 25 |
+
list:
|
| 26 |
+
list: float64
|
| 27 |
+
- name: camera_projection_matrix
|
| 28 |
+
list:
|
| 29 |
+
list: float64
|
| 30 |
+
- name: labels
|
| 31 |
+
list: string
|
| 32 |
+
- name: bbox_2d_loose
|
| 33 |
+
list:
|
| 34 |
+
list: float64
|
| 35 |
+
- name: size_local
|
| 36 |
+
list:
|
| 37 |
+
list: float64
|
| 38 |
+
- name: center_local
|
| 39 |
+
list:
|
| 40 |
+
list: float64
|
| 41 |
+
- name: local_to_world_transform
|
| 42 |
+
list:
|
| 43 |
+
list:
|
| 44 |
+
list: float64
|
| 45 |
+
splits:
|
| 46 |
+
- name: train
|
| 47 |
+
num_bytes: 5647010348
|
| 48 |
+
num_examples: 12040
|
| 49 |
+
download_size: 5485176011
|
| 50 |
+
dataset_size: 5647010348
|
| 51 |
+
task_categories:
|
| 52 |
+
- object-detection
|
| 53 |
+
tags:
|
| 54 |
+
- robotics
|
| 55 |
+
- 6d-pose-estimation
|
| 56 |
+
- agriculture
|
| 57 |
+
- strawberry
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
# Straw6D: In-Field 6D Pose Dataset for Robotic Strawberry Harvesting
|
| 61 |
+
|
| 62 |
+
This dataset accompanies the paper:
|
| 63 |
+
|
| 64 |
+
> **From Simulation to the Real-World: An In-Field 6D Pose Dataset and Baseline for Robotic Strawberry Harvesting**
|
| 65 |
+
> Woojung Son, Won Suk Lee, Zijing Huang, Daeun Choi, Catia Silva, Yu She, Yan Gu
|
| 66 |
+
> University of Florida & Purdue University
|
| 67 |
+
> [[arXiv]](https://arxiv.org/abs/2606.11381)
|
| 68 |
+
|
| 69 |
+
## Overview
|
| 70 |
+
|
| 71 |
+
To the best of our knowledge, Straw6D is the **first real-world 6D pose ground truth dataset of strawberries collected in actual agricultural fields**. Collecting 6D pose ground truth in real agricultural environments is inherently challenging; prior work has largely relied on synthetic data with limited realism. This dataset bridges that gap by providing per-frame 6D pose annotations paired with RGB images captured directly in the field.
|
| 72 |
+
|
| 73 |
+
- **12,040** RGB images with **16,037** annotated strawberry instances
|
| 74 |
+
- **Single category**: `strawberry` (red-stage / ripe only)
|
| 75 |
+
- Recorded using an Intel RealSense D435i camera
|
| 76 |
+
|
| 77 |
+
## Annotation Pipeline
|
| 78 |
+
|
| 79 |
+
Ground truth 6D poses were obtained through a multi-step process:
|
| 80 |
+
1. Checkerboard-based camera calibration (PnP algorithm)
|
| 81 |
+
2. Metric-scale 3D reconstruction via COLMAP
|
| 82 |
+
3. Manual 3D bounding box annotation on reconstructed point clouds
|
| 83 |
+
4. 6D pose derived from camera-to-world and local-to-world transformations
|
| 84 |
+
|
| 85 |
+
## Dataset Structure
|
| 86 |
+
|
| 87 |
+
Each sample provides image, per-frame camera parameters, and per-object pose annotations.
|
| 88 |
+
|
| 89 |
+
**Camera fields** (per frame):
|
| 90 |
+
|
| 91 |
+
| Field | Description |
|
| 92 |
+
|---|---|
|
| 93 |
+
| `image_id` | Zero-padded frame index (e.g. `000042`) |
|
| 94 |
+
| `image` | RGB image |
|
| 95 |
+
| `resolution` | [width, height] in pixels |
|
| 96 |
+
| `fx`, `fy`, `cx`, `cy` | Camera intrinsics in pixels |
|
| 97 |
+
| `camera_view_matrix` | 4×4 world-to-camera transform |
|
| 98 |
+
| `camera_projection_matrix` | 4×4 OpenGL projection matrix |
|
| 99 |
+
|
| 100 |
+
**Object fields** (list, one entry per object in the frame):
|
| 101 |
+
|
| 102 |
+
| Field | Description |
|
| 103 |
+
|---|---|
|
| 104 |
+
| `labels` | Category label (`"strawberry"`) |
|
| 105 |
+
| `bbox_2d_loose` | 2D bounding box [x_min, y_min, x_max, y_max] in pixels |
|
| 106 |
+
| `size_local` | Object size [x, y, z] in meters |
|
| 107 |
+
| `center_local` | Object center in local space |
|
| 108 |
+
| `local_to_world_transform` | 4×4 object-local-to-world transform |
|
| 109 |
+
|
| 110 |
+
All 4×4 matrices are **row-major**: `p_out = p_in @ M`.
|
| 111 |
+
|
| 112 |
+
## Usage
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from datasets import load_dataset
|
| 116 |
+
|
| 117 |
+
ds = load_dataset("WoojungSon/Straw6D")
|
| 118 |
+
sample = ds["train"][0]
|
| 119 |
+
|
| 120 |
+
print(sample["image_id"]) # "000000"
|
| 121 |
+
print(sample["labels"]) # ["strawberry"]
|
| 122 |
+
sample["image"] # PIL Image
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
## Visualization
|
| 126 |
+
|
| 127 |
+
A visualization script is provided in `scripts/visualization.py`. It projects the 6D pose axes onto the RGB image:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
python scripts/visualization.py \
|
| 131 |
+
--image path/to/rgb/000000.png \
|
| 132 |
+
--json path/to/json/000000.json \
|
| 133 |
+
--output output.png
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
## Citation
|
| 137 |
+
|
| 138 |
+
```bibtex
|
| 139 |
+
@article{son2025straw6d,
|
| 140 |
+
title={From Simulation to the Real-World: An In-Field 6D Pose Dataset and Baseline for Robotic Strawberry Harvesting},
|
| 141 |
+
author={Son, Woojung and Lee, Won Suk and Huang, Zijing and Choi, Daeun and Silva, Catia and She, Yu and Gu, Yan},
|
| 142 |
+
journal={arXiv preprint arXiv:2606.11381},
|
| 143 |
+
year={2025}
|
| 144 |
+
}
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
## License
|
| 148 |
+
|
| 149 |
+
This dataset is released under the [Creative Commons Attribution 4.0 International (CC BY 4.0)](https://creativecommons.org/licenses/by/4.0/) license.
|
scripts/visualization.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Visualize 6D pose annotations by projecting local frame axes onto RGB images.
|
| 3 |
+
|
| 4 |
+
Coordinate conventions
|
| 5 |
+
----------------------
|
| 6 |
+
- All matrices are **row-major** (Isaac Sim / USD convention).
|
| 7 |
+
Transforms are applied as: p_out = p_in @ M (row vector on the left)
|
| 8 |
+
|
| 9 |
+
- World / object space uses a **right-handed, Y-up** frame (OpenGL convention).
|
| 10 |
+
+X : right
|
| 11 |
+
+Y : up
|
| 12 |
+
-Z : into the scene (camera looks toward -Z in camera space)
|
| 13 |
+
|
| 14 |
+
- Camera space also follows **OpenGL**:
|
| 15 |
+
+X : right, +Y : up, -Z : into the scene
|
| 16 |
+
|
| 17 |
+
- Screen space follows **OpenCV / image** convention:
|
| 18 |
+
+u : right, +v : down, origin at top-left
|
| 19 |
+
|
| 20 |
+
Conversion from OpenGL camera space → OpenCV screen space:
|
| 21 |
+
x_cv = x_gl
|
| 22 |
+
y_cv = -y_gl (flip Y)
|
| 23 |
+
z_cv = -z_gl (flip Z; positive depth is in front)
|
| 24 |
+
|
| 25 |
+
Matrix fields in the JSON
|
| 26 |
+
--------------------------
|
| 27 |
+
- camera_view_matrix (4x4, row-major) : world → camera
|
| 28 |
+
- local_to_world_transform (4x4, row-major) : object-local → world
|
| 29 |
+
- intrinsics : {fx, fy, cx, cy} in pixels
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
import json
|
| 33 |
+
import numpy as np
|
| 34 |
+
from PIL import Image, ImageDraw
|
| 35 |
+
import argparse
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def project_world_point_to_screen(world_point, view_matrix, intrinsics):
|
| 39 |
+
"""Project a homogeneous world-space point to pixel coordinates.
|
| 40 |
+
|
| 41 |
+
Uses row-major convention: cam = world_point @ view_matrix.
|
| 42 |
+
Converts OpenGL camera space (y-up, -z forward) to OpenCV screen space (y-down, +z forward).
|
| 43 |
+
Returns None if the point is behind the camera (z_cv <= 0).
|
| 44 |
+
"""
|
| 45 |
+
p = np.array([*world_point[:3], 1.0]) if len(world_point) == 3 else np.array(world_point)
|
| 46 |
+
cam = p @ view_matrix # row-major: point on the left
|
| 47 |
+
x, y, z = cam[0], -cam[1], -cam[2] # OpenGL → OpenCV axis flip
|
| 48 |
+
if z <= 0:
|
| 49 |
+
return None
|
| 50 |
+
u = intrinsics['fx'] * x / z + intrinsics['cx']
|
| 51 |
+
v = intrinsics['fy'] * y / z + intrinsics['cy']
|
| 52 |
+
return round(u), round(v)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def draw_local_frame_axes(draw, local_to_world_transform, camera_view_matrix, intrinsics, size_local, origin_local, axes_length_perc=1.5):
|
| 56 |
+
"""Draw X/Y/Z axes of the object's local frame onto the image.
|
| 57 |
+
|
| 58 |
+
Axis length is scaled by the mean object size * axes_length_perc.
|
| 59 |
+
Pipeline: local → world (@ L), world → screen (project_world_point_to_screen).
|
| 60 |
+
"""
|
| 61 |
+
L = np.array(local_to_world_transform) # row-major local→world (4x4)
|
| 62 |
+
V = np.array(camera_view_matrix) # row-major world→camera (4x4)
|
| 63 |
+
ax_len = np.mean(size_local) * axes_length_perc
|
| 64 |
+
ox, oy, oz = origin_local
|
| 65 |
+
|
| 66 |
+
points_local = {
|
| 67 |
+
'origin': [ox, oy, oz, 1],
|
| 68 |
+
'x': [ox + ax_len, oy, oz, 1],
|
| 69 |
+
'y': [ox, oy + ax_len, oz, 1],
|
| 70 |
+
'z': [ox, oy, oz + ax_len, 1],
|
| 71 |
+
}
|
| 72 |
+
pts2d = {k: project_world_point_to_screen(np.array(v) @ L, V, intrinsics)
|
| 73 |
+
for k, v in points_local.items()}
|
| 74 |
+
|
| 75 |
+
o = pts2d['origin']
|
| 76 |
+
for key, color in [('x', 'red'), ('y', 'green'), ('z', 'blue')]:
|
| 77 |
+
if o is not None and pts2d[key] is not None:
|
| 78 |
+
draw.line([o, pts2d[key]], fill=color, width=5)
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def draw_world_frame_axes_bottom_left(draw, camera_view_matrix, intrinsics, screen_size, axes_scale=0.1, margin_percentage=0.05):
|
| 82 |
+
"""Draw world-frame X/Y/Z axes in the bottom-left corner as a reference gizmo.
|
| 83 |
+
|
| 84 |
+
Places a virtual origin 1 unit in front of the camera (OpenGL: z=-1 in camera space),
|
| 85 |
+
converts it to world space via the inverse view matrix, then re-projects to screen.
|
| 86 |
+
The axes are offset so they appear anchored to the bottom-left corner.
|
| 87 |
+
"""
|
| 88 |
+
V = np.array(camera_view_matrix)
|
| 89 |
+
V_inv = np.linalg.inv(V)
|
| 90 |
+
# z=-1 in OpenGL camera space = 1 unit in front of the camera
|
| 91 |
+
origin_world = np.array([0, 0, -1.0, 1]) @ V_inv # camera → world
|
| 92 |
+
|
| 93 |
+
pts2d = {}
|
| 94 |
+
pts2d['origin'] = project_world_point_to_screen(origin_world, V, intrinsics)
|
| 95 |
+
for key, delta in [('x', [axes_scale, 0, 0, 0]), ('y', [0, axes_scale, 0, 0]), ('z', [0, 0, axes_scale, 0])]:
|
| 96 |
+
pts2d[key] = project_world_point_to_screen(origin_world + np.array(delta), V, intrinsics)
|
| 97 |
+
|
| 98 |
+
if any(v is None for v in pts2d.values()):
|
| 99 |
+
return
|
| 100 |
+
|
| 101 |
+
# Shift projected axes to bottom-left corner
|
| 102 |
+
margin = int(margin_percentage * min(screen_size))
|
| 103 |
+
all_x = [pts2d[k][0] for k in pts2d]
|
| 104 |
+
all_y = [pts2d[k][1] for k in pts2d]
|
| 105 |
+
ox = margin - min(all_x)
|
| 106 |
+
oy = screen_size[1] - margin - max(all_y)
|
| 107 |
+
|
| 108 |
+
o = (pts2d['origin'][0] + ox, pts2d['origin'][1] + oy)
|
| 109 |
+
for key, color in [('x', 'red'), ('y', 'green'), ('z', 'blue')]:
|
| 110 |
+
end = (pts2d[key][0] + ox, pts2d[key][1] + oy)
|
| 111 |
+
draw.line([o, end], fill=color, width=3)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def main(image_path, json_path, output_path):
|
| 115 |
+
rgb_img = Image.open(image_path)
|
| 116 |
+
draw = ImageDraw.Draw(rgb_img)
|
| 117 |
+
|
| 118 |
+
with open(json_path, 'r') as f:
|
| 119 |
+
data = json.load(f)
|
| 120 |
+
|
| 121 |
+
camera_data = data["camera_data"]
|
| 122 |
+
V = camera_data["camera_view_matrix"] # row-major world→camera (4x4)
|
| 123 |
+
intrinsics = camera_data["intrinsics"] # {fx, fy, cx, cy} in pixels
|
| 124 |
+
screen_size = tuple(camera_data["resolution"]) # (width, height)
|
| 125 |
+
|
| 126 |
+
for obj in data["objects"]:
|
| 127 |
+
b = obj["bbox_3d_local"]
|
| 128 |
+
size_local = [b["x_max"] - b["x_min"], b["y_max"] - b["y_min"], b["z_max"] - b["z_min"]]
|
| 129 |
+
center_local = [(b["x_min"] + b["x_max"]) / 2, (b["y_min"] + b["y_max"]) / 2, (b["z_min"] + b["z_max"]) / 2]
|
| 130 |
+
|
| 131 |
+
draw_local_frame_axes(draw, obj["local_to_world_transform"], V, intrinsics, size_local, center_local)
|
| 132 |
+
|
| 133 |
+
draw_world_frame_axes_bottom_left(draw, V, intrinsics, screen_size)
|
| 134 |
+
|
| 135 |
+
rgb_img.save(output_path)
|
| 136 |
+
print(f"Overlay image saved to: {output_path}")
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
if __name__ == "__main__":
|
| 140 |
+
parser = argparse.ArgumentParser()
|
| 141 |
+
parser.add_argument("--image", type=str, required=True)
|
| 142 |
+
parser.add_argument("--json", type=str, required=True)
|
| 143 |
+
parser.add_argument("--output", type=str, required=True)
|
| 144 |
+
args = parser.parse_args()
|
| 145 |
+
|
| 146 |
+
main(args.image, args.json, args.output)
|
test/metadata.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
test/plant_000/000.png
ADDED
|
Git LFS Details
|
test/plant_000/001.png
ADDED
|
Git LFS Details
|
test/plant_000/002.png
ADDED
|
Git LFS Details
|
test/plant_000/003.png
ADDED
|
Git LFS Details
|
test/plant_000/004.png
ADDED
|
Git LFS Details
|
test/plant_000/005.png
ADDED
|
Git LFS Details
|
test/plant_000/006.png
ADDED
|
Git LFS Details
|
test/plant_000/007.png
ADDED
|
Git LFS Details
|
test/plant_000/008.png
ADDED
|
Git LFS Details
|
test/plant_000/009.png
ADDED
|
Git LFS Details
|
test/plant_000/010.png
ADDED
|
Git LFS Details
|
test/plant_000/011.png
ADDED
|
Git LFS Details
|
test/plant_000/012.png
ADDED
|
Git LFS Details
|
test/plant_000/013.png
ADDED
|
Git LFS Details
|
test/plant_000/014.png
ADDED
|
Git LFS Details
|
test/plant_000/015.png
ADDED
|
Git LFS Details
|
test/plant_000/016.png
ADDED
|
Git LFS Details
|
test/plant_000/017.png
ADDED
|
Git LFS Details
|
test/plant_000/018.png
ADDED
|
Git LFS Details
|
test/plant_000/019.png
ADDED
|
Git LFS Details
|
test/plant_000/020.png
ADDED
|
Git LFS Details
|
test/plant_000/021.png
ADDED
|
Git LFS Details
|
test/plant_000/022.png
ADDED
|
Git LFS Details
|
test/plant_000/023.png
ADDED
|
Git LFS Details
|
test/plant_000/024.png
ADDED
|
Git LFS Details
|
test/plant_000/025.png
ADDED
|
Git LFS Details
|
test/plant_000/026.png
ADDED
|
Git LFS Details
|
test/plant_000/027.png
ADDED
|
Git LFS Details
|
test/plant_000/028.png
ADDED
|
Git LFS Details
|
test/plant_000/029.png
ADDED
|
Git LFS Details
|
test/plant_000/030.png
ADDED
|
Git LFS Details
|
test/plant_000/031.png
ADDED
|
Git LFS Details
|
test/plant_000/032.png
ADDED
|
Git LFS Details
|
test/plant_000/033.png
ADDED
|
Git LFS Details
|
test/plant_000/034.png
ADDED
|
Git LFS Details
|
test/plant_000/035.png
ADDED
|
Git LFS Details
|
test/plant_000/036.png
ADDED
|
Git LFS Details
|
test/plant_000/037.png
ADDED
|
Git LFS Details
|
test/plant_000/038.png
ADDED
|
Git LFS Details
|
test/plant_000/039.png
ADDED
|
Git LFS Details
|
test/plant_000/040.png
ADDED
|
Git LFS Details
|
test/plant_000/041.png
ADDED
|
Git LFS Details
|
test/plant_000/042.png
ADDED
|
Git LFS Details
|
test/plant_000/043.png
ADDED
|
Git LFS Details
|
test/plant_000/044.png
ADDED
|
Git LFS Details
|
test/plant_000/045.png
ADDED
|
Git LFS Details
|