当前位置: 首页>>代码示例>>C++>>正文


C++ MatrixXf::conservativeResize方法代码示例

本文整理汇总了C++中eigen::MatrixXf::conservativeResize方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXf::conservativeResize方法的具体用法?C++ MatrixXf::conservativeResize怎么用?C++ MatrixXf::conservativeResize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eigen::MatrixXf的用法示例。


在下文中一共展示了MatrixXf::conservativeResize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convert

int Conversion::convert(const Eigen::MatrixXf & depthMat,
                                 Eigen::MatrixXf & point3D,
                                 double &fx,
                                 double &fy,
                                 double &cx,
                                 double &cy)
{
      //max resize
      point3D.resize(depthMat.rows()*depthMat.cols(),3);
    
      int index(0);
      for (int i=0; i<depthMat.rows();i++)
        for (int j=0 ; j<depthMat.cols();j++)
        {
          float z = depthMat(i,j);
          if (fabs( z+ 1.f) > std::numeric_limits<float>::epsilon() 
            & fabs(z) !=1
            & z > std::numeric_limits<float>::epsilon() ){
            point3D(index,2) = z;
            point3D(index,0) = (i-cx)*point3D(index,2)/fx; 
            point3D(index,1) = (j-cy)*point3D(index,2)/fy;
            index++;
          }
        }
        //min resize
        point3D.conservativeResize(index,3);
        return 1;
}     
开发者ID:clairedune,项目名称:gaitan,代码行数:28,代码来源:conversion.cpp

示例2: runtime_error

Eigen::MatrixXf
readDescrFromFile(const std::string &file, int padding, int rowSize)
{

    // check if file exists
    boost::filesystem::path path = file;
    if ( ! (boost::filesystem::exists ( path ) && boost::filesystem::is_regular_file(path)) )
        throw std::runtime_error ("Given file path to read Matrix does not exist!");

    std::ifstream in (file.c_str (), std::ifstream::in);

    int bufferSize = 819200;
    //int bufferSize = rowSize * 10;

    char linebuf[bufferSize];



    Eigen::MatrixXf matrix;
    matrix.resize(0,rowSize);
    int j=0;
    while(in.getline (linebuf, bufferSize)){
        int start_s=clock();
        std::string line (linebuf);
        std::vector < std::string > strs_2;
        boost::split (strs_2, line, boost::is_any_of (" "));
        matrix.conservativeResize(matrix.rows()+1,rowSize);
        for (int i = 0; i < strs_2.size()-1; i++)
            matrix (j, i) = static_cast<float> (atof (strs_2[i].c_str ()));
        j++;
        int stop_s=clock();
        std::cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << std::endl;
    }
    return matrix;
}
开发者ID:Cerarus,项目名称:v4r,代码行数:35,代码来源:eigen.cpp


注:本文中的eigen::MatrixXf::conservativeResize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。