cut out part of a point cloud
Instead of list comprehension, is used numpy and came up with this statement:
inPathPoints = pc[(pc[:, 0] > -0.5) & (pc[:, 0] < 0.5) & (pc[:, 2] > 0.2) & (pc[:, 2] < 2)]
This is so fast it does not even show up in the profile output.
I have an intel D415 depth camera and want to identify obstacles in the path of my robot.
I want to reduce the points from the cam pc=(102720,3) to only a rectangular area where the robot has to pass through
I came up with this list comprehension, p[0] is the x-axis, p[2] the distance and the values are in meters, the robot needs around a 1 meter "door" and I limit the distance to 2 meters.
inPathPoints = np.asarray([p for p in pc if p[0] > -0.5 and p[0] < 0.5 and p[2] > 0.2 and p[2] < 2])
On my laptop cProfile shows a runtime of 0.25 seconds for this evaluation. 
As the robot needs to check for obstacles while moving I wanted to repeat this check about 5..10 times a 
second. Any hints what I could try to speed it up?