Exemple #1
0
def match_poses(gts, gt_stats, errs, scene_id, visib_gt_min, error_threshs,
                n_top):

    # Organize the errors by image id and object id (for faster query)
    errs_org = {}
    for e in errs:
        errs_org.setdefault(e['im_id'], {}). \
            setdefault(e['obj_id'], []).append(e)

    # Matching
    matches = []
    for im_id, gts_im in gts.items():
        matches_im = []
        for gt_id, gt in enumerate(gts_im):
            valid = gt_stats[im_id][gt_id]['visib_fract'] >= visib_gt_min
            matches_im.append({
                'scene_id': scene_id,
                'im_id': im_id,
                'obj_id': gt['obj_id'],
                'gt_id': gt_id,
                'est_id': -1,
                'score': -1,
                'error': -1,
                'error_norm': -1,
                # 'stats': gt_stats[im_id][gt_id],
                'valid': int(valid)
            })

        # Mask of valid GT poses (i.e. GT poses with sufficient visibility)
        gt_valid_mask = [m['valid'] for m in matches_im]

        # Treat estimates of each object separately
        im_obj_ids = set([gt['obj_id'] for gt in gts_im])
        for obj_id in im_obj_ids:
            if im_id in errs_org.keys() and obj_id in errs_org[im_id].keys():

                # Greedily match the estimated poses to the ground truth
                # poses in the order of decreasing score
                errs_im_obj = errs_org[im_id][obj_id]
                ms = pose_matching.match_poses(errs_im_obj,
                                               error_threshs[obj_id], n_top,
                                               gt_valid_mask)
                for m in ms:
                    g = matches_im[m['gt_id']]
                    g['est_id'] = m['est_id']
                    g['score'] = m['score']
                    g['error'] = m['error']
                    g['error_norm'] = m['error_norm']

        matches += matches_im

    return matches
Exemple #2
0
            } for gt_id, gt in enumerate(gts_im)]

            # Mask of valid GT poses (i.e. GT poses with sufficient visibility)
            gt_valid_mask = [m['valid'] for m in matches_im]

            # Treat estimates of each object separately
            im_obj_ids = set([gt['obj_id'] for gt in gts_im])
            for obj_id in im_obj_ids:
                if im_id in errs_org.keys()\
                        and obj_id in errs_org[im_id].keys():

                    # Greedily match the estimated poses to the ground truth
                    # poses in the order of decreasing score
                    errs_im_obj = errs_org[im_id][obj_id]
                    ms = pose_matching.match_poses(errs_im_obj,
                                                   error_threshs[obj_id],
                                                   n_top, gt_valid_mask)
                    for m in ms:
                        g = matches_im[m['gt_id']]
                        g['est_id'] = m['est_id']
                        g['score'] = m['score']
                        g['error'] = m['error']
                        g['error_norm'] = m['error_norm']

            matches += matches_im

    # Calculation of performance scores
    #---------------------------------------------------------------------------
    # Count the number of visible object instances in each image
    insts = {
        i: {j: defaultdict(lambda: 0)