cvtools.cocotools package

Module contents

class cvtools.cocotools.COCO(annotation_file=None)[源代码]

基类:object

annToMask(ann)[源代码]

Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask. :return: binary mask (numpy 2D array)

annToRLE(ann)[源代码]

Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array)

createIndex()[源代码]
download(tarDir=None, imgIds=[])[源代码]

Download COCO images from mscoco.org server. :param tarDir (str): COCO results directory name

imgIds (list): images to be downloaded
返回:
getAnnIds(imgIds=[], catIds=[], areaRng=[], iscrowd=None)[源代码]

Get ann ids that satisfy given filter conditions. default skips that filter :param imgIds (int array) : get anns for given imgs

catIds (int array) : get anns for given cats areaRng (float array) : get anns for given area range (e.g. [0 inf]) iscrowd (boolean) : get anns for given crowd label (False or True)
返回:ids (int array) : integer array of ann ids
getCatIds(catNms=[], supNms=[], catIds=[])[源代码]

filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given cat ids :return: ids (int array) : integer array of cat ids

getImgIds(imgIds=[], catIds=[])[源代码]

Get img ids that satisfy given filter conditions. :param imgIds (int array) : get imgs for given ids :param catIds (int array) : get imgs with all given cats :return: ids (int array) : integer array of img ids

info()[源代码]

Print information about the annotation file. :return:

loadAnns(ids=[])[源代码]

Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects

loadCats(ids=[])[源代码]

Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects

loadImgs(ids=[])[源代码]

Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects

loadNumpyAnnotations(data)[源代码]

Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} :param data (numpy.ndarray) :return: annotations (python nested list)

loadRes(resFile)[源代码]

Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object

showAnns(anns)[源代码]

Display the specified annotations. :param anns (array of object): annotations to display :return: None

class cvtools.cocotools.COCOeval(cocoGt=None, cocoDt=None, iouType='segm')[源代码]

基类:object

accumulate(p=None)[源代码]

Accumulate per image evaluation results and store the result in self.eval :param p: input params for evaluation :return: None

computeIoU(imgId, catId)[源代码]
computeOks(imgId, catId)[源代码]
evaluate()[源代码]

Run per image evaluation on given images and store results (a list of dict) in self.evalImgs :return: None

evaluateImg(imgId, catId, aRng, maxDet)[源代码]

perform evaluation for single category and image :return: dict (single image results)

summarize()[源代码]

Compute and display summary metrics for evaluation results. Note this functin can only be applied on the default parameter setting