예제 #1
0
my_renderer = SMPLRenderer(face_path="../predef/smpl_faces.npy")
hf_list = get_hf_list()

tr = trange(data_num, desc='Bar desc', leave=True)
for i in tr:
    # read results and gt mesh
    mesh_gt = om.read_trimesh("./eval_data/%s_set/gt/%03d.obj" % (set_name, i))
    mesh_tgt = om.read_trimesh("./eval_data/%s_set/pred_save/%s_%03d.obj" \
                               % (set_name, opt.tgt, i))

    verts_gt = mesh_gt.points()
    verts_tgt = mesh_tgt.points()

    # pick visible verts
    _, visi_gt = render_depth(mesh_gt, require_visi=True)
    _, visi_tgt = render_depth(mesh_tgt, require_visi=True)

    faces_gt = mesh_gt.face_vertex_indices()
    faces_tgt = mesh_tgt.face_vertex_indices()

    visi_gt = [visi_gt[x, y] for x in range(448) for y in range(448)]
    visi_gt = set(visi_gt)
    visi_gt.remove(4294967295)
    visi_gt = [faces_gt[fv][ind] for ind in range(3) for fv in visi_gt]
    visi_gt = list(set(visi_gt))

    visi_tgt = [visi_tgt[x, y] for x in range(448) for y in range(448)]
    visi_tgt = set(visi_tgt)
    visi_tgt.remove(4294967295)
    visi_tgt = [faces_tgt[fv][ind] for ind in range(3) for fv in visi_tgt]
예제 #2
0
        draw_img[y:y + 2 * radius + 1, x:x + 2 * radius + 1] = win

final_mask = sil_img - draw_img[10:10 + img_size[0], 10:10 + img_size[1]]
final_mask[sil_img == 0] = 0

pred_depth = pred_depth * final_mask

# print('pred_depth shape:')
# print(pred_depth.shape)
# from matplotlib import pyplot as plt
# plt.imshow(final_mask)
# plt.show()

# project mesh to depth and merge with depth difference
proj_depth, visi_map = rd.render_depth(
    subdiv_mesh, require_visi=True
)  # mesh to depth map//proj_depth/visi_map shape = (448,448)

# print('proj_depth:')
# print(proj_depth)
# depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(proj_depth),cv2.COLORMAP_JET)
# cv2.imshow('depth_colormap',depth_colormap)
# cv2.waitKey(0)

# get all visible vertex index
verts_sd = subdiv_mesh.points()
faces_sd = subdiv_mesh.face_vertex_indices()
visi_vert_inds = []
for y in range(visi_map.shape[0]):
    for x in range(visi_map.shape[1]):
        f_ind = visi_map[y, x]
예제 #3
0
draw_img = np.pad(draw_img, radius, 'edge')
for y in range(img_size[0]):
    for x in range(img_size[1]):
        if bound_img[y, x] == 0:
            continue
        win = draw_img[y:y + 2 * radius + 1, x:x + 2 * radius + 1]
        win[circ_template > win] = circ_template[circ_template > win]
        draw_img[y:y + 2 * radius + 1, x:x + 2 * radius + 1] = win

final_mask = sil_img - draw_img[10:10 + img_size[0], 10:10 + img_size[1]]
final_mask[sil_img == 0] = 0

pred_depth = pred_depth * final_mask

# project mesh to depth and merge with depth difference
proj_depth, visi_map = rd.render_depth(subdiv_mesh, require_visi=True)

# get all visible vertex index
verts_sd = subdiv_mesh.points()
faces_sd = subdiv_mesh.face_vertex_indices()
visi_vert_inds = []
for y in range(visi_map.shape[0]):
    for x in range(visi_map.shape[1]):
        f_ind = visi_map[y, x]
        if f_ind >= len(faces_sd):
            continue
        else:
            fv = faces_sd[f_ind]
            visi_vert_inds.append(fv[0])
            visi_vert_inds.append(fv[1])
            visi_vert_inds.append(fv[2])