martianxiu / MSECNet

This is the official implementation of our paper MSECNet: Accurate and Robust Normal Estimation for 3D Point Clouds by Multi-Scale Edge Conditioning (ACMMM2023)
Other
23 stars 1 forks source link

Normals orientation postprocessing #2

Closed RauchLukas closed 8 months ago

RauchLukas commented 8 months ago

Hey authors, great work! Thank you for open-sourcing the code!

I reproduced the tests with your pretrained model for PCPNet and was wondering if you have deeper insights of "how to orient the Normans" in post-processing.

Your Output results of the Liberty Statue show oriented normals, which doesn't match the predicted output of the model and the test script. I can reproduce a kind of similar result if I use third party libraries, e.g. Open3D to orient normals along local tangent planes. But this is highly inefficient for larger point clouds.

Can you recommend a more efficient way to orient the normals global, that fits better in the pipeline with your approach, to reproduce the presented results?

martianxiu commented 8 months ago

Hello! Thanks for asking.

For visualization, I have flipped the predicted normal vector if flipping it will reduce the angular error with the ground truth.

If there is no ground truth to correct the orientation, I would suggest using an existing post-processing algorithm (like the one you used) or estimating the oriented normal vector directly by the network. In the latter case, the input radius should be increased so that the network can infer the global structure of the point cloud.

RauchLukas commented 8 months ago

Could you please reference this in the code sniped? From skipping though the code, I am not sure where to make this change.

And, if this is only a matter of configuration, does it imply a decrease of accuracy in the results?

martianxiu commented 8 months ago

Sorry, I currently don't have the nice code for visualization but you can implement something like this:

def get_norm(v):
    return np.sum(v**2, axis=-1, keepdims=True) ** 0.5

def angle_error(v1, v2, oriented=False, rmse=True):
    cos_sim = np.sum(v1 * v2, axis=-1, keepdims=True) / ((get_norm(v1)*get_norm(v2)) + 1e-10)
    if oriented:
        return (1 - cos_sim)**2 if rmse else 1 - cos_sim
    else:
        return (1 - np.abs(cos_sim))**2 if rmse else 1 - np.abs(cos_sim)

def flip_normal(v, v_gt):
    n1 = v
    n2 = -v
    error_n1 = angle_error(n1, v_gt, oriented=True)
    error_n2 = angle_error(n2, v_gt, oriented=True)
    n_final = np.where(error_n1 <= error_n2, n1, n2)
    return n_final

You can get the orientation corrected normals by applying flip_normal() to the output of the model.