svkcore.annotation

svkcore.annotation.pascal

class svkcore.annotation.pascal.DTAnnotation(filename: str, size, objects: List[DTObject], segmented=False, **kwargs)[source]

Bases: object

Detection Annotation: An annotation for object detection

dump(path)[source]

Dump DTAnnotation to a file

Parameters:

path (str) – dumped file path

dumpd()[source]

Dump DTAnnotation to a dict

Returns:

a dict contains DTAnnotation information

Return type:

dict

static load(path: str)[source]

Load DTAnnotation from a file

Parameters:

path – file path

Returns:

loaded DTAnnotation object

Return type:

DTAnnotation

static loadd(obj: dict)[source]

Load DTAnnotation from a dict

Parameters:

obj – a dict contains DTAnnotation information

Returns:

loaded DTAnnotation object

Return type:

DTAnnotation

size_keys = ('width', 'height', 'depth')
class svkcore.annotation.pascal.DTDataset(annotations, images, categories)[source]

Bases: object

Detection dataset: A collection of annotations for object detection

dump_coco(path)[source]

Save dataset to coco format

Parameters:

path – coco format annotation path

Returns:

None

dump_pascal(annotation_dir)[source]

Save dataset to pascal format

Parameters:

annotation_dir – pascal format annotations directory

Returns:

None

dump_yolo(dataset_dir)[source]

Save dataset to yolo format

Parameters:

dataset_dir – yolo format dataset directory

Returns:

None

static load_coco(annotation_path, image_root)[source]

Load coco format dataset

Parameters:
  • annotation_path – json format annotation file path

  • image_root – image root directory

Returns:

DTDataset object

static load_pascal(annotation_paths, image_paths)[source]

Load pascal format dataset

Parameters:
  • annotation_paths – a list of pascal format annotation file path

  • image_paths – a list of image path respect with each annotation file

Returns:

DTDataset object

class svkcore.annotation.pascal.DTObject(name, bndbox=None, polygon=None, mask=None, pose='Unspecified', truncated=False, difficult=False)[source]

Bases: object

Detection object: base object for object detection

box_keys = ('xmin', 'ymin', 'xmax', 'ymax')
dumpd() dict[source]

Dump DTObject to a dict

Returns:

a dict contains DTObject information

Return type:

dict

static loadd(obj: dict)[source]

Load DTObject from a dict

Parameters:

obj – a dict contains DTObject information

Returns:

loaded DTObject object

Return type:

DTObject

svkcore.annotation.pascal.read_annotation(annotation_path)[source]

Read object detection annotation of xml format file

Parameters:

annotation_path (str) – file path of annotation

Returns:

a dict of detection annotation

Return type:

dict

svkcore.annotation.pascal.write_annotation(annotation_path, annotation)[source]

Write object detection annotation to a xml format file

Parameters:
  • annotation_path – file path of annotation

  • annotation – a dict of detection annotation