Constructor of Microsoft COCO helper class for reading and visualizing annotations. :param annotation_file (str): location of annotation file :param image_folder (str): location to the folder that hosts images. :return:
(self, annotation_file=None)
| 60 | |
| 61 | class COCO: |
| 62 | def __init__(self, annotation_file=None): |
| 63 | """ |
| 64 | Constructor of Microsoft COCO helper class for reading and visualizing annotations. |
| 65 | :param annotation_file (str): location of annotation file |
| 66 | :param image_folder (str): location to the folder that hosts images. |
| 67 | :return: |
| 68 | """ |
| 69 | # load dataset |
| 70 | self.dataset = {} |
| 71 | self.anns = [] |
| 72 | self.imgToAnns = {} |
| 73 | self.catToImgs = {} |
| 74 | self.imgs = {} |
| 75 | self.cats = {} |
| 76 | if not annotation_file == None: |
| 77 | print 'loading annotations into memory...' |
| 78 | tic = time.time() |
| 79 | dataset = json.load(open(annotation_file, 'r')) |
| 80 | print 'Done (t=%0.2fs)'%(time.time()- tic) |
| 81 | self.dataset = dataset |
| 82 | self.createIndex() |
| 83 | |
| 84 | def createIndex(self): |
| 85 | # create index |
nothing calls this directly
no test coverage detected