本文整理汇总了C++中DataPoints::allocateDescriptors方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPoints::allocateDescriptors方法的具体用法?C++ DataPoints::allocateDescriptors怎么用?C++ DataPoints::allocateDescriptors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPoints
的用法示例。
在下文中一共展示了DataPoints::allocateDescriptors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointsCount
void DataPointsFiltersImpl<T>::SamplingSurfaceNormalDataPointsFilter::inPlaceFilter(
DataPoints& cloud)
{
typedef Matrix Features;
typedef typename DataPoints::View View;
typedef typename DataPoints::Label Label;
typedef typename DataPoints::Labels Labels;
const int pointsCount(cloud.features.cols());
const int featDim(cloud.features.rows());
const int descDim(cloud.descriptors.rows());
int insertDim(0);
if (averageExistingDescriptors)
{
// TODO: this should be in the form of an assert
// Validate descriptors and labels
for(unsigned int i = 0; i < cloud.descriptorLabels.size(); i++)
insertDim += cloud.descriptorLabels[i].span;
if (insertDim != descDim)
throw InvalidField("SamplingSurfaceNormalDataPointsFilter: Error, descriptor labels do not match descriptor data");
}
// Compute space requirement for new descriptors
const int dimNormals(featDim-1);
const int dimDensities(1);
const int dimEigValues(featDim-1);
const int dimEigVectors((featDim-1)*(featDim-1));
// Allocate space for new descriptors
Labels cloudLabels;
if (keepNormals)
cloudLabels.push_back(Label("normals", dimNormals));
if (keepDensities)
cloudLabels.push_back(Label("densities", dimDensities));
if (keepEigenValues)
cloudLabels.push_back(Label("eigValues", dimEigValues));
if (keepEigenVectors)
cloudLabels.push_back(Label("eigVectors", dimEigVectors));
cloud.allocateDescriptors(cloudLabels);
// we keep build data on stack for reentrant behaviour
View cloudExistingDescriptors(cloud.descriptors.block(0,0,cloud.descriptors.rows(),cloud.descriptors.cols()));
BuildData buildData(cloud.features, cloud.descriptors);
// get views
if (keepNormals)
buildData.normals = cloud.getDescriptorViewByName("normals");
if (keepDensities)
buildData.densities = cloud.getDescriptorViewByName("densities");
if (keepEigenValues)
buildData.eigenValues = cloud.getDescriptorViewByName("eigValues");
if (keepEigenVectors)
buildData.eigenVectors = cloud.getDescriptorViewByName("eigVectors");
// build the new point cloud
buildNew(
buildData,
0,
pointsCount,
cloud.features.rowwise().minCoeff(),
cloud.features.rowwise().maxCoeff()
);
// Bring the data we keep to the front of the arrays then
// wipe the leftover unused space.
std::sort(buildData.indicesToKeep.begin(), buildData.indicesToKeep.end());
int ptsOut = buildData.indicesToKeep.size();
for (int i = 0; i < ptsOut; i++){
int k = buildData.indicesToKeep[i];
assert(i <= k);
cloud.features.col(i) = cloud.features.col(k);
if (cloud.descriptors.rows() != 0)
cloud.descriptors.col(i) = cloud.descriptors.col(k);
if(keepNormals)
buildData.normals->col(i) = buildData.normals->col(k);
if(keepDensities)
(*buildData.densities)(0,i) = (*buildData.densities)(0,k);
if(keepEigenValues)
buildData.eigenValues->col(i) = buildData.eigenValues->col(k);
if(keepEigenVectors)
buildData.eigenVectors->col(i) = buildData.eigenVectors->col(k);
}
cloud.features.conservativeResize(Eigen::NoChange, ptsOut);
cloud.descriptors.conservativeResize(Eigen::NoChange, ptsOut);
// warning if some points were dropped
if(buildData.unfitPointsCount != 0)
LOG_INFO_STREAM(" SamplingSurfaceNormalDataPointsFilter - Could not compute normal for " << buildData.unfitPointsCount << " pts.");
}