Expand description
§COCO Dataset Format Support
This module provides comprehensive support for the COCO (Common Objects in Context) dataset format, enabling bidirectional conversion between COCO and EdgeFirst formats.
§Supported Workflows
- COCO → EdgeFirst Arrow: Convert COCO JSON/ZIP to Arrow-based EdgeFirst format
- EdgeFirst Arrow → COCO: Convert Arrow format back to COCO JSON
- COCO → Studio: Import COCO directly into EdgeFirst Studio via API
- Studio → COCO: Export Studio dataset to COCO format
§Scope
Phase 1 supports:
- Bounding boxes (box2d)
- Polygon segmentation (mask)
- RLE segmentation (decoded to polygons)
Not yet supported: keypoints, captions, panoptic segmentation.
§Example
use edgefirst_client::coco::{CocoReader, CocoToArrowOptions, coco_to_arrow};
// Read COCO annotations
let reader = CocoReader::new();
let dataset = reader.read_json("annotations/instances_val2017.json")?;
println!(
"Found {} images and {} annotations",
dataset.images.len(),
dataset.annotations.len()
);
// Convert to EdgeFirst Arrow format
let options = CocoToArrowOptions::default();
let count = coco_to_arrow(
"annotations/instances_val2017.json",
"dataset.arrow",
&options,
None,
)
.await?;
println!("Converted {} samples", count);Re-exports§
pub use studio::CocoExportOptions;pub use studio::CocoImportOptions;pub use studio::CocoImportResult;pub use studio::CocoUpdateOptions;pub use studio::CocoUpdateResult;pub use studio::CocoVerifyOptions;pub use studio::export_studio_to_coco;pub use studio::import_coco_to_studio;pub use studio::update_coco_annotations;pub use studio::verify_coco_import;pub use verify::BboxValidationResult;pub use verify::CategoryValidationResult;pub use verify::MaskValidationResult;pub use verify::VerificationResult;
Modules§
Structs§
- Arrow
ToCoco Options - Options for Arrow to COCO conversion.
- Coco
Annotation - Annotation for object detection and instance segmentation.
- Coco
Category - Category definition.
- Coco
Compressed Rle - Compressed RLE segmentation (LEB128 encoded).
- Coco
Dataset - Top-level COCO dataset structure.
- Coco
Image - Image metadata.
- Coco
Index - Lookup tables for efficient COCO data access.
- Coco
Info - Dataset metadata.
- Coco
License - License information.
- Coco
Read Options - Options for COCO reading.
- Coco
Reader - Streaming COCO reader for large datasets.
- CocoRle
- Uncompressed RLE (Run-Length Encoding) segmentation.
- Coco
ToArrow Options - Options for COCO to Arrow conversion.
- Coco
Write Options - Options for COCO writing.
- Coco
Writer - COCO writer for generating JSON and ZIP files.
Enums§
- Coco
Segmentation - Segmentation format: polygon array or RLE.
Functions§
- arrow_
to_ coco - Convert EdgeFirst Arrow format to COCO annotations.
- box2d_
to_ coco_ bbox - Convert EdgeFirst
Box2dto COCO bbox[x, y, w, h](top-left, pixels). - calculate_
coco_ area - Calculate area from COCO segmentation (in pixels²).
- coco_
bbox_ to_ box2d - Convert COCO bbox
[x, y, w, h](top-left, pixels) to EdgeFirstBox2d(top-left, normalized). - coco_
polygon_ to_ mask - Convert COCO polygon segmentation to EdgeFirst
Maskformat. - coco_
rle_ to_ mask - Convert RLE segmentation to EdgeFirst
Mask. - coco_
segmentation_ to_ mask - Convert any COCO segmentation to EdgeFirst
Mask. - coco_
to_ arrow - Convert COCO annotations to EdgeFirst Arrow format.
- decode_
compressed_ rle - Decode compressed RLE (LEB128) to binary mask.
- decode_
rle - Decode uncompressed RLE to binary mask.
- infer_
group_ from_ filename - Infer group name from COCO annotation filename.
- infer_
group_ from_ folder - Infer the group name from an image folder path.
- mask_
to_ coco_ polygon - Convert EdgeFirst
Maskformat to COCO polygon segmentation. - mask_
to_ contours - Convert binary mask to polygon contours.
- read_
coco_ directory - Read all COCO annotation files from a directory.
- validate_
coco_ bbox - Validate that a COCO bounding box is within image bounds.