Search code examples
point-cloud-library

Finding the direction of axis in PCL


I have a PCD file which contains some information about x,y and z coordinates of point clouds. I am doing some analysis on this data for recognizing whether two objects are in right/left side of each other or not. I have made an AABB(axis aligned bounding box) around each point cloud and then set the right/left side detection rules, also . Now, I was wondering how can I find the direction of X,Y, Z axes according to the PCD file or visualizer. means whether is there any way that I can understand e.g. the direction of positive part of X axis is from left to right or right to left? it is important because my detection rules should be compatible with that. Thanks a lot for you kind answers :)


Solution

  • First, cluster and segment two objects. EuclideanClusterExtraction is enough.

    Second, compute the center point(pcl::PointXYZ p1, p2) of two objects, you can find this API in PCL.

    Third, decide which direction is the front. The direction is a different coordinate system and you need a Orthographic projection to transform p1 and p2 to the direction coordinate(you get p1' and p2'). To do Orthographic projection, I usually use this api and it works fine.

    Four, the value of (p1'-p2').x tell you left or right.