【问题标题】:Convert pcl point type XYZ to Eigen Vector 4f将 pcl 点类型 XYZ 转换为特征向量 4f
【发布时间】:2015-07-29 22:57:26
【问题描述】:

我正在尝试将 pcl pointXYZ 转换为特征向量

Eigen::Vector4f min (minPnt.x, minPnt.y, minPnt.z);  
Eigen::Vector4f max (maxPnt.x, maxPnt.y, maxPnt.z);

其中 minPnt 和 maxPnt 的类型为 pcl::PointXYZ。 但是,我收到一个错误为 "error C2338: THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE" 。您能否建议一些其他方法或让我知道我的方法是否错误。

【问题讨论】:

    标签: c++ point-cloud-library eigenvector


    【解决方案1】:

    请使用getVector4fMap()获取Eigen::Vector4f并使用getVector3fMap()获取Eigen::Vector3f

    例子:

    PointT pcl_pt = ...;
    Eigen::Vector3f e_v3f_pt = pcl_pt.getVector3fMap();
    Eigen::Vector4f e_v4f_pt = pcl_pt.getVector4fMap();
    

    如果你拥有的是pcl::Normal,你可以尝试使用getNormalVector4fMap,如下所示

    pcl::Normal pcl_normal(0, 0, 1);
    Eigen::Vector4f eigen_normal = pcl_normal.getNormalVector4fMap();
    

    【讨论】:

      【解决方案2】:

      我用下面的代码解决了上述问题。

      auto x_min = static_cast<float>(minPnt.x); 
      auto y_min = static_cast<float>(minPnt.y); 
      auto z_min = static_cast<float>(minPnt.z); 
      
      auto x_max = static_cast<float>(maxPnt.x); 
      auto y_max = static_cast<float>(maxPnt.y); 
      auto z_max = static_cast<float>(maxPnt.z); 
      
      Eigen::Vector4f min(x_min, y_min, z_min, 0.0); 
      Eigen::Vector4f max(x_max, y_max, z_max, 0.0); 
      

      如果有更好的方法,请提出建议。

      【讨论】:

        【解决方案3】:

        eigen::Vector4f 正在寻找 4 个浮点数,但您只给了它 3 个 (x, y, z)。尝试在末尾添加一个 0:

        Eigen::Vector4f min (minPnt.x, minPnt.y, minPnt.z, 0);  
        Eigen::Vector4f max (maxPnt.x, maxPnt.y, maxPnt.z, 0);
        

        【讨论】:

        • 如果您使用的是 (x,y,z,w) 坐标,则为 1
        猜你喜欢
        • 2012-12-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多