Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The code for 1ualitative error visualization #6

Open
sunjc0306 opened this issue Oct 19, 2021 · 3 comments
Open

The code for 1ualitative error visualization #6

sunjc0306 opened this issue Oct 19, 2021 · 3 comments

Comments

@sunjc0306
Copy link

sunjc0306 commented Oct 19, 2021

image

Hi, thanks for your excellent work and open-sourcing your code.
I have successfully reproduced your code. However, I would like to implement some cool visualization results. Can you share the code for visualizing the qualitativee error of Figure 5 in your paper?

@CrisHY1995
Copy link
Owner

Apologies for the late reply.

The main code is as follows:

import cv2
import numpy as np
import openmesh  as om
import os

import pymesh
import numpy as np

def calc_error(pred_mesh_path, gt_mesh_path):

    gt_mesh = pymesh.load_mesh(gt_mesh_path)
    pred_mesh = pymesh.load_mesh(pred_mesh_path)

    squa_distan_pred_2_gt, _, _ = pymesh.distance_to_mesh(gt_mesh, pred_mesh.vertices)
    return np.sqrt(squa_distan_pred_2_gt)


def process_one(bar_img_path, res_mesh_path, GT_mesh_path, max_thres, save_path):

    # load color bar info.
    color_bar_path = bar_img_path
    color_bar_img = cv2.imread(color_bar_path)
    color_bar_img = cv2.cvtColor(color_bar_img, cv2.COLOR_BGR2RGB)
    color_bar_img = color_bar_img.astype(np.float32)/255.0
    bar_colors = color_bar_img[:, 100, :]

    # load mesh geo
    assert os.path.exists(res_mesh_path)
    res_mesh = om.read_trimesh(res_mesh_path)
    res_mesh.request_vertex_colors()

    # calc the error of each vertex
    dis_res_2_gt = calc_error(res_mesh_path, GT_mesh_path)
    dis_res_2_gt [dis_res_2_gt > max_thres] = max_thres
    
    # convert error 2 color, the length of color bar is 1024
    color_index = (1023 - (dis_res_2_gt/max_thres) * 1023).astype(np.int)
    temp_vcs = bar_colors[color_index]
    
    # Color each vertex
    res_vcs = res_mesh.vertex_colors()
    res_vcs[:, 0:3] = temp_vcs

    # save color mesh.
    om.write_mesh(save_path, res_mesh, vertex_color = True)

This is the color bar image:
colorbar_texture

Sorry again !!

@sunjc0306
Copy link
Author

Thanks for your provided code. I have successfully achieved the cool visualization results with your help.
Thank you again.
However, I have another problem that Fig 5 maybe show point-to-surface error visualization, and is
pymesh.distance_to_mesh(gt_mesh, pred_mesh.vertices) used to calculate the metric value of point-to-surface?

@CrisHY1995
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants