bantmen
bantmen

Reputation: 768

Creating PointCloud from std::vector

I have some points in a std::vector collection and I am trying to use that to create a pcl::PointCloud object. Looking at the documentation did not help me out. Any ideas?

Upvotes: 0

Views: 1840

Answers (1)

Teivaz
Teivaz

Reputation: 5675

Just copy element by element:

void CloudToVector(const std::vector<PointType>& inPointVector, PointCloud& outPointCloud)
{
    for(const PointType& point : inPointVector)
    {
        outPointCloud.push_back(point);
    }
}

UPD this should also work

void CloudToVector(const std::vector<PointType>& inPointVector, PointCloud& outPointCloud)
{
    outPointCloud.points = inPointVector;
}

Upvotes: 1

Related Questions