【注释说明】pcl库中OBB和AABB包围盒头文件pcl/features/moment_of_inertia_estimation.h,中文翻译注释说明,欢迎补充

【注释说明】pcl库中OBB和AABB包围盒头文件pcl/features/moment_of_inertia_estimation.h,中文翻译注释说明,欢迎补充

前景提要

近期学习了下OBB和AABB包围盒在pcl点云中的使用,想要弄清楚OBB的原理,打开头文件翻译注释了,特此记录。

翻译注释

前面这些英文是版权声明,没必要看

/*
 * Software License Agreement (BSD License)
 *
 *  Point Cloud Library (PCL) - www.pointclouds.org
 *
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of Willow Garage, Inc. nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 * Author : Sergey Ushakov
 * Email  : sergey.s.ushakov@mail.ru
 *
 */

#ifndef PCL_MOMENT_OF_INERTIA_ESIMATION_H_
#define PCL_MOMENT_OF_INERTIA_ESIMATION_H_

#include <vector>
#include <math.h>
#include <pcl/features/feature.h>
#include <pcl/PointIndices.h>

namespace pcl
{
  /** \brief
    * Implements the method for extracting features based on moment of inertia. It also
    * calculates AABB, OBB and eccentricity of the projected cloud.
	实现了基于惯性矩的特征提取方法。它还可以计算出投影云的AABB、OBB和离心率。
    */
  template <typename PointT>
  class PCL_EXPORTS MomentOfInertiaEstimation : public pcl::PCLBase <PointT>
  {
    public:

      using PCLBase <PointT>::input_;
      using PCLBase <PointT>::indices_;
      using PCLBase <PointT>::fake_indices_;
      using PCLBase <PointT>::use_indices_;
      using PCLBase <PointT>::initCompute;
      using PCLBase <PointT>::deinitCompute;

      typedef typename pcl::PCLBase <PointT>::PointCloudConstPtr PointCloudConstPtr;
      typedef typename pcl::PCLBase <PointT>::PointIndicesConstPtr PointIndicesConstPtr;

    public:

      /** \brief Provide a pointer to the input dataset
	   brief提供指向输入数据集的指针
        * \param[in] cloud the const boost shared pointer to a PointCloud message
	   param[in] cloud指向PointCloud消息的const boost共享指针
        */
      virtual void
      setInputCloud (const PointCloudConstPtr& cloud);

      /** \brief Provide a pointer to the vector of indices that represents the input data.
	   提供一个指向表示输入数据的索引向量的指针。
        * \param[in] indices a pointer to the vector of indices that represents the input data.
    	   param[in] indices一个指针,指向表示输入数据的索引向量。
        */
      virtual void
      setIndices (const IndicesPtr& indices);

      /** \brief Provide a pointer to the vector of indices that represents the input data.
	   提供一个指向表示输入数据的索引向量的指针。
        * \param[in] indices a pointer to the vector of indices that represents the input data.
	   param[in] indices一个指针,指向表示输入数据的索引向量。
        */
      virtual void
      setIndices (const IndicesConstPtr& indices);

      /** \brief Provide a pointer to the vector of indices that represents the input data.
	   提供一个指向表示输入数据的索引向量的指针。
        * \param[in] indices a pointer to the vector of indices that represents the input data.
	   param[in] indices一个指针,指向表示输入数据的索引向量。
        */
      virtual void
      setIndices (const PointIndicesConstPtr& indices);

      /** \brief Set the indices for the points laying within an interest region of 
        * the point cloud.
        * \note you shouldn't call this method on unorganized point clouds!
        * \param[in] row_start the offset on rows
        * \param[in] col_start the offset on columns
        * \param[in] nb_rows the number of rows to be considered row_start included
        * \param[in] nb_cols the number of columns to be considered col_start included
	/** \brief设置点云中感兴趣区域内的点的索引。
	注意,你不应该在没有组织的点云上调用这个方法!
	* \param[in] row_start行偏移量
	* \param[in] col_start列的偏移量
	* \param[in] nb_rows被认为包含row_start的行数
	* \param[in] nb_cols被认为包含col_start的列数
        */
      virtual void
      setIndices (size_t row_start, size_t col_start, size_t nb_rows, size_t nb_cols);

      /** \brief Constructor that sets default values for member variables. */
	/** \brief为成员变量设置默认值的构造函数。*/
      MomentOfInertiaEstimation ();

      /** \brief Virtual destructor which frees the memory. */
	/** \brief释放内存的虚析构函数。*/
      virtual
      ~MomentOfInertiaEstimation ();

      /** \brief This method allows to set the angle step. It is used for the rotation
        * of the axis which is used for moment of inertia/eccentricity calculation.
        * \param[in] step angle step
此方法允许设置角度步长。用于轴的转动,用于计算转动惯量/偏心量。
param[in] step角度步长
        */
      void
      setAngleStep (const float step);

      /** \brief Returns the angle step. */
/** \brief返回角度步骤。*/
      float
      getAngleStep () const;

      /** \brief This method allows to set the normalize_ flag. If set to false, then
        * point_mass_ will be used to scale the moment of inertia values. Otherwise,
        * point_mass_ will be set to 1 / number_of_points. Default value is true.
        * \param[in] need_to_normalize desired value

该方法允许设置normalize_标志。如果设置为false,则point_mass_将用于缩放惯性矩值。否则,point_mass_将被设置为1 / number_of_points。默认值为true。
need_to_normalize期望值
        */
      void
      setNormalizePointMassFlag (bool need_to_normalize);

      /** \brief Returns the normalize_ flag. */
/** \brief返回normalize_标志。*/
      bool
      getNormalizePointMassFlag () const;

      /** \brief This method allows to set point mass that will be used for
        * moment of inertia calculation. It is needed to scale moment of inertia values.
        * default value is 0.0001.
        * \param[in] point_mass point mass

这种方法允许设置点质量,用于计算惯性矩。需要对惯性矩值进行缩放。
默认值为0.0001。
参数[in] point_mass点质量
        */
      void
      setPointMass (const float point_mass);

      /** \brief Returns the mass of point. */
/** \brief返回点的质量。*/
      float
      getPointMass () const;

      /** \brief This method launches the computation of all features. After execution
        * it sets is_valid_ flag to true and each feature can be accessed with the
        * corresponding get method.
/** \brief该方法启动所有特性的计算。在执行之后,它将is_valid_标志设置为true,并且每个特性都可以通过
*对应的get方法。
        */
      void
      compute ();

      /** \brief This method gives access to the computed axis aligned bounding box. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * \param[out] min_point min point of the AABB
        * \param[out] max_point max point of the AABB

这个方法提供了对计算出的轴对齐边界框的访问。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
* \param[out] min_point AABB的最小点
* \param[out] max_point AABB的最大点
        */
      bool
      getAABB (PointT& min_point, PointT& max_point) const;

      /** \brief This method gives access to the computed oriented bounding box. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * Note that in order to get the OBB, each vertex of the given AABB (specified with min_point and max_point)
        * must be rotated with the given rotational matrix (rotation transform) and then positioned.
        * Also pay attention to the fact that this is not the minimal possible bounding box. This is the bounding box
        * which is oriented in accordance with the eigen vectors.
        * \param[out] min_point min point of the OBB
        * \param[out] max_point max point of the OBB
        * \param[out] position position of the OBB
        * \param[out] rotational_matrix this matrix represents the rotation transform

这个方法提供了对计算出的方向包围框的访问。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
*注意,为了得到OBB,给定的AABB的每个顶点(用min_point和max_point指定)必须旋转给定的旋转矩阵(旋转变换),然后定位。
*还要注意的是,这不是最小可能的边界框。这是根据特征向量定向的边界框。
* \param[out] min_point OBB的最小点
* \param[out] max_point OBB的最大点
* param[out] position OBB的位置
* \param[out] rotational_matrix这个矩阵表示旋转变换
        */
      bool
      getOBB (PointT& min_point, PointT& max_point, PointT& position, Eigen::Matrix3f& rotational_matrix) const;

      /** \brief This method gives access to the computed eigen values. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * \param[out] major major eigen value
        * \param[out] middle middle eigen value
        * \param[out] minor minor eigen value

这个方法提供了对计算出的特征值的访问。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
* \param[out] major主要特征值
* \param[out] middle中间特征值
* \param[out] minor小的特征值
        */
      bool
      getEigenValues (float& major, float& middle, float& minor) const;

      /** \brief This method gives access to the computed eigen vectors. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * \param[out] major axis which corresponds to the eigen vector with the major eigen value
        * \param[out] middle axis which corresponds to the eigen vector with the middle eigen value
        * \param[out] minor axis which corresponds to the eigen vector with the minor eigen value
这种方法提供了对计算出的特征向量的访问。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
* \param[out]长轴,对应于具有主特征值的特征向量
* \param[out]中轴,对应于具有中间特征值的特征向量
* \param[out]小轴,对应于具有小特征值的特征向量
        */
      bool
      getEigenVectors (Eigen::Vector3f& major, Eigen::Vector3f& middle, Eigen::Vector3f& minor) const;

      /** \brief This method gives access to the computed moments of inertia. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * \param[out] moment_of_inertia computed moments of inertia

这种方法可以得到计算出的转动惯量。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
* \param[out] moment_of_惯性计算的惯性矩
        */
      bool
      getMomentOfInertia (std::vector <float>& moment_of_inertia) const;

      /** \brief This method gives access to the computed ecentricities. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * \param[out] eccentricity computed eccentricities

这个方法提供了对计算出的偏心度的访问。它返回true当前值(离心率,转动惯量等)是有效的,否则返回false。
param[out] eccentricity计算出的偏心度
        */
      bool
      getEccentricity (std::vector <float>& eccentricity) const;

      /** \brief This method gives access to the computed mass center. It returns true
        * if the current values (eccentricity, moment of inertia etc) are valid and false otherwise.
        * Note that when mass center of a cloud is computed, mass point is always considered equal 1.
        * \param[out] mass_center computed mass center

这种方法可以访问计算出的质心。如果当前值(离心率,转动惯量等)有效则返回true,否则返回false。
*注意,当计算云的质心时,质点总是被认为等于1。
* \param[out] mass_center计算质量中心
        */
      bool
      getMassCenter (Eigen::Vector3f& mass_center) const;

    private:

      /** \brief This method rotates the given vector around the given axis.
        * \param[in] vector vector that must be rotated
        * \param[in] axis axis around which vector must be rotated
        * \param[in] angle angle in degrees
        * \param[out] rotated_vector resultant vector

这个方法使给定的向量围绕给定的轴旋转。
* \param[in] vector必须旋转的向量
* \param[in] axis旋转矢量的轴
param[in] Angle表示角度
* \param[out] rotated_vector结果向量
        */
      void
      rotateVector (const Eigen::Vector3f& vector, const Eigen::Vector3f& axis, const float angle, Eigen::Vector3f& rotated_vector) const;

      /** \brief This method computes center of mass and axis aligned bounding box. */
/** \brief该方法计算质心和轴对齐的包围盒。*/
      void
      computeMeanValue ();

      /** \brief This method computes the oriented bounding box. */
/*这个方法计算有方向的包围框。*/
      void
      computeOBB ();

      /** \brief This method computes the covariance matrix for the input_ cloud.
        * \param[out] covariance_matrix stores the computed covariance matrix

这种方法计算输入云的协方差矩阵。
* \param[out] covariance_matrix存储计算的协方差矩阵
        */
      void
      computeCovarianceMatrix (Eigen::Matrix <float, 3, 3>& covariance_matrix) const;

      /** \brief This method computes the covariance matrix for the given cloud.
        * It uses all points in the cloud, unlike the previous method that uses indices.
        * \param[in] cloud cloud for which covariance matrix will be computed
        * \param[out] covariance_matrix stores the computed covariance matrix

这种方法计算给定云的协方差矩阵。
*它使用了云中的所有点,不像之前使用索引的方法。
param[in] cloud 云的协方差矩阵将计算
* \param[out] covariance_matrix存储计算的协方差矩阵
        */
      void
      computeCovarianceMatrix (PointCloudConstPtr cloud, Eigen::Matrix <float, 3, 3>& covariance_matrix) const;

      /** \brief This method calculates the eigen values and eigen vectors
        * for the given covariance matrix. Note that it returns normalized eigen
        * vectors that always form the right-handed coordinate system.
        * \param[in] covariance_matrix covariance matrix
        * \param[out] major_axis eigen vector which corresponds to a major eigen value
        * \param[out] middle_axis eigen vector which corresponds to a middle eigen value
        * \param[out] minor_axis eigen vector which corresponds to a minor eigen value
        * \param[out] major_value major eigen value
        * \param[out] middle_value middle eigen value
        * \param[out] minor_value minor eigen value

该方法计算给定协方差矩阵的特征值和特征向量。注意,它返回总是形成右手坐标系的标准化特征向量。
* \param[in] covariance_matrix
* \param[out] major_axis特征向量,对应于一个主要特征值
* \param[out] middle_axis特征向量,对应中间特征值
* \param[out] minor_axis特征向量,对应于一个小特征值
* \param[out] major_value主特征值
* \param[out] middle_value中间特征值
* \param[out] minor_value小特征值
        */
      void
      computeEigenVectors (const Eigen::Matrix <float, 3, 3>& covariance_matrix, Eigen::Vector3f& major_axis,
                           Eigen::Vector3f& middle_axis, Eigen::Vector3f& minor_axis, float& major_value, float& middle_value,
                           float& minor_value);

      /** \brief This method returns the moment of inertia of a given input_ cloud.
        * Note that when moment of inertia is computed it is multiplied by the point mass.
        * Point mass can be accessed with the corresponding get/set methods.
        * \param[in] current_axis axis that will be used in moment of inertia computation
        * \param[in] mean_value mean value(center of mass) of the cloud

/** \brief这个方法返回给定输入云的惯性矩。
*注意当计算转动惯量时,转动惯量乘以质点质量。
*点质量可以通过相应的get/set方法访问。
* \param[in] current_axis用于计算惯性矩的轴
param[in] mean_value云的平均值(质心)
        */
      float
      calculateMomentOfInertia (const Eigen::Vector3f& current_axis, const Eigen::Vector3f& mean_value) const;

      /** \brief This method simply projects the given input_ cloud on the plane specified with
        * the normal vector.
        * \param[in] normal_vector nrmal vector of the plane
        * \param[in] point point belonging to the plane
        * \param[out] projected_cloud projected cloud
这个方法简单地将给定的输入云投影到法向量指定的平面上。
\param[in] normal_vector平面的法向量
param[in]点属于平面的点
* \param[out] projted_cloud投影的云
        */
      void
      getProjectedCloud (const Eigen::Vector3f& normal_vector, const Eigen::Vector3f& point, typename pcl::PointCloud <PointT>::Ptr projected_cloud) const;

      /** \brief This method returns the eccentricity of the projected cloud.
        * \param[in] covariance_matrix covariance matrix of the projected cloud
        * \param[in] normal_vector normal vector of the plane, it is used to discard the
        *            third eigen vector and eigen value*/

/** \brief这个方法返回投影云的离心率。
* param[in] covariance_matrix投影云的协方差矩阵
* \param[in] normal_vector平面的法向量,用来丢弃
*第三个特征向量和特征值*/
      float
      computeEccentricity (const Eigen::Matrix <float, 3, 3>& covariance_matrix, const Eigen::Vector3f& normal_vector);

    private:

      /** \brief Indicates if the stored values (eccentricity, moment of inertia, AABB etc.)
        * are valid when accessed with the get methods. */
      bool is_valid_;

      /** \brief Stores the angle step */
      float step_;

      /** \brief Stores the mass of point in the cloud */
      float point_mass_;

      /** \brief Stores the flag for mass normalization */
      bool normalize_;

      /** \brief Stores the mean value (center of mass) of the cloud */
      Eigen::Vector3f mean_value_;

      /** \brief Major eigen vector */
      Eigen::Vector3f major_axis_;

      /** \brief Middle eigen vector */
      Eigen::Vector3f middle_axis_;

      /** \brief Minor eigen vector */
      Eigen::Vector3f minor_axis_;

      /** \brief Major eigen value */
      float major_value_;

      /** \brief Middle eigen value */
      float middle_value_;

      /** \brief Minor eigen value */
      float minor_value_;

      /** \brief Stores calculated moments of inertia */
      std::vector <float> moment_of_inertia_;

      /** \brief Stores calculated eccentricities */
      std::vector <float> eccentricity_;

      /** \brief Min point of the axis aligned bounding box */
      PointT aabb_min_point_;

      /** \brief Max point of the axis aligned bounding box */
      PointT aabb_max_point_;

      /** \brief Min point of the oriented bounding box */
      PointT obb_min_point_;

      /** \brief Max point of the oriented bounding box */
      PointT obb_max_point_;

      /** \brief Stores position of the oriented bounding box */
      Eigen::Vector3f obb_position_;

      /** \brief Stores the rotational matrix of the oriented bounding box */
      Eigen::Matrix3f obb_rotational_matrix_;

    public:
      EIGEN_MAKE_ALIGNED_OPERATOR_NEW
  };
}

#define PCL_INSTANTIATE_MomentOfInertiaEstimation(T) template class pcl::MomentOfInertiaEstimation<T>;

#ifdef PCL_NO_PRECOMPILE
#include <pcl/features/impl/moment_of_inertia_estimation.hpp>
#endif

#endif
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值