edgefirst-client 2.9.1

EdgeFirst Client Library and CLI
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2025 Au-Zone Technologies. All Rights Reserved.

//! # 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
//!
//! 1. **COCO → EdgeFirst Arrow**: Convert COCO JSON/ZIP to Arrow-based
//!    EdgeFirst format
//! 2. **EdgeFirst Arrow → COCO**: Convert Arrow format back to COCO JSON
//! 3. **COCO → Studio**: Import COCO directly into EdgeFirst Studio via API
//! 4. **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
//!
//! ```rust,no_run
//! use edgefirst_client::coco::{CocoReader, CocoToArrowOptions, coco_to_arrow};
//!
//! # async fn example() -> Result<(), edgefirst_client::Error> {
//! // 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);
//! # Ok(())
//! # }
//! ```

mod convert;
mod reader;
mod types;
pub mod verify;
mod writer;

#[cfg(feature = "polars")]
mod arrow;

#[cfg(feature = "polars")]
pub mod studio;

// Re-export types
pub use types::{
    CocoAnnotation, CocoCategory, CocoCompressedRle, CocoDataset, CocoImage, CocoIndex, CocoInfo,
    CocoLicense, CocoRle, CocoSegmentation,
};

// Re-export readers/writers
pub use reader::{
    CocoReadOptions, CocoReader, infer_group_from_filename, infer_group_from_folder,
    read_coco_directory,
};
pub use writer::{CocoDatasetBuilder, CocoWriteOptions, CocoWriter};

// Re-export conversion functions
pub use convert::{
    box2d_to_coco_bbox, calculate_coco_area, coco_bbox_to_box2d, coco_polygon_to_polygon,
    coco_rle_to_polygon, coco_segmentation_to_mask_data, coco_segmentation_to_polygon,
    decode_compressed_rle, decode_rle, encode_rle, mask_to_contours, polygon_to_coco_polygon,
    rle_to_mask_data, validate_coco_bbox,
};

// Re-export Arrow conversions (feature-gated)
#[cfg(feature = "polars")]
pub use arrow::{
    ArrowToCocoOptions, CocoToArrowOptions, SCHEMA_VERSION, arrow_to_coco, coco_to_arrow,
};

// Re-export Studio integration (feature-gated)
#[cfg(feature = "polars")]
pub use studio::{
    CocoExportOptions, CocoImportOptions, CocoImportResult, CocoUpdateOptions, CocoUpdateResult,
    CocoVerifyOptions, export_studio_to_coco, import_coco_to_studio, update_coco_annotations,
    verify_coco_import,
};

// Re-export verification types
pub use verify::{
    BboxValidationResult, CategoryValidationResult, MaskValidationResult, VerificationResult,
};

#[cfg(test)]
mod tests;