本文整理汇总了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;
}
示例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;
}