tmontaigu / CloudCompare-PythonRuntime

Python plugin for CloudCompare
55 stars 15 forks source link

Point cloud visualization problem #98

Closed polzaco closed 8 months ago

polzaco commented 8 months ago

Hi everyone!

We are using pycc for point clouds segmentation. When we store the point cloud in the database of cc with the following code, the points results are wrong :

CREATE THE RESULTING POINT CLOUD

        # Load the predictions
        pcd_prediction = pd.read_csv(os.path.join(self.output_directory,'predictions.txt'), sep=',')  # Use sep='\t' for tab-separated files       

        # Select only the 'Predictions' column
        pc_results_prediction = pycc.ccPointCloud(pcd_prediction['X'], pcd_prediction['Y'], pcd_prediction['Z'])
        pc_results_prediction.setName("Results_from_segmentation")
        idx = pc_results_prediction.addScalarField("Labels",pcd_prediction['Predictions']) 

        # STORE IN THE DATABASE OF CLOUDCOMPARE
        CC = pycc.GetInstance()
        CC.addToDB(pc_results_prediction)
        CC.updateUI() 

Firstly, I would prefer open it with the Scalar Field view at the beginning, because it appears with None. (first picture) Captura de pantalla 2024-03-08 160300

Then, after the scalar field activation , the point cloud only open the first class color, the rest dont open. (second picture) Captura de pantalla 2024-03-08 160321

It should appear at the first time like that. I did with "Split cloud (integer values)" tool and then merging all of them (thrid picture) Captura de pantalla 2024-03-08 160508

Is possible to do that? Thanks in advance.

tmontaigu commented 8 months ago

To show a scalar field by default you have to call point_cloud.setCurrentDisplayedScalarField(idx)

And to CC to show nice colors you have to call computeMinAndMax on the scalar field point_cloud.getScalarField(point_cloud.getScalarFieldIndexByName("classification")).computeMinAndMax()