Beispiel #1
0
            im_size = (obj_mask_gt.shape[1], obj_mask_gt.shape[0])

            # Absolute difference of the distance images
            # dist_diff = np.abs(dist_gt.astype(np.float32) -
            #                    dist_im.astype(np.float32))
            # mask_below_delta = dist_diff < delta
            # mask_below_delta *= obj_mask_gt

            # Bounding box of the object mask
            # bbox_all = [-1, -1, -1, -1]
            # if px_count_all > 0:
            #     ys, xs = obj_mask_gt.nonzero()
            #     bbox_all = misc.calc_2d_bbox(xs, ys, im_size)

            # Bounding box of the object projection
            bbox_obj = misc.calc_pose_2d_bbox(models[gt['obj_id']], im_size, K,
                                              gt['cam_R_m2c'], gt['cam_t_m2c'])

            # Bounding box of the visible surface part
            bbox_visib = [-1, -1, -1, -1]
            if px_count_visib > 0:
                ys, xs = visib_gt.nonzero()
                bbox_visib = misc.calc_2d_bbox(xs, ys, im_size)

            gt_stats[im_id].append({
                'px_count_all': int(px_count_all),
                'px_count_visib': int(px_count_visib),
                'px_count_valid': int(px_count_valid),
                'visib_fract': float(visib_fract),
                'bbox_obj': [int(e) for e in bbox_obj],
                'bbox_visib': [int(e) for e in bbox_visib]
            })
Beispiel #2
0
    R_conv = np.linalg.inv(R_model.dot(R_z_90.dot(R_x_90)))

    for im_id in im_ids:
        if im_id % 10 == 0:
            print('obj,view: ' + obj_name + ',' + str(im_id))

        # Load the GT pose
        pose = load_gt_pose_brachmann(pose_mpath.format(obj_name, im_id))
        if pose['R'].size != 0 and pose['t'].size != 0:

            # Transfom the GT pose
            R_m2c = pose['R'].dot(R_conv)
            t_m2c = pose['t'] * 1000  # from [m] to [mm]

            # Get 2D bounding box of the object model at the ground truth pose
            obj_bb = misc.calc_pose_2d_bbox(model, par['cam']['im_size'],
                                            par['cam']['K'], R_m2c, t_m2c)

            # Visualisation
            if False:
                rgb = inout.load_im(rgb_mpath.format(im_id, im_id))
                ren_rgb = renderer.render(model,
                                          par['cam']['im_size'],
                                          par['cam']['K'],
                                          R_m2c,
                                          t_m2c,
                                          mode='rgb')
                vis_rgb = 0.4 * rgb.astype(np.float32) + 0.6 * ren_rgb.astype(
                    np.float32)
                vis_rgb = vis_rgb.astype(np.uint8)
                vis_rgb = misc.draw_rect(vis_rgb, obj_bb)
                plt.imshow(vis_rgb)
Beispiel #3
0
            im_size = (obj_mask_gt.shape[1], obj_mask_gt.shape[0])

            # Absolute difference of the distance images
            # dist_diff = np.abs(dist_gt.astype(np.float32) -
            #                    dist_im.astype(np.float32))
            # mask_below_delta = dist_diff < delta
            # mask_below_delta *= obj_mask_gt

            # Bounding box of the object mask
            # bbox_all = [-1, -1, -1, -1]
            # if px_count_all > 0:
            #     ys, xs = obj_mask_gt.nonzero()
            #     bbox_all = misc.calc_2d_bbox(xs, ys, im_size)

            # Bounding box of the object projection
            bbox_obj = misc.calc_pose_2d_bbox(models[gt['obj_id']], im_size,
                                              K, gt['cam_R_m2c'], gt['cam_t_m2c'])

            # Bounding box of the visible surface part
            bbox_visib = [-1, -1, -1, -1]
            if px_count_visib > 0:
                ys, xs = visib_gt.nonzero()
                bbox_visib = misc.calc_2d_bbox(xs, ys, im_size)

            gt_stats[im_id].append({
                'px_count_all': int(px_count_all),
                'px_count_visib': int(px_count_visib),
                'px_count_valid': int(px_count_valid),
                'visib_fract': float(visib_fract),
                'bbox_obj': [int(e) for e in bbox_obj],
                'bbox_visib': [int(e) for e in bbox_visib]
            })