pub struct CocoIndex {
pub images: HashMap<u64, CocoImage>,
pub categories: HashMap<u32, CocoCategory>,
pub label_indices: HashMap<u32, u64>,
pub annotations_by_image: HashMap<u64, Vec<CocoAnnotation>>,
}Expand description
Lookup tables for efficient COCO data access.
Builds indexes from a CocoDataset for O(1) lookups.
Fields§
§images: HashMap<u64, CocoImage>image_id → CocoImage
categories: HashMap<u32, CocoCategory>category_id → CocoCategory
label_indices: HashMap<u32, u64>category_id → label_index (0-based, alphabetical order by name)
annotations_by_image: HashMap<u64, Vec<CocoAnnotation>>image_id → Vec<CocoAnnotation>
Implementations§
Source§impl CocoIndex
impl CocoIndex
Sourcepub fn from_dataset(dataset: &CocoDataset) -> Self
pub fn from_dataset(dataset: &CocoDataset) -> Self
Build lookup index from a CocoDataset.
Creates efficient lookup tables for accessing images, categories, and annotations by their IDs.
Sourcepub fn label_name(&self, category_id: u32) -> Option<&str>
pub fn label_name(&self, category_id: u32) -> Option<&str>
Get the label name for a category ID.
Sourcepub fn label_index(&self, category_id: u32) -> Option<u64>
pub fn label_index(&self, category_id: u32) -> Option<u64>
Get the label index for a category ID.
Sourcepub fn annotations_for_image(&self, image_id: u64) -> &[CocoAnnotation]
pub fn annotations_for_image(&self, image_id: u64) -> &[CocoAnnotation]
Get annotations for an image.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CocoIndex
impl RefUnwindSafe for CocoIndex
impl Send for CocoIndex
impl Sync for CocoIndex
impl Unpin for CocoIndex
impl UnwindSafe for CocoIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more