colission detection example for python
Hi,
for a media installation i am looking for a simple python example of how i can detect a collision in a defined area.
E.g. 200cm in front of the sensor there is a 50x50x50cm defined volume in the room. As soon as there are a certain number of points in this volume, a trigger should be triggered.
is there an example to start with?
regards
-
Hi Gappdietmar If you are generating a point cloud, a simple approach that I have seen used is to count the number of points by accessing the size value.
The link below has an example of a pyrealsense2 script that uses this method.
https://www.programmersought.com/article/10355487444/

If you are able to make use of OpenCV, an alternative approach may be to use its countNonZero instruction to count the number of non-zero elements in an array to determine the current number of values that are greater than zero (no depth).
https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#countnonzero
-
i would like to keep it very simple, it is really only about a rough distance measurement.
i have looked at the example pyglet_pointcloud_viewer.py, i am familiar with pyglet and with it i should get a simple visualization.
it is urgently necessary to use pcl for the filtering, unfortunately I don't get python installed!
for the nodejs, which would also be interesting, I have to compile the linrealsense first: https://github.com/IntelRealSense/librealsense/tree/master/wrappers/nodejs
I'm curious if that works. greetings
-
If the camera is in a fixed position, another approach would be to apply a 'depth clamp' to set a minimum and maximum depth sensing distance, so that depth distances below and above a certain distance from the camera will be ignored. In other words, defining a 'zone' in front of the camera where depth can be detected if something enters that range. In librealsense, a post-processing filter called a Threshold Filter can filter the depth data.
https://github.com/IntelRealSense/librealsense/issues/5964#issuecomment-594372943
Conceivably you could adapt pyglet_pointcloud_viewer.py to add a Python implementation of a threshold filter if pyglet is a format that you are comfortable with.
If you want to implement a depth clamp in PCL, a PassThrough Filter may produce the same effect.
Please sign in to leave a comment.
Comments
3 comments