def load_annotation(gt_file):

        with open(gt_file, 'r') as f:
            lines = f.readlines()
        f.close()

        annotations = []

        for line in lines:
            obj = line.strip().split(' ')

            try:
                cls = config.CLASS_TO_IDX[obj[0].lower().strip()]

                xmin = float(obj[4])
                ymin = float(obj[5])
                xmax = float(obj[6])
                ymax = float(obj[7])

                assert xmin >= 0.0 and xmin <= xmax, \
                    'Invalid bounding box x-coord xmin {} or xmax {} at {}' \
                    .format(xmin, xmax, gt_file)
                assert ymin >= 0.0 and ymin <= ymax, \
                    'Invalid bounding box y-coord ymin {} or ymax {} at {}' \
                    .format(ymin, ymax, gt_file)

                x, y, w, h = bbox_transform_inv([xmin, ymin, xmax, ymax])

                annotations.append([x, y, w, h, cls])

            except:
                continue
        return annotations
Exemple #2
0
    def load_annotation(gt_file):

        with open(gt_file, 'r') as f:
            lines = f.readlines()
        f.close()

        annotations = []

        #each line is an annotation bounding box
        for line in lines:
            obj = line.strip().split(' ')

            #get class, if class is not in listed, skip it
            try:
                # With euclidaug, classId is directly in the line
                # cls = config.CLASS_TO_IDX[obj[0].lower().strip()]
                # print cls
                cls = int(obj[0])

                #get coordinates
                xmin = float(obj[4])
                ymin = float(obj[5])
                xmax = float(obj[6])
                ymax = float(obj[7])

                #check for valid bounding boxes
                assert xmin >= 0.0 and xmin <= xmax, \
                    'Invalid bounding box x-coord xmin {} or xmax {} at {}' \
                        .format(xmin, xmax, gt_file)
                assert ymin >= 0.0 and ymin <= ymax, \
                    'Invalid bounding box y-coord ymin {} or ymax {} at {}' \
                        .format(ymin, ymax, gt_file)

                #transform to  point + width and height representation
                x, y, w, h = bbox_transform_inv([xmin, ymin, xmax, ymax])

                annotations.append([x, y, w, h, cls])

            except:
                continue
        return annotations
Exemple #3
0
    def load_annotation(gt_file):

        with open(gt_file, 'r') as f:
            lines = f.readlines()
        f.close()

        annotations = []

        #each line is an annotation bounding box
        for line in lines:
            obj = line.strip().split(' ')
            #cls = config.CLASS_TO_IDX[obj[0].strip()]
            cls = config.CLASS_TO_IDX['head']
            # print cls
            #get coordinates
            xmin = float(obj[0])
            ymin = float(obj[1])
            xmax = float(obj[2]) + xmin
            ymax = float(obj[3]) + ymin
            x, y, w, h = bbox_transform_inv([xmin, ymin, xmax, ymax])

            annotations.append([x, y, w, h, cls])
        return annotations
Exemple #4
0
    def load_annotation(gt_file):

        with open(gt_file, 'r') as f:
            lines = f.readlines()
        f.close()

        annotations = []

        #each line is an annotation bounding box
        for line in lines:
            obj = line.strip().split(' ')
            #get class, if class is not in listed, skip it

            #cls = config.CLASS_TO_IDX[obj[0].strip()]
            #print cls
            cls = config.CLASS_TO_IDX['head']
            #get coordinates
            xmin = float(obj[0])
            ymin = float(obj[1])
            xmax = float(obj[2]) + xmin
            ymax = float(obj[3]) + ymin
            '''
            #check for valid bounding boxes
            assert xmin >= 0.0 and xmin <= xmax, \
                'Invalid bounding box x-coord xmin {} or xmax {} at {}' \
                    .format(xmin, xmax, gt_file)
            assert ymin >= 0.0 and ymin <= ymax, \
                'Invalid bounding box y-coord ymin {} or ymax {} at {}' \
                    .format(ymin, ymax, gt_file)
            '''

            #transform to  point + width and height representation
            x, y, w, h = bbox_transform_inv([xmin, ymin, xmax, ymax])

            annotations.append([x, y, w, h, cls])
        return annotations