PCL_Select the object after the object is divided with a square frame

The frame selection itself is still very simple, just get the center of gravity of the point cloud of each object after segmentation, and then draw the frame. Here I also added a PCA to adjust the rectangular frame according to the main axis of the object point cloud Mainly refer to http://pointclouds.org/documentation/tutorials/moment_of_inertia.php. It is written in detail here. The main process is:

First calculate the covariance matrix of the point cloud, and extract its eigenvalues ​​and vectors. You can think that the resulting eigenvectors are normalized and always form a right-handed coordinate system (the main eigenvector represents the X axis and the minor vector represents the Z axis). In the next step, an iterative process takes place. In each iteration, the main feature vector is rotated. The rotation sequence is always the same and is performed around other feature vectors, which provides the invariance of the rotation of the point cloud. From now on, we will call this rotating principal vector the current axis.


The result of box selection of the reference article is this:



The final result of my operation is:




My code here is very redundant. . . But my code ability is also average, so I won't post it.

Guess you like

Origin blog.csdn.net/wi162yyxq/article/details/73246507