CloudCompare / CloudComPy

Python wrapper for CloudCompare
Other
294 stars 42 forks source link

About PointCloud Segmentation #7

Open jianjuan opened 3 years ago

jianjuan commented 3 years ago

Hi, I really appreciate your effort to develop a Python-API for CC. And I wonder if "segmetation tool" has been implemented ? I have no idea to find this, thanks very much for your reply!

prascle commented 3 years ago

Hi, There are several segmentation tools available in the CloudCompare GUI, I don't know which ones you are interested in. In the Python interface, I have taken in priority functions from the online command mode (https://www.cloudcompare.org/doc/wiki/index.php?title=Command_line_mode) including the CROP2D function which allows to cut a point cloud by a polyline (see the Python test007.py and documentation crop2D). If this is not what you are looking for, can you tell me what you are interested in, with the menus of the graphical interface you use, and/or screenshots of what you would like to reproduce in Python ? I will then add this to my to-do list, if possible. Regards.

jianjuan commented 3 years ago

I think crop2D is exactly what i want, by the way, cloud you please tell me what kind of data structure that parameter "polyline" should be? Or, if I have pixel coordinates in the picture, how can I convert these 2D points to crop the corresponding pointcloud? Thank you very much!

prascle commented 3 years ago

A polyline is a broken line described by the list of points that constitute it. CloudCompare supports several polyline formats: dxf, shapefile, .poly... I used the .poly format (Salome Hydro polyline) to build a polyline file in my Python examples: easy to edit Ascii file, one point per line (x y z coordinates). For instance:

1.000000 2.000000 0.000000
2.000000 4.000000 0.000000
3.000000 1.000000 0.000000
2.000000 -2.000000 0.000000
-1.000000 -3.000000 0.000000
-1.000000 -1.000000 0.000000
-2.000000 2.000000 0.000000

For the Crop2D, only the x and y coordinates are used, z can be set to 0. It is of course necessary to have the same coordinate system for the cloud and for the polyline. In your case, I guess you have a calibrated picture and a cloud, so you should be able to convert pixel coordinates in cloud coordinates?

jianjuan commented 3 years ago

Yeah, I see, you are right! And I know how to crop my cloud this time, Thanks very much!