ndsampler.coco_frames
¶
Module Contents¶
Classes¶
wrapper around coco-style dataset to allow for getitem syntax |
Attributes¶
- ndsampler.coco_frames.profile¶
- class ndsampler.coco_frames.CocoFrames(dset, hashid_mode='PATH', workdir=None, verbose=0, backend='auto')[source]¶
Bases:
ndsampler.abstract_frames.Frames
,ndsampler.utils.util_misc.HashIdentifiable
wrapper around coco-style dataset to allow for getitem syntax
- CommandLine:
xdoctest -m ndsampler.coco_frames CocoFrames
Example
>>> from ndsampler.coco_frames import * >>> import ndsampler >>> import kwcoco >>> import ubelt as ub >>> workdir = ub.Path.appdir('ndsampler').ensuredir() >>> dset = kwcoco.CocoDataset.demo(workdir=workdir) >>> dset._ensure_imgsize() >>> self = CocoFrames(dset, workdir=workdir) >>> assert self.load_image(1).shape == (512, 512, 3) >>> assert self.load_image(1)[:-20, :-10].shape == (492, 502, 3) >>> assert self.load_region(1, (slice(-20), slice(-10))).shape == (492, 502, 3)
Example
>>> from ndsampler import coco_sampler >>> self = coco_sampler.CocoSampler.demo().frames >>> assert self.load_image(1).shape == (600, 600, 3) >>> assert self.load_image(1)[:-20, :-10].shape == (580, 590, 3)
- property image_ids¶
- load_region(image_id, region=None, channels=ub.NoParam)[source]¶
Ammortized O(1) image subregion loading (assuming constant region size)
- Parameters
image_id (int) – image identifier
region (Tuple[slice, …]) – space-time region within an image
channels (str) – NotImplemented
width (int) – if the width of the entire image is know specify it
height (int) – if the height of the entire image is know specify it
- _build_pathinfo(image_id)[source]¶
- Returns
See Parent Method Docs
Example
>>> import ndsampler >>> sampler1 = ndsampler.CocoSampler.demo('vidshapes5-aux') >>> sampler2 = ndsampler.CocoSampler.demo('vidshapes5-multispectral') >>> self = sampler1.frames >>> pathinfo = self._build_pathinfo(1) >>> print('pathinfo = {}'.format(ub.urepr(pathinfo, nl=3)))
>>> self = sampler2.frames >>> pathinfo = self._build_pathinfo(1) >>> print('pathinfo = {}'.format(ub.urepr(pathinfo, nl=3)))