charlesq34 / pointnet

PointNet: Deep Learning on Point Sets for 3D Classification and Segmentation
Other
4.64k stars 1.44k forks source link

how to visualize the segmentation results(not npy file) #269

Open beepbeep08 opened 3 years ago

beepbeep08 commented 3 years ago

hello, i want to visualize the segmentation result. i know that the way visualize npy file, but i want to see "pred_obj file", not gt obj file/npy file. meshlab show me grayscale obj file. plz help me.

chongma commented 2 years ago

@beepbeep08 i used pyvista in jupyter notebook to visualize the obj colours as i didn't have any program to view it

import re
import pyvista as pv
import numpy as np

filename = '<pathToYourInstallation>/pointnet/part_seg/test_results/12_gt.obj'

reComp = re.compile("(?<=^)(v |vn |vt |f )(.*)(?=$)", re.MULTILINE)
with open(filename) as f:
    data = [txt.group() for txt in reComp.finditer(f.read())]

v_arr, vn_arr, vt_arr, f_arr = [], [], [], []
for line in data:
    tokens = line.split(' ')
    if tokens[0] == 'v':
        v_arr.append([float(c) for c in tokens[1:]])
    elif tokens[0] == 'vn':
        vn_arr.append([float(c) for c in tokens[1:]])
    elif tokens[0] == 'vt':
        vn_arr.append([float(c) for c in tokens[1:]])
    elif tokens[0] == 'f':
        f_arr.append([[int(i) if len(i) else 0 for i in c.split('/')] for c in tokens[1:]])

points = []
colormat = []
for v in v_arr:
    points.append([v[0], v[1], v[2]])
    colormat.append([v[3], v[4], v[5]])

mesh = pv.PolyData(points)
mesh["colors"] = colormat

plotter = pv.Plotter(notebook=True)
plotter.add_mesh(mesh, show_edges=False, scalars="colors", rgb=True, point_size=3.0)
plotter.show()

# print(len(v_arr))
# print(v_arr)

it gives 3 files like 12_gt.obj, 12_pred.obj and 12_diff.obj. is there any explanation as to what these different files are for?

chongma commented 2 years ago

Ah...i see. gt = ground truth pred = prediction diff = difference between ground truth and prediction