Пример #1
0
    def get_ufc1_bboxes(self, frame_no, data):
        xmlns = "{http://lamp.cfar.umd.edu/viper#}"
        xmlns_data = "{http://lamp.cfar.umd.edu/viperdata#}"
        bboxes = []
        for person in data.findall('.//' + xmlns + 'object[@name="PERSON"]'):
            occluded = False
            attr_occlusion = person.find('.//' + xmlns + 'attribute[@name="Occlusion"]')
            for occ_element in attr_occlusion:
                fs = occ_element.attrib.get('framespan').split(':')
                if int(fs[0]) <= frame_no <= int(fs[1]):
                    if occ_element.attrib.get('value') == 1:
                        occluded = True
            if occluded:
                continue
            data_bbox = person.findall('.//' + xmlns_data + 'bbox')
            for bbox_element in data_bbox:
                fs = bbox_element.attrib.get('framespan').split(':')
                if int(fs[0]) <= frame_no <= int(fs[1]):
                    bboxes.append([int(bbox_element.attrib.get('x')),
                                   int(bbox_element.attrib.get('y')),
                                   int(bbox_element.attrib.get('width')),
                                   int(bbox_element.attrib.get('height')),
                                   ])
        if len(bboxes) > 0:
            bboxes = bbu.convert_topleft_to_centre(bboxes)

        return bboxes
Пример #2
0
 def get_minidrone_bbox(self, frame_no, data):
     root = data.getroot()
     xmlns = "{http://lamp.cfar.umd.edu/viper#}"
     xmlns_data = "{http://lamp.cfar.umd.edu/viperdata#}"
     bboxes = []
     for elem in root.findall('.//' + xmlns + 'object[@name="Person"]'):
         vis_attr = elem.find('.//' + xmlns + 'attribute[@name="Visibility"]')
         occluded = False
         for vis_interval in vis_attr:
             lim = vis_interval.attrib.get('framespan').split(sep=':')
             if int(lim[0]) <= frame_no <= int(lim[1]):
                 if vis_interval.attrib.get('value') == 'strong_occlusion':
                     occluded = True
         if occluded:
             continue
         for child in elem.iter(tag=xmlns_data + 'bbox'):
             occluded = False
             # check for occlusion
             lim = child.attrib.get('framespan').split(sep=':')
             if (int(lim[0]) <= frame_no <= int(lim[1])) and (not occluded):
                 x = child.attrib.get('x')
                 y = child.attrib.get('y')
                 w = child.attrib.get('width')
                 h = child.attrib.get('height')
                 bboxes.append([max(int(x), 0), max(int(y), 0), max(int(w), 0), max(int(h), 0)])
     if bboxes:
         bboxes = bbu.convert_topleft_to_centre(bboxes)
     return bboxes
Пример #3
0
 def get_coco_bboxes(self, data, img_name):
     img_id = -1
     for img_info in data['images']:
         if img_info['file_name'] == img_name:
             img_id = img_info['id']
     if img_id == -1:
         raise ValueError('image id is not found')
     bboxes = []
     for obj in data['annotations']:
         if obj['image_id'] == img_id and obj['category_id'] == 1:
             bboxes.append([int(x) for x in obj['bbox']])
     return bbu.convert_topleft_to_centre(bboxes)
Пример #4
0
 def get_ufc2_bboxes(self, frame_no, data):
     xmlns = "{http://lamp.cfar.umd.edu/viper#}"
     xmlns_data = "{http://lamp.cfar.umd.edu/viperdata#}"
     bboxes = []
     for obj in data.findall('.//' + xmlns + 'object'):
         if obj.find('.//' + xmlns_data + 'svalue').get('value') == 'man':
             for bbox_element in obj.findall('.//' + xmlns_data + 'bbox'):
                 fs = bbox_element.attrib.get('framespan').split(':')
                 if int(fs[0]) <= frame_no <= int(fs[1]):
                     bboxes.append([int(bbox_element.attrib.get('x')),
                                    int(bbox_element.attrib.get('y')),
                                    int(bbox_element.attrib.get('width')),
                                    int(bbox_element.attrib.get('height'))])
     if len(bboxes) > 0:
         bboxes = bbu.convert_topleft_to_centre(bboxes)
     return bboxes
Пример #5
0
 def get_visdrone_bbox(self, data):
     bboxes = np.array([b for b in data if (int(b[5]) == 1 or int(b[5]) == 2) and int(b[7]) != 2])
     if len(bboxes) > 0:
         bboxes = bboxes[:, :5]
         bboxes = bbu.convert_topleft_to_centre(bboxes)
     return bboxes