Hi!
I was experimentig with the vtkConnectedPointsFilter to implement point cloud segmentation methods for a PyQt based application and I encountered a problem.
When running the filter on a simple test script the algorithm takes 20 seconds to process 17,849,266 points. When running the same filter with exactly the same parameters on a PyQt application the process hangs for hours and never finishes. I use other filters (for example vtkPCANormalEstimation) on the same application and with the same data and this huge difference is not present.
I do not understand where the bottleneck is and why there is such a huge difference. Is it related to the GIL (on the lines of this question python - File copy too slow when pyqt is involved - Stack Overflow)? Is there a way to fix this issue?
This is what I do in my test script
import vtk
pc = some_VTK_FLOAT_data #17,849,266 pts
points = vtk.vtkPoints()
points.SetData(pc)
vtk_ps = vtk.vtkPointSet()
vtk_ps.SetPoints(points)
vtk_ps.Modified()
vtk_pd = vtk.vtkPolyData()
vtk_pd.ShallowCopy(vtk_ps)
connectivity_filter = vtk.vtkConnectedPointsFilter()
connectivity_filter.SetInputData(vtk_pd)
connectivity_filter.SetRadius(50)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update() #20s to complete
In my application I create custom objects that inherit from the vtkPointSet class and calculate the connectivity using the method custom_obj.connected_calc():
def connected_calc(self):
temp = vtkPolyData()
temp.ShallowCopy(self)
connectivity_filter = vtkConnectedPointsFilter()
connectivity_filter.SetInputData(temp)
connectivity_filter.SetRadius(50)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update() #Never finishes
num_regions = connectivity_filter.GetNumberOfExtractedRegions()
self.GetPointData().SetScalars(connectivity_filter.GetOutput().GetPointData().GetArray('RegionId'))
self.Modified()
return num_regions
Thanks!