

def annotations(self, imageset=None, classes=None, nodifficult=False):
    if (imageset is None):
        imageset = self.imageset()
    elif isinstance(imageset, str):
        imageset = self.imageset(imageset)
    for file in imageset:
        logger.info('Reading {0}'.format(file))
        file = os.path.join(self.root, 'Annotations', '{0}.xml'.format(file))
        if (not file.endswith('.xml')):
            continue
        tree = ElementTree.parse(file)
        filename = tree.find('filename').text.strip()
        for object in tree.findall('object'):
            label = object.find('name').text.strip()
            if (classes and (label not in classes)):
                continue
            if nodifficult:
                difficult = object.find('difficult').text
                difficult = bool(int(difficult))
                if difficult:
                    continue
            xtl = int(object.find('bndbox/xmin').text)
            ytl = int(object.find('bndbox/ymin').text)
            xbr = int(object.find('bndbox/xmax').text)
            ybr = int(object.find('bndbox/ymax').text)
            (yield Box(xtl, ytl, xbr, ybr, label=label, image=filename))

dataset/ETHPy150Open cvondrick/pyvision/vision/pascal.py PascalDataset.annotations/original