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

This example program is located in your CVB installation under %CVB%Tutorial/DNC/Cvb++/CppDncConsole.

main.cpp:

// The CppDncConsole example shows how to use DNC functionality. The console output gives information
// about the required steps how to **find a pattern in a dense point cloud**.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
#include <iostream>
#include <cvb/point_cloud_factory.hpp>
#include <cvb/point_cloud.hpp>
#include <cvb/dense_point_cloud.hpp>
#include <cvb/dnc/finder.hpp>
int main(int /*argc*/, char* /*argv*/[])
{
try
{
const auto path = Cvb::InstallPath();
// Load DNC search pattern
std::cout << "Load the search pattern...\n";
auto finder = Cvb::Dnc::Finder::Load(path + CVB_LIT("tutorial/DNC/Images/Genie/GenieTest.dnc"));
// Create a dense point cloud
std::cout << "Create a dense point cloud...\n";
auto densePointCloud = Cvb::PointCloudFactory::Load<Cvb::DensePointCloud>(path + CVB_LIT("tutorial/DNC/Images/Genie/GenieTest.tif"),
Cvb::PointCloudFlags::Float | Cvb::PointCloudFlags::XYZ);
// Define the search parameteres
std::cout << "Define the search parameters...\n";
params.SetIndifferentRadius(1.0);
params.SetPartsToFind(0); // find all objects
params.SetRawResultsOnly(false);
params.SetICPShrink(4);
params.SetICPMaxIterations(10);
params.SetPrecisionThreshold(2.0);
params.SetMinCoverage(0.70);
params.SetMaxOcclusion(0.20);
params.SetMaxInconsistency(0.20);
params.SetMinScore(0.70);
// Start the search
std::cout << "Run the search on the point cloud...\n";
auto searchResult = finder->Find(*densePointCloud, params);
// Output of the search result
std::cout << "Number of search results: " << searchResult.size() << "\n";
int counter = 0;
for (const auto& result : searchResult) {
std::cout << counter
<< ": position(x=" << result.Position().X()
<< ",y=" << result.Position().Y()
<< ",z=" << result.Position().Z()
<< "), rotation(x=" << result.RotationVector().X()
<< ",y=" << result.RotationVector().Y()
<< ",z=" << result.RotationVector().Z()
<< "), theta=" << result.Theta().Deg()
<< "\370, score=" << result.Score() << "\n";
// \370 = � to display on console
++counter;
}
}
catch (const std::exception& error)
{
std::cout << error.what() << std::endl;
}
}
static std::unique_ptr< Finder > Load(const String &fileName)
void SetMaxInconsistency(double value)
void SetPrecisionThreshold(double value)
void SetMaxOcclusion(double value)
void SetHypothesesThreshold(double value)
void SetMinScore(double value)
void SetDerivativePatchSize(int value)
void SetICPMaxIterations(int value)
void SetICPShrink(int value)
void SetMinCoverage(double value)
void SetPartsToFind(int value)
void SetRawResultsOnly(bool value) noexcept
void SetIndifferentRadius(double value)
static std::shared_ptr< T > Load(const String &fileName, PointCloudFlags flags)
String InstallPath()