Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Image Manager/Cvb++/CppPointCloudCreateAndHandle

This example program is located in your CVB installation under %CVB%Tutorial/Image Manager/Cvb++/CppPointCloudCreateAndHandle.

main.cpp:

// This simple point cloud example programm shows how to create a dense point cloud and set values to
// it.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#include <iostream>
#include "cvb/point_cloud_factory.hpp"
#include "cvb/point_cloud.hpp"
void SetValuesToDensePointCloud(Cvb::DensePointCloud &cloud, const float initialValue);
int main()
{
try
{
// create dense point cloud
int width = 25, height = 20;
auto cloudDense = Cvb::PointCloudFactory::CreateDense(Cvb::Size2D<int>(width, height),
Cvb::PointCloudFlags::Float | Cvb::PointCloudFlags::XYZ);
// set intial values to points of cloud
SetValuesToDensePointCloud(*cloudDense, 123.4f);
}
catch (const std::exception & error)
{
std::cout << error.what() << std::endl;
}
return 0;
}
void SetValuesToDensePointCloud(Cvb::DensePointCloud &cloud, const float initialValue)
{
Cvb::Point3D<float>* pPoints = nullptr;
cloud.Points(pPoints);
auto size = cloud.LatticeSize();
float x = 0, y = 0;
auto end = pPoints + cloud.NumPoints();
for (auto it = pPoints; it != end; it++)
{
*it = Cvb::Point3D<float>{ x++,y,initialValue };
if (x >= size.Width())
{
x = 0;
y++;
}
}
}
Cvb::Size2D< int > LatticeSize() const
static DensePointCloudPtr CreateDense(Size2D< int > size, PointCloudFlags flags)
std::size_t Points(Point3D< T > *&points) const
std::size_t NumPoints() const