本文整理汇总了C++中eigen::Matrix::conservativeResize方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::conservativeResize方法的具体用法?C++ Matrix::conservativeResize怎么用?C++ Matrix::conservativeResize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Matrix
的用法示例。
在下文中一共展示了Matrix::conservativeResize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bb_scan
//.........这里部分代码省略.........
}
Eigen::VectorXd bbH(21);
//scale bb on y axis
for (unsigned int x = 0; x < 21; x++) {
bbH(x) = floor((bb_height(bb) * scale(x)) + 0.5);
}
Eigen::VectorXd bbSHH(21);
Eigen::VectorXd bbSHW(21);
//shift the scales
for (unsigned int x = 0; x < 21; x++)
bbSHH(x) = bbH(x) * shift;
for (unsigned int x = 0; x < 21; x++) {
if (bbH(x) <= bbW(x))
bbSHW(x) = bbH(x) * shift;
else
bbSHW(x) = bbW(x) * shift;
}
Eigen::VectorXd bbF(4);
bbF << 2, 2, imsize(0), imsize(1);
Eigen::Matrix<double, 6, Eigen::Dynamic> bbs;
Eigen::Matrix<double, 6, Eigen::Dynamic> bbsbak;
Eigen::Matrix<double, 2, Eigen::Dynamic> sca;
//create a grid of bounding boxes with different scales
for (unsigned int i = 0, last_scale = 0; i < 21; i++) {
if (bbW(i) < minBB || bbH(i) < minBB)
continue;
Eigen::VectorXd left;
Eigen::VectorXd leftbak;
Eigen::VectorXd top;
Eigen::VectorXd topbak;
double val;
val = bbF(0);
for (unsigned int p = 0; val <= bbF(2) - bbW(i) - 1; val += bbSHW(i), p++) {
leftbak.resize(left.size());
leftbak = left;
left.resize(p + 1);
if (p > 0)
left << leftbak, floor(val + 0.5);
else
left(0) = floor(val + 0.5);
}
if(left.size() == 0)
continue;
val = bbF(1);
for (unsigned int p = 0; val <= bbF(3) - bbH(i) - 1; val += bbSHH(i), p++) {
topbak.resize(top.size());
topbak = top;
top.resize(p + 1);
if (p > 0)
top << topbak, floor(val + 0.5);
else
top(0) = floor(val + 0.5);
}
if(top.size() == 0)
continue;
Eigen::MatrixXd grid(2, top.size() * left.size());
unsigned int cnt = 0;
for (int k = 0; k < left.size(); k++)
for (int w = 0; w < top.size(); w++) {
grid(0, cnt) = top(w);
grid(1, cnt) = left(k);
cnt++;
}
Eigen::MatrixXd bbsnew(6, grid.cols());
bbsnew.row(0) = grid.row(1);
bbsnew.row(1) = grid.row(0);
bbsnew.row(2) = grid.array().row(1) + bbW(i) - 1;
bbsnew.row(3) = grid.array().row(0) + bbH(i) - 1;
bbsnew.row(4) = Eigen::MatrixXd::Constant(1, grid.cols(), last_scale + 1);
bbsnew.row(5) = Eigen::MatrixXd::Constant(1, grid.cols(), left.size());
bbsbak.resize(6, bbs.cols());
bbsbak = bbs;
bbs.resize(6, bbs.cols() + bbsnew.cols());
//lets have some fun!
if (i > 0)
bbs << bbsbak, bbsnew;
else
bbs = bbsnew;
//save the scales on x and y axis
sca.conservativeResize(2, sca.cols() + 1);
sca(0, sca.cols() - 1) = bbH(i);
sca(1, sca.cols() - 1) = bbW(i);
last_scale++;
}
tld.grid = bbs;
tld.nGrid = bbs.cols();
tld.scales = sca;
}