How to use deep learning masks to adjust the output pose orientation

Logic: Get the centroids of the point clouds extracted using masks obtained by deep learning.
Issue: In some cases, the point clouds of the objects to pick are incomplete, resulting in unstable orientations of the object poses while the X-axes point along the long sides of the point clouds.
Desired implementation: Adjust the orientations of the objects’ X-axes using the masks provided by deep learning.

You can generate a point cloud using this method, and then calculate its shape, with ‘x’ always representing the longer side.